Skip to content
Eddy Spreeuwers edited this page Mar 23, 2021 · 5 revisions

This xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
 <xs:element name="choose1">
  <xs:complexType>
   <xs:choice >
    <xs:element name="item"  type="xs:string"/>
    <xs:element name="param" type="xs:integer"/>
   </xs:choice>
  </xs:complexType>
 </xs:element>
 <xs:complexType name="choose2">
  <xs:sequence>
   <xs:element name="item"  type="xs:string"/>
   <xs:choice>
    <xs:element name="b"  type="xs:string"/>
    <xs:element name="c"  type="xs:string"/>
   </xs:choice>
  </xs:sequence>
  <xs:attribute name="a1" use="required" type="xs:dateTime"/>
  <xs:attribute name="a2" use="required" type="xs:dateTime"/>
  <xs:attribute name="a0"  type="xs:dateTime"/>
 </xs:complexType>
</xs:schema>

converts to:

/***********
generated template classes for ./test/xsd/choice.xsd 3/23/2021, 11:17:52 PM
***********/
export class Choice {
    public choose1: Choose1;
    public choose2: Choose2;
    public constructor(props?: Choice) {
       this["@class"] = ".Choice";
       (<any>Object).assign(this, <any> props);
    }
}

export class Choose1 {
   //choice
   public item(arg: string) {
      delete((this as any).param);
      (this as any).item = arg;
   } 

   //choice
   public param(arg: number) {
      delete((this as any).item);
      (this as any).param = arg;
   }
   
   public constructor(props?: Choose1) {
       this["@class"] = ".Choose1";  
       (<any>Object).assign(this, <any> props);
   }
}

export class Choose2 {
    public item: string;
    public $a1: Date;
    public $a2: Date;
    public $a0: Date;
    //choice
    public b(arg: string) {
       delete((this as any).c);
       (this as any).b = arg;
    }
    //choice
    public c(arg: string) {
       delete((this as any).b);
       (this as any).c = arg;
    }
    public constructor(props?: Choose2) {
        this["@class"] = ".Choose2";
        (<any>Object).assign(this, <any> props);
    }
 }
Clone this wiki locally