|
1 | 1 | package main |
2 | 2 |
|
3 | | -// import ( |
4 | | -// "encoding/xml" |
5 | | -// ) |
| 3 | +import ( |
| 4 | + "encoding/xml" |
| 5 | +) |
6 | 6 |
|
7 | 7 | type XsdSchema struct { |
| 8 | + XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema schema"` |
| 9 | + Tns string `xml:"xmlns tns",attr` |
| 10 | + Xs string `xml:"xmlns xs,attr"` |
| 11 | + Version string `xml:"version,attr"` |
8 | 12 | TargetNamespace string `xml:"targetNamespace,attr"` |
9 | 13 | ElementFormDefault string `xml:"elementFormDefault,attr"` |
10 | 14 | Includes []*XsdInclude `xml:"http://www.w3.org/2001/XMLSchema include"` |
11 | 15 | Imports []*XsdImport `xml:"http://www.w3.org/2001/XMLSchema import"` |
12 | 16 | Elements []*XsdElement `xml:"http://www.w3.org/2001/XMLSchema element"` |
13 | | - ComplexTypes []*XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"` |
| 17 | + ComplexTypes []*XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"` //global |
| 18 | + SimpleType []*XsdSimpleType `xml:"http://www.w3.org/2001/XMLSchema simpleType"` |
14 | 19 | } |
15 | 20 |
|
16 | 21 | type XsdInclude struct { |
17 | 22 | SchemaLocation string `xml:"schemaLocation,attr"` |
18 | 23 | } |
19 | 24 |
|
20 | 25 | type XsdImport struct { |
21 | | - SchemaLocation string `xml:"schemaLocation,attr"` |
22 | | - Namespace string `xml:"namespace,attr"` |
| 26 | + XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema import"` |
| 27 | + SchemaLocation string `xml:"schemaLocation,attr"` |
| 28 | + Namespace string `xml:"namespace,attr"` |
23 | 29 | } |
24 | 30 |
|
25 | 31 | type XsdElement struct { |
| 32 | + XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema element"` |
26 | 33 | Name string `xml:"name,attr"` |
27 | 34 | Nillable bool `xml:"nillable,attr"` |
28 | 35 | Type string `xml:"type,attr"` |
29 | 36 | MinOccurs string `xml:"minOccurs,attr"` |
30 | 37 | MaxOccurs string `xml:"maxOccurs,attr"` |
31 | | - ComplexType *XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"` |
| 38 | + ComplexType *XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"` //local |
32 | 39 | SimpleType *XsdSimpleType `xml:"http://www.w3.org/2001/XMLSchema simpleType"` |
| 40 | + Groups []*XsdGroup `xml:"http://www.w3.org/2001/XMLSchema group"` |
33 | 41 | } |
34 | 42 |
|
35 | 43 | type XsdComplexType struct { |
36 | | - Name string `xml:"name,attr"` |
37 | | - Sequence *XsdSequence `xml:"http://www.w3.org/2001/XMLSchema sequence"` |
| 44 | + XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema complexType"` |
| 45 | + Abstract bool `xml:"abstract,attr"` |
| 46 | + Name string `xml:"name,attr"` |
| 47 | + Mixed bool `xml:"mixed,attr"` |
| 48 | + Sequence []XsdElement `xml:"sequence>element"` |
| 49 | + Choice []XsdElement `xml:"choice>element"` |
| 50 | + All []XsdElement `xml:"all>element"` |
| 51 | + Content XsdComplexContent `xml:"http://www.w3.org/2001/XMLSchema complexContent"` |
38 | 52 | } |
39 | 53 |
|
40 | | -type XsdSimpleType struct { |
41 | | - Name string `xml:"name,attr"` |
42 | | - Sequence *XsdRestriction `xml:"http://www.w3.org/2001/XMLSchema restriction"` |
| 54 | +type XsdGroup struct { |
| 55 | + Name string `xml:"name, attr"` |
| 56 | + Ref string `xml:"ref,attr"` |
| 57 | + Sequence []XsdElement `xml:"http://www.w3.org/2001/XMLSchema sequence"` |
| 58 | + Choice []XsdElement `xml:"http://www.w3.org/2001/XMLSchema choice"` |
| 59 | + All []XsdElement `xml:"http://www.w3.org/2001/XMLSchema all"` |
43 | 60 | } |
44 | 61 |
|
45 | | -type XsdSequence struct { |
46 | | - Elements []*XsdElement `xml:"http://www.w3.org/2001/XMLSchema element"` |
| 62 | +type XsdComplexContent struct { |
| 63 | + XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema complexContent"` |
| 64 | + Extension XsdExtension `xml:"http://www.w3.org/2001/XMLSchema extension"` |
47 | 65 | } |
48 | 66 |
|
49 | | -type XsdRestriction struct { |
50 | | - Base string `xml:"base,attr"` |
51 | | - Pattern *XsdPattern `xml:"http://www.w3.org/2001/XMLSchema pattern"` |
52 | | - MinInclusive *XsdMinInclusive `xml:"http://www.w3.org/2001/XMLSchema minInclusive"` |
53 | | - MaxInclusive *XsdMaxInclusive `xml:"http://www.w3.org/2001/XMLSchema maxInclusive"` |
| 67 | +type XsdExtension struct { |
| 68 | + XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema extension"` |
| 69 | + Base string `xml:"base,attr"` |
| 70 | + Sequence XsdSequence `xml:"http://www.w3.org/2001/XMLSchema extension sequence"` |
54 | 71 | } |
55 | 72 |
|
56 | | -type XsdPattern struct { |
57 | | - Value string `xml:"value,attr"` |
| 73 | +type XsdSimpleType struct { |
| 74 | + Name string `xml:"name,attr"` |
| 75 | + Retriction XsdRestriction `xml:"http://www.w3.org/2001/XMLSchema restriction"` |
58 | 76 | } |
59 | 77 |
|
60 | | -type XsdMinInclusive struct { |
61 | | - Value string `xml:"value,attr"` |
| 78 | +type XsdSequence struct { |
| 79 | + Elements []XsdElement `xml:"http://www.w3.org/2001/XMLSchema element"` |
| 80 | +} |
| 81 | + |
| 82 | +type XsdRestriction struct { |
| 83 | + Base string `xml:"base,attr"` |
| 84 | + Enumeration []XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema enumeration"` |
| 85 | + Pattern XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema pattern"` |
| 86 | + MinInclusive XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema minInclusive"` |
| 87 | + MaxInclusive XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema maxInclusive"` |
| 88 | + WhiteSpace XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema whitespace"` |
| 89 | + Length XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema length"` |
| 90 | + MinLength XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema minLength"` |
| 91 | + MaxLength XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema maxLength"` |
62 | 92 | } |
63 | 93 |
|
64 | | -type XsdMaxInclusive struct { |
| 94 | +type XsdRestrictionValue struct { |
65 | 95 | Value string `xml:"value,attr"` |
66 | 96 | } |
0 commit comments