-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxsd.go
113 lines (98 loc) · 4.89 KB
/
xsd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package main
import (
"encoding/xml"
)
type XsdSchema struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema schema"`
Tns string `xml:"xmlns tns,attr"`
Xs string `xml:"xmlns xs,attr"`
Version string `xml:"version,attr"`
TargetNamespace string `xml:"targetNamespace,attr"`
ElementFormDefault string `xml:"elementFormDefault,attr"`
Includes []*XsdInclude `xml:"http://www.w3.org/2001/XMLSchema include"`
Imports []*XsdImport `xml:"http://www.w3.org/2001/XMLSchema import"`
Elements []*XsdElement `xml:"http://www.w3.org/2001/XMLSchema element"`
ComplexTypes []*XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"` //global
SimpleType []*XsdSimpleType `xml:"http://www.w3.org/2001/XMLSchema simpleType"`
}
type XsdInclude struct {
SchemaLocation string `xml:"schemaLocation,attr"`
}
type XsdImport struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema import"`
SchemaLocation string `xml:"schemaLocation,attr"`
Namespace string `xml:"namespace,attr"`
}
type XsdElement struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema element"`
Name string `xml:"name,attr"`
Nillable bool `xml:"nillable,attr"`
Type string `xml:"type,attr"`
Ref string `xml:"ref,attr"`
MinOccurs string `xml:"minOccurs,attr"`
MaxOccurs string `xml:"maxOccurs,attr"`
ComplexType *XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"` //local
SimpleType *XsdSimpleType `xml:"http://www.w3.org/2001/XMLSchema simpleType"`
Groups []*XsdGroup `xml:"http://www.w3.org/2001/XMLSchema group"`
}
type XsdComplexType struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema complexType"`
Abstract bool `xml:"abstract,attr"`
Name string `xml:"name,attr"`
Mixed bool `xml:"mixed,attr"`
Sequence XsdSequence `xml:"http://www.w3.org/2001/XMLSchema sequence"`
Choice []XsdElement `xml:"choice>element"`
All []XsdElement `xml:"all>element"`
ComplexContent XsdComplexContent `xml:"http://www.w3.org/2001/XMLSchema complexContent"`
SimpleContent XsdSimpleContent `xml:"http://www.w3.org/2001/XMLSchema simpleContent"`
Attributes []*XsdAttribute `xml:"http://www.w3.org/2001/XMLSchema attribute"`
}
type XsdGroup struct {
Name string `xml:"name,attr"`
Ref string `xml:"ref,attr"`
Sequence XsdSequence `xml:"http://www.w3.org/2001/XMLSchema sequence"`
Choice []XsdElement `xml:"http://www.w3.org/2001/XMLSchema choice"`
All []XsdElement `xml:"http://www.w3.org/2001/XMLSchema all"`
}
type XsdComplexContent struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema complexContent"`
Extension XsdExtension `xml:"http://www.w3.org/2001/XMLSchema extension"`
}
type XsdSimpleContent struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema simpleContent"`
Extension XsdExtension `xml:"http://www.w3.org/2001/XMLSchema extension"`
}
type XsdExtension struct {
XMLName xml.Name `xml:"http://www.w3.org/2001/XMLSchema extension"`
Base string `xml:"base,attr"`
Attributes []*XsdAttribute `xml:"http://www.w3.org/2001/XMLSchema attribute"`
Sequence XsdSequence `xml:"http://www.w3.org/2001/XMLSchema sequence"`
}
type XsdAttribute struct {
Name string `xml:"name,attr"`
Type string `xml:"type,attr"`
}
type XsdSimpleType struct {
Name string `xml:"name,attr"`
Restriction XsdRestriction `xml:"http://www.w3.org/2001/XMLSchema restriction"`
}
type XsdSequence struct {
Elements []XsdElement `xml:"http://www.w3.org/2001/XMLSchema element"`
}
type XsdRestriction struct {
Base string `xml:"base,attr"`
Enumeration []XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema enumeration"`
Pattern XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema pattern"`
MinInclusive XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema minInclusive"`
MaxInclusive XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema maxInclusive"`
WhiteSpace XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema whitespace"`
Length XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema length"`
MinLength XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema minLength"`
MaxLength XsdRestrictionValue `xml:"http://www.w3.org/2001/XMLSchema maxLength"`
}
type XsdRestrictionValue struct {
Value string `xml:"value,attr"`
}