forked from hooklift/gowsdl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xsd.go
135 lines (120 loc) · 5.34 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// 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 gowsdl
import (
"encoding/xml"
)
// XSDSchema represents an entire Schema structure.
type XSDSchema struct {
XMLName xml.Name `xml:"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:"include"`
Imports []*XSDImport `xml:"import"`
Elements []*XSDElement `xml:"element"`
ComplexTypes []*XSDComplexType `xml:"complexType"` //global
SimpleType []*XSDSimpleType `xml:"simpleType"`
}
// XSDInclude represents schema includes.
type XSDInclude struct {
SchemaLocation string `xml:"schemaLocation,attr"`
}
// XSDImport represents XSD imports within the main schema.
type XSDImport struct {
XMLName xml.Name `xml:"import"`
SchemaLocation string `xml:"schemaLocation,attr"`
Namespace string `xml:"namespace,attr"`
}
// XSDElement represents a Schema element.
type XSDElement struct {
XMLName xml.Name `xml:"element"`
Name string `xml:"name,attr"`
Doc string `xml:"annotation>documentation"`
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:"complexType"` //local
SimpleType *XSDSimpleType `xml:"simpleType"`
Groups []*XSDGroup `xml:"group"`
}
// XSDComplexType represents a Schema complex type.
type XSDComplexType struct {
XMLName xml.Name `xml:"complexType"`
Abstract bool `xml:"abstract,attr"`
Name string `xml:"name,attr"`
Doc string `xml:"annotation>documentation"`
Mixed bool `xml:"mixed,attr"`
Sequence []XSDElement `xml:"sequence>element"`
Choice []XSDElement `xml:"choice>element"`
SequenceChoice []XSDElement `xml:"sequence>choice>element"`
All []XSDElement `xml:"all>element"`
ComplexContent XSDComplexContent `xml:"complexContent"`
SimpleContent XSDSimpleContent `xml:"simpleContent"`
Attributes []*XSDAttribute `xml:"attribute"`
}
// XSDGroup element is used to define a group of elements to be used in complex type definitions.
type XSDGroup struct {
Name string `xml:"name,attr"`
Ref string `xml:"ref,attr"`
Sequence []XSDElement `xml:"sequence>element"`
Choice []XSDElement `xml:"choice>element"`
All []XSDElement `xml:"all>element"`
}
// XSDComplexContent element defines extensions or restrictions on a complex
// type that contains mixed content or elements only.
type XSDComplexContent struct {
XMLName xml.Name `xml:"complexContent"`
Extension XSDExtension `xml:"extension"`
}
// XSDSimpleContent element contains extensions or restrictions on a text-only
// complex type or on a simple type as content and contains no elements.
type XSDSimpleContent struct {
XMLName xml.Name `xml:"simpleContent"`
Extension XSDExtension `xml:"extension"`
}
// XSDExtension element extends an existing simpleType or complexType element.
type XSDExtension struct {
XMLName xml.Name `xml:"extension"`
Base string `xml:"base,attr"`
Attributes []*XSDAttribute `xml:"attribute"`
Sequence []XSDElement `xml:"sequence>element"`
}
// XSDAttribute represent an element attribute. Simple elements cannot have
// attributes. If an element has attributes, it is considered to be of a
// complex type. But the attribute itself is always declared as a simple type.
type XSDAttribute struct {
Name string `xml:"name,attr"`
Doc string `xml:"annotation>documentation"`
Type string `xml:"type,attr"`
SimpleType *XSDSimpleType `xml:"simpleType"`
}
// XSDSimpleType element defines a simple type and specifies the constraints
// and information about the values of attributes or text-only elements.
type XSDSimpleType struct {
Name string `xml:"name,attr"`
Doc string `xml:"annotation>documentation"`
Restriction XSDRestriction `xml:"restriction"`
}
// XSDRestriction defines restrictions on a simpleType, simpleContent, or complexContent definition.
type XSDRestriction struct {
Base string `xml:"base,attr"`
Enumeration []XSDRestrictionValue `xml:"enumeration"`
Pattern XSDRestrictionValue `xml:"pattern"`
MinInclusive XSDRestrictionValue `xml:"minInclusive"`
MaxInclusive XSDRestrictionValue `xml:"maxInclusive"`
WhiteSpace XSDRestrictionValue `xml:"whitespace"`
Length XSDRestrictionValue `xml:"length"`
MinLength XSDRestrictionValue `xml:"minLength"`
MaxLength XSDRestrictionValue `xml:"maxLength"`
}
// XSDRestrictionValue represents a restriction value.
type XSDRestrictionValue struct {
Doc string `xml:"annotation>documentation"`
Value string `xml:"value,attr"`
}