├── LICENSE.md
├── README.md
├── elem.go
├── elemmakepkg.go
├── elemparents.go
├── hasattr.go
├── haselem.go
├── hasmakepkg.go
├── hasparents.go
├── makepkg.go
├── types
├── README.md
├── doc.go
└── xsdtypes.go
├── xsd-makepkg
├── main.go
└── tests
│ ├── README.md
│ ├── doc.go
│ ├── tests.go
│ ├── xsd-test-atom
│ ├── feed
│ │ ├── infiles
│ │ │ └── samplefeed.xml
│ │ └── outfiles
│ │ │ └── samplefeed.xml
│ └── main.go
│ ├── xsd-test-collada
│ ├── 1.4.1
│ │ ├── infiles
│ │ │ ├── berlin.dae
│ │ │ ├── cube.dae
│ │ │ ├── cube_triangulate.dae
│ │ │ ├── duck.dae
│ │ │ ├── duck_triangulate.dae
│ │ │ └── mgmidget.dae
│ │ └── outfiles
│ │ │ ├── berlin.dae
│ │ │ ├── cube.dae
│ │ │ ├── cube_triangulate.dae
│ │ │ ├── duck.dae
│ │ │ ├── duck_triangulate.dae
│ │ │ └── mgmidget.dae
│ ├── 1.5
│ │ ├── infiles
│ │ │ ├── berlin.dae
│ │ │ ├── cube.dae
│ │ │ ├── cube_triangulate.dae
│ │ │ ├── duck.dae
│ │ │ ├── duck_triangulate.dae
│ │ │ └── mgmidget.dae
│ │ └── outfiles
│ │ │ ├── berlin.dae
│ │ │ ├── cube.dae
│ │ │ ├── cube_triangulate.dae
│ │ │ ├── duck.dae
│ │ │ ├── duck_triangulate.dae
│ │ │ └── mgmidget.dae
│ └── main.go
│ ├── xsd-test-kml
│ ├── infiles
│ │ └── doc.kml
│ ├── main.go
│ └── outfiles
│ │ └── doc.kml
│ ├── xsd-test-rss
│ ├── infiles
│ │ └── go-ngine-blog.rss
│ ├── main.go
│ └── outfiles
│ │ └── go-ngine-blog.rss
│ └── xsd-test-svg
│ └── main.go
└── xsd-schema.go
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Phil Schumann
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | go-xsd
2 | ======
3 |
4 |
5 | A Go package for loading ( **xml.Unmarshal()**-ing ) an XML Schema Definition (XSD) document into an **xsd.Schema** structure.
6 |
7 | With this, you could probably write an XML validator, or otherwise utilize or further process the loaded XSD --- but the main use-case here was:
8 |
9 |
10 | go-xsd/xsd-makepkg
11 | ==================
12 |
13 |
14 | A command-line tool to generate Go "XML wrapper" package sources for specified XSD schema URIs.
15 |
16 | If no arguments are specified, this tool proceeds to (re)generate all Go packages for various common XML formats in your local $GOPATH-relative directory corresponding to the **http://github.com/metaleap/go-xsd-pkg** repository. For more details on command-line arguments for *xsd-makepkg*: scroll down to the bottom of this readme.
17 |
18 | Each generated wrapper package contains the type structures required to easily **xml.Unmarshal()** an XML document based on that XSD.
19 |
20 | **XSD simple-types** are represented by the corresponding native Go scalar data type, augmented by utility methods where applicable:
21 |
22 | - enumerated simple-types (eg. "value can be 'sunny', 'cloudy', 'rainy'") get handy corresponding **IsXyz() bool** methods (eg. "IsSunny()", "IsCloudy()", "IsRainy()")
23 |
24 | - simple-types that define a whitespace-separated list of scalar values get a corresponding, properly typed **Values()** method
25 |
26 | - for attributes or elements that define a fixed or default value, their corresponding generated Go simple-type will have a properly typed *ElemnameDefault()* / *ElemnameFixed()* / *AttnameDefault()* / *AttnameFixed()* method (eg. if the *langpref* attribute is defined to default to "Go", then its simple-type will have a *LangprefDefault()* method returning "Go")
27 |
28 | **XSD complex-types**, attribute-groups, element-groups, elements etc. are ultimately represented by corresponding generated Go struct types.
29 |
30 | **XSD includes** are all loaded and processed together into a single output .go source file.
31 |
32 | **XSD imports** are rewritten as Go imports but not otherwise auto-magically processed. If you see the generated .go package importing another "some-xsd-xml-whatever-name-_go" package that will cause a "package not found" compiler error, then to make that import work, you'll first need to also auto-generate that package with *xsd-makepkg* yourself as well.
33 |
34 | **XSD documentation annotation** is rewritten as Go // code comments. Yeah, that's rather neat.
35 |
36 | Regarding the auto-generated code:
37 |
38 | - it's **by necessity not idiomatic** and most likely not as terse/slim as manually-written structs would be. For very simplistic XML formats, writing your own 3 or 4 custom structs might be a tiny bit more efficient. **For highly intricate, unwieldy XML formats, the auto-generated packages beat hand-writing 100s of custom structs, however.** Auto-generated code will never win a code-beauty contest, you're expected to simply import the compiled package rather than having to work inside its generated source files.
39 |
40 | - most (XSD-declared) types are prefixed with T -- thanks to the SVG schema which taught me that in XSD, "scriptType" and "ScriptType" are two valid and uniquely different type names. To have all types exported from the generated Go package, then, some kind of prefix is indeed needed.
41 |
42 | - most XSDs are chock-full of anonymous types, as well as implicit ones (unions, restrictions, extensions...) Go does support "anonymous types" per se, but I decided against using them. Every type is declared and exported, no anonymous magic. This makes most auto-generated packages "look" even more confusing than their XSD counterparts at first glance. Indeed they may appear quite bloated, and when coding with the imported generated package you'll probably be better off working with the particular XML format's specification document rather than the **godoc** for the generated package... this is not a perfect situation but at least for now I can work with this for the few XML formats I occasionally need to "parse, convert and forget" -- ultimately, most XML formats at my end are mere interchange or legacy formats, and never really the "main topic" at hand.
43 |
44 |
45 | go-xsd/types
46 | ============
47 |
48 |
49 | A tiny package automatically imported by all **go-xsd** auto-generated packages.
50 | Maps all XSD built-in simple-types to Go types, which affords us easy mapping of any XSD type references in the schema to Go imports: every *xs:string* and *xs:boolean* automatically becomes *xsdt.String* and *xsdt.Boolean* etc.
51 | Types are mapped to Go types depending on how **encoding/xml.Unmarshal()** can handle them: ie. it parses bools and numbers, but dates/durations have too many format mismatches and thus are just declared string types.
52 | Same for base64- and hex-encoded binary data: since **Unmarshal()** won't decode them, we leave them as strings. If you need their binary data, your code needs to import Go's base64/hex codec packages and use them as necessary.
53 |
54 |
55 | How to use auto-generated packages:
56 | ===================================
57 |
58 |
59 | Take a look at the "test progs" under **xsd-makepkg/tests**, they're basically simple usage examples. For unmarshal you need to define just one small custom struct like this --- using the rss package as a simple example, as demonstrated in **xsd-makepkg/tests/xsd-test-rss/main.go**:
60 |
61 |
62 | type MyRssDoc struct {
63 | XMLName xml.Name `xml:"rss"`
64 | rss.TxsdRss
65 | }
66 |
67 |
68 | So your custom struct specifies two things:
69 |
70 | - the XML name of the root element in your XML file, as is typical when working with **encoding/xml.Unmarshal()**.
71 |
72 | - the Go struct type from the auto-generated package to **embed right inside** your custom struct.
73 |
74 | The second part is the only tricky part. XML Schema Definition has no real concept of "root element", partly because they're designed to support use-cases where you embed a full document defined in one XSD deep inside a full document defined in another XSD. So a Collada document may contain a full or partial MathML document somewhere inside it. Some well-designed XSDs define a single top-level element, so we could infer "this is the root element" and generate a "XyzDoc" struct (like the *MyRssDoc* above) for you. But many don't. Some formats may legally have one of two or more possible "root" elements, ie. Atom allegedly may have either a "feed" root element or an "entry" root element. So **go-xsd** does not magically infer which of the XSD's top-level elements might be the root element, you define this by writing a small struct as shown above. The naming of the root element Go type to be embedded is not consistent across different packages, because their naming is directly based on the XSD that was used to generate the package. So for example...
75 |
76 | - for rss we have *rss.TxsdRss*
77 | - for atom: *atom.TentryType* and *atom.TfeedType*
78 | - for svg: *svg.TsvgType*
79 | - for Collada: *collada.TxsdCollada*
80 |
81 | Seems like Collada and RSS share a certain naming pattern, and yet Atom/SVG share another one? Mere coincidence, the naming is completely arbitrary and up to the XSD author. Ultimately, to find out the proper Go type name to embed, you'll have to dig a bit inside the generated package. That's actually pretty straightforward, here's how you do it:
82 |
83 | A) Suppose you have an XML format where the root element (and only that one) is known to be named:
84 |
85 |
86 |
87 |
88 |
89 | B) Open the generated Go package source files under **$GOPATH/src/github.com/metaleap/go-xsd-pkg/yourdomain.org/xsd/gopher.xsd_go/*.go** (unless you used custom paths when you ran the **go-xsd/xsd-makepkg** tool)
90 |
91 | C) Search for an occurence of either:
92 |
93 |
94 | "gopher"`
95 |
96 |
97 | ( quote, gopher, quote, backtick ), or:
98 |
99 |
100 | gopher"`
101 |
102 |
103 | ( *whitespace*, gopher, quote, backtick )
104 |
105 | D) The found occurence is likely the tag for a field in a type named something like **XsdGoPkgHasElem_Gopher** or **XsdGoPkgHasElems_Gopher**. Ignore that type, instead focus on the type of the field itself. That's the one you're looking for, the one to embed in your tiny custom doc struct.
106 |
107 |
108 | Command-line flags for *go-xsd/xsd-makepkg* tool:
109 | =================================================
110 |
111 |
112 | - **-basepath=""**: Defaults to github.com/metaleap/go-xsd-pkg. A $GOPATH/src/-relative path (always a slash-style path, even on Windows) where XSD files are downloaded to / loaded from and generated Go wrapper packages are created. Any XSD imports are also rewritten as Go imports from that path (but are not otherwise auto-magically processed in any way).
113 | - **-local=true**: Local copy -- only downloads if file does not exist locally
114 | - **-parse=false**: Not necessary, unless the generated Go wrapper package fails to compile with either the error "*cannot convert {value} to type {type}*" or "*cannot use {value} (type {type}) as type {type} in return argument*" -- ultimately down to a slightly faulty XSD file, but while rare, those exist (hello, KML using 0 and 1 for *xs:boolean*s that are clearly spec'd to be only ever either *true* or *false*...)
115 | - **-uri=""**: The XML Schema Definition file URIs to generate a Go wrapper packages from, whitespace-separated. (For each, the protocol prefix can be omitted, it then defaults to *http://*. Only protocols understood by the *net/http* package are supported.)
116 | - **-gofmt=true**: Run 'gofmt' against the generated Go wrapper package?
117 | - **-goinst=true**: Run 'go-buildrun' ( http://github.com/metaleap/go-buildrun ) against the generated Go wrapper package?
118 |
--------------------------------------------------------------------------------
/elem.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | import (
4 | xsdt "github.com/metaleap/go-xsd/types"
5 | )
6 |
7 | type element interface {
8 | base() *elemBase
9 | init(parent, self element, xsdName xsdt.NCName, atts ...beforeAfterMake)
10 | Parent() element
11 | }
12 |
13 | type elemBase struct {
14 | atts []beforeAfterMake
15 | parent, self element // self is the struct that embeds elemBase, rather than the elemBase pseudo-field
16 | xsdName xsdt.NCName
17 | hasNameAttr bool
18 | }
19 |
20 | func (me *elemBase) afterMakePkg(bag *PkgBag) {
21 | if !me.hasNameAttr {
22 | bag.Stacks.Name.Pop()
23 | }
24 | for _, a := range me.atts {
25 | a.afterMakePkg(bag)
26 | }
27 | }
28 |
29 | func (me *elemBase) beforeMakePkg(bag *PkgBag) {
30 | if !me.hasNameAttr {
31 | bag.Stacks.Name.Push(me.xsdName)
32 | }
33 | for _, a := range me.atts {
34 | a.beforeMakePkg(bag)
35 | }
36 | }
37 |
38 | func (me *elemBase) base() *elemBase { return me }
39 |
40 | func (me *elemBase) init(parent, self element, xsdName xsdt.NCName, atts ...beforeAfterMake) {
41 | me.parent, me.self, me.xsdName, me.atts = parent, self, xsdName, atts
42 | for _, a := range atts {
43 | if _, me.hasNameAttr = a.(*hasAttrName); me.hasNameAttr {
44 | break
45 | }
46 | }
47 | }
48 |
49 | func (me *elemBase) longSafeName(bag *PkgBag) (ln string) {
50 | var els = []element{}
51 | for el := me.self; (el != nil) && (el != bag.Schema); el = el.Parent() {
52 | els = append(els, el)
53 | }
54 | for i := len(els) - 1; i >= 0; i-- {
55 | ln += bag.safeName(els[i].base().selfName().String())
56 | }
57 | return
58 | }
59 |
60 | func (me *elemBase) selfName() xsdt.NCName {
61 | if me.hasNameAttr {
62 | for _, at := range me.atts {
63 | if an, ok := at.(*hasAttrName); ok {
64 | return an.Name
65 | }
66 | }
67 | }
68 | return me.xsdName
69 | }
70 |
71 | func (me *elemBase) Parent() element { return me.parent }
72 |
73 | type All struct {
74 | elemBase
75 | // XMLName xml.Name `xml:"all"`
76 | hasAttrId
77 | hasAttrMaxOccurs
78 | hasAttrMinOccurs
79 | hasElemAnnotation
80 | hasElemsElement
81 | }
82 |
83 | type Annotation struct {
84 | elemBase
85 | // XMLName xml.Name `xml:"annotation"`
86 | hasElemsAppInfo
87 | hasElemsDocumentation
88 | }
89 |
90 | type Any struct {
91 | elemBase
92 | // XMLName xml.Name `xml:"any"`
93 | hasAttrId
94 | hasAttrMaxOccurs
95 | hasAttrMinOccurs
96 | hasAttrNamespace
97 | hasAttrProcessContents
98 | hasElemAnnotation
99 | }
100 |
101 | type AnyAttribute struct {
102 | elemBase
103 | // XMLName xml.Name `xml:"anyAttribute"`
104 | hasAttrId
105 | hasAttrNamespace
106 | hasAttrProcessContents
107 | hasElemAnnotation
108 | }
109 |
110 | type AppInfo struct {
111 | elemBase
112 | // XMLName xml.Name `xml:"appinfo"`
113 | hasAttrSource
114 | hasCdata
115 | }
116 |
117 | type Attribute struct {
118 | elemBase
119 | // XMLName xml.Name `xml:"attribute"`
120 | hasAttrDefault
121 | hasAttrFixed
122 | hasAttrForm
123 | hasAttrId
124 | hasAttrName
125 | hasAttrRef
126 | hasAttrType
127 | hasAttrUse
128 | hasElemAnnotation
129 | hasElemsSimpleType
130 | }
131 |
132 | type AttributeGroup struct {
133 | elemBase
134 | // XMLName xml.Name `xml:"attributeGroup"`
135 | hasAttrId
136 | hasAttrName
137 | hasAttrRef
138 | hasElemAnnotation
139 | hasElemsAnyAttribute
140 | hasElemsAttribute
141 | hasElemsAttributeGroup
142 | }
143 |
144 | type Choice struct {
145 | elemBase
146 | // XMLName xml.Name `xml:"choice"`
147 | hasAttrId
148 | hasAttrMaxOccurs
149 | hasAttrMinOccurs
150 | hasElemAnnotation
151 | hasElemsAny
152 | hasElemsChoice
153 | hasElemsElement
154 | hasElemsGroup
155 | hasElemsSequence
156 | }
157 |
158 | type ComplexContent struct {
159 | elemBase
160 | // XMLName xml.Name `xml:"complexContent"`
161 | hasAttrId
162 | hasAttrMixed
163 | hasElemAnnotation
164 | hasElemExtensionComplexContent
165 | hasElemRestrictionComplexContent
166 | }
167 |
168 | type ComplexType struct {
169 | elemBase
170 | // XMLName xml.Name `xml:"complexType"`
171 | hasAttrAbstract
172 | hasAttrBlock
173 | hasAttrFinal
174 | hasAttrId
175 | hasAttrMixed
176 | hasAttrName
177 | hasElemAll
178 | hasElemAnnotation
179 | hasElemsAnyAttribute
180 | hasElemsAttribute
181 | hasElemsAttributeGroup
182 | hasElemChoice
183 | hasElemComplexContent
184 | hasElemGroup
185 | hasElemSequence
186 | hasElemSimpleContent
187 | }
188 |
189 | type Documentation struct {
190 | elemBase
191 | // XMLName xml.Name `xml:"documentation"`
192 | hasAttrLang
193 | hasAttrSource
194 | hasCdata
195 | }
196 |
197 | type Element struct {
198 | elemBase
199 | // XMLName xml.Name `xml:"element"`
200 | hasAttrAbstract
201 | hasAttrBlock
202 | hasAttrDefault
203 | hasAttrFinal
204 | hasAttrFixed
205 | hasAttrForm
206 | hasAttrId
207 | hasAttrMaxOccurs
208 | hasAttrMinOccurs
209 | hasAttrName
210 | hasAttrNillable
211 | hasAttrRef
212 | hasAttrSubstitutionGroup
213 | hasAttrType
214 | hasElemAnnotation
215 | hasElemComplexType
216 | hasElemsKey
217 | hasElemKeyRef
218 | hasElemsSimpleType
219 | hasElemUnique
220 | }
221 |
222 | type ExtensionComplexContent struct {
223 | elemBase
224 | // XMLName xml.Name `xml:"extension"`
225 | hasAttrBase
226 | hasAttrId
227 | hasElemAll
228 | hasElemAnnotation
229 | hasElemsAnyAttribute
230 | hasElemsAttribute
231 | hasElemsAttributeGroup
232 | hasElemsChoice
233 | hasElemsGroup
234 | hasElemsSequence
235 | }
236 |
237 | type ExtensionSimpleContent struct {
238 | elemBase
239 | // XMLName xml.Name `xml:"extension"`
240 | hasAttrBase
241 | hasAttrId
242 | hasElemAnnotation
243 | hasElemsAnyAttribute
244 | hasElemsAttribute
245 | hasElemsAttributeGroup
246 | }
247 |
248 | type Field struct {
249 | elemBase
250 | // XMLName xml.Name `xml:"field"`
251 | hasAttrId
252 | hasAttrXpath
253 | hasElemAnnotation
254 | }
255 |
256 | type Group struct {
257 | elemBase
258 | // XMLName xml.Name `xml:"group"`
259 | hasAttrId
260 | hasAttrMaxOccurs
261 | hasAttrMinOccurs
262 | hasAttrName
263 | hasAttrRef
264 | hasElemAll
265 | hasElemAnnotation
266 | hasElemChoice
267 | hasElemSequence
268 | }
269 |
270 | type Include struct {
271 | elemBase
272 | // XMLName xml.Name `xml:"include"`
273 | hasAttrId
274 | hasAttrSchemaLocation
275 | hasElemAnnotation
276 | }
277 |
278 | type Import struct {
279 | elemBase
280 | // XMLName xml.Name `xml:"import"`
281 | hasAttrId
282 | hasAttrNamespace
283 | hasAttrSchemaLocation
284 | hasElemAnnotation
285 | }
286 |
287 | type Key struct {
288 | elemBase
289 | // XMLName xml.Name `xml:"key"`
290 | hasAttrId
291 | hasAttrName
292 | hasElemAnnotation
293 | hasElemField
294 | hasElemSelector
295 | }
296 |
297 | type KeyRef struct {
298 | elemBase
299 | // XMLName xml.Name `xml:"keyref"`
300 | hasAttrId
301 | hasAttrName
302 | hasAttrRefer
303 | hasElemAnnotation
304 | hasElemField
305 | hasElemSelector
306 | }
307 |
308 | type List struct {
309 | elemBase
310 | // XMLName xml.Name `xml:"list"`
311 | hasAttrId
312 | hasAttrItemType
313 | hasElemAnnotation
314 | hasElemsSimpleType
315 | }
316 |
317 | type Notation struct {
318 | elemBase
319 | // XMLName xml.Name `xml:"notation"`
320 | hasAttrId
321 | hasAttrName
322 | hasAttrPublic
323 | hasAttrSystem
324 | hasElemAnnotation
325 | }
326 |
327 | type Redefine struct {
328 | elemBase
329 | // XMLName xml.Name `xml:"redefine"`
330 | hasAttrId
331 | hasAttrSchemaLocation
332 | hasElemAnnotation
333 | hasElemsAttributeGroup
334 | hasElemsComplexType
335 | hasElemsGroup
336 | hasElemsSimpleType
337 | }
338 |
339 | type RestrictionComplexContent struct {
340 | elemBase
341 | // XMLName xml.Name `xml:"restriction"`
342 | hasAttrBase
343 | hasAttrId
344 | hasElemAll
345 | hasElemAnnotation
346 | hasElemsAnyAttribute
347 | hasElemsAttribute
348 | hasElemsAttributeGroup
349 | hasElemsChoice
350 | hasElemsSequence
351 | }
352 |
353 | type RestrictionSimpleContent struct {
354 | elemBase
355 | // XMLName xml.Name `xml:"restriction"`
356 | hasAttrBase
357 | hasAttrId
358 | hasElemAnnotation
359 | hasElemsAnyAttribute
360 | hasElemsAttribute
361 | hasElemsAttributeGroup
362 | hasElemsEnumeration
363 | hasElemFractionDigits
364 | hasElemLength
365 | hasElemMaxExclusive
366 | hasElemMaxInclusive
367 | hasElemMaxLength
368 | hasElemMinExclusive
369 | hasElemMinInclusive
370 | hasElemMinLength
371 | hasElemPattern
372 | hasElemsSimpleType
373 | hasElemTotalDigits
374 | hasElemWhiteSpace
375 | }
376 |
377 | type RestrictionSimpleEnumeration struct {
378 | elemBase
379 | // XMLName xml.Name `xml:"enumeration"`
380 | hasAttrValue
381 | }
382 |
383 | type RestrictionSimpleFractionDigits struct {
384 | elemBase
385 | // XMLName xml.Name `xml:"fractionDigits"`
386 | hasAttrValue
387 | }
388 |
389 | type RestrictionSimpleLength struct {
390 | elemBase
391 | // XMLName xml.Name `xml:"length"`
392 | hasAttrValue
393 | }
394 |
395 | type RestrictionSimpleMaxExclusive struct {
396 | elemBase
397 | // XMLName xml.Name `xml:"maxExclusive"`
398 | hasAttrValue
399 | }
400 |
401 | type RestrictionSimpleMaxInclusive struct {
402 | elemBase
403 | // XMLName xml.Name `xml:"maxInclusive"`
404 | hasAttrValue
405 | }
406 |
407 | type RestrictionSimpleMaxLength struct {
408 | elemBase
409 | // XMLName xml.Name `xml:"maxLength"`
410 | hasAttrValue
411 | }
412 |
413 | type RestrictionSimpleMinExclusive struct {
414 | elemBase
415 | // XMLName xml.Name `xml:"minExclusive"`
416 | hasAttrValue
417 | }
418 |
419 | type RestrictionSimpleMinInclusive struct {
420 | elemBase
421 | // XMLName xml.Name `xml:"minInclusive"`
422 | hasAttrValue
423 | }
424 |
425 | type RestrictionSimpleMinLength struct {
426 | elemBase
427 | // XMLName xml.Name `xml:"minLength"`
428 | hasAttrValue
429 | }
430 |
431 | type RestrictionSimplePattern struct {
432 | elemBase
433 | // XMLName xml.Name `xml:"pattern"`
434 | hasAttrValue
435 | }
436 |
437 | type RestrictionSimpleTotalDigits struct {
438 | elemBase
439 | // XMLName xml.Name `xml:"totalDigits"`
440 | hasAttrValue
441 | }
442 |
443 | type RestrictionSimpleType struct {
444 | elemBase
445 | // XMLName xml.Name `xml:"restriction"`
446 | hasAttrBase
447 | hasAttrId
448 | hasElemAnnotation
449 | hasElemsEnumeration
450 | hasElemFractionDigits
451 | hasElemLength
452 | hasElemMaxExclusive
453 | hasElemMaxInclusive
454 | hasElemMaxLength
455 | hasElemMinExclusive
456 | hasElemMinInclusive
457 | hasElemMinLength
458 | hasElemPattern
459 | hasElemsSimpleType
460 | hasElemTotalDigits
461 | hasElemWhiteSpace
462 | }
463 |
464 | type RestrictionSimpleWhiteSpace struct {
465 | elemBase
466 | // XMLName xml.Name `xml:"whiteSpace"`
467 | hasAttrValue
468 | }
469 |
470 | type Selector struct {
471 | elemBase
472 | // XMLName xml.Name `xml:"selector"`
473 | hasAttrId
474 | hasAttrXpath
475 | hasElemAnnotation
476 | }
477 |
478 | type Sequence struct {
479 | elemBase
480 | // XMLName xml.Name `xml:"sequence"`
481 | hasAttrId
482 | hasAttrMaxOccurs
483 | hasAttrMinOccurs
484 | hasElemAnnotation
485 | hasElemsAny
486 | hasElemsChoice
487 | hasElemsElement
488 | hasElemsGroup
489 | hasElemsSequence
490 | }
491 |
492 | type SimpleContent struct {
493 | elemBase
494 | // XMLName xml.Name `xml:"simpleContent"`
495 | hasAttrId
496 | hasElemAnnotation
497 | hasElemExtensionSimpleContent
498 | hasElemRestrictionSimpleContent
499 | }
500 |
501 | type SimpleType struct {
502 | elemBase
503 | // XMLName xml.Name `xml:"simpleType"`
504 | hasAttrFinal
505 | hasAttrId
506 | hasAttrName
507 | hasElemAnnotation
508 | hasElemList
509 | hasElemRestrictionSimpleType
510 | hasElemUnion
511 | }
512 |
513 | type Union struct {
514 | elemBase
515 | // XMLName xml.Name `xml:"union"`
516 | hasAttrId
517 | hasAttrMemberTypes
518 | hasElemAnnotation
519 | hasElemsSimpleType
520 | }
521 |
522 | type Unique struct {
523 | elemBase
524 | // XMLName xml.Name `xml:"unique"`
525 | hasAttrId
526 | hasAttrName
527 | hasElemAnnotation
528 | hasElemField
529 | hasElemSelector
530 | }
531 |
532 | func Flattened(choices []*Choice, seqs []*Sequence) (allChoices []*Choice, allSeqs []*Sequence) {
533 | var tmpChoices []*Choice
534 | var tmpSeqs []*Sequence
535 | for _, ch := range choices {
536 | if ch != nil {
537 | allChoices = append(allChoices, ch)
538 | tmpChoices, tmpSeqs = Flattened(ch.Choices, ch.Sequences)
539 | allChoices = append(allChoices, tmpChoices...)
540 | allSeqs = append(allSeqs, tmpSeqs...)
541 | }
542 | }
543 | for _, seq := range seqs {
544 | if seq != nil {
545 | allSeqs = append(allSeqs, seq)
546 | tmpChoices, tmpSeqs = Flattened(seq.Choices, seq.Sequences)
547 | allChoices = append(allChoices, tmpChoices...)
548 | allSeqs = append(allSeqs, tmpSeqs...)
549 | }
550 | }
551 | return
552 | }
553 |
--------------------------------------------------------------------------------
/elemparents.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | func (me *All) initElement(parent element) {
4 | me.elemBase.init(parent, me, "all", &me.hasAttrId, &me.hasAttrMaxOccurs, &me.hasAttrMinOccurs)
5 | me.hasElemAnnotation.initChildren(me)
6 | me.hasElemsElement.initChildren(me)
7 | }
8 |
9 | func (me *Annotation) initElement(parent element) {
10 | me.elemBase.init(parent, me, "annotation")
11 | me.hasElemsAppInfo.initChildren(me)
12 | me.hasElemsDocumentation.initChildren(me)
13 | }
14 |
15 | func (me *Any) initElement(parent element) {
16 | me.elemBase.init(parent, me, "any", &me.hasAttrId, &me.hasAttrNamespace, &me.hasAttrMaxOccurs, &me.hasAttrMinOccurs, &me.hasAttrProcessContents)
17 | me.hasElemAnnotation.initChildren(me)
18 | }
19 |
20 | func (me *AnyAttribute) initElement(parent element) {
21 | me.elemBase.init(parent, me, "anyAttribute", &me.hasAttrId, &me.hasAttrNamespace, &me.hasAttrProcessContents)
22 | me.hasElemAnnotation.initChildren(me)
23 | }
24 |
25 | func (me *AppInfo) initElement(parent element) {
26 | me.elemBase.init(parent, me, "appInfo", &me.hasAttrSource)
27 | }
28 |
29 | func (me *Attribute) initElement(parent element) {
30 | me.elemBase.init(parent, me, "attribute", &me.hasAttrDefault, &me.hasAttrFixed, &me.hasAttrForm, &me.hasAttrId, &me.hasAttrName, &me.hasAttrRef, &me.hasAttrType, &me.hasAttrUse)
31 | me.hasElemAnnotation.initChildren(me)
32 | me.hasElemsSimpleType.initChildren(me)
33 | }
34 |
35 | func (me *AttributeGroup) initElement(parent element) {
36 | me.elemBase.init(parent, me, "attributeGroup", &me.hasAttrId, &me.hasAttrName, &me.hasAttrRef)
37 | me.hasElemAnnotation.initChildren(me)
38 | me.hasElemsAttribute.initChildren(me)
39 | me.hasElemsAnyAttribute.initChildren(me)
40 | me.hasElemsAttributeGroup.initChildren(me)
41 | }
42 |
43 | func (me *Choice) initElement(parent element) {
44 | me.elemBase.init(parent, me, "choice", &me.hasAttrId, &me.hasAttrMaxOccurs, &me.hasAttrMinOccurs)
45 | me.hasElemAnnotation.initChildren(me)
46 | me.hasElemsAny.initChildren(me)
47 | me.hasElemsChoice.initChildren(me)
48 | me.hasElemsElement.initChildren(me)
49 | me.hasElemsGroup.initChildren(me)
50 | me.hasElemsSequence.initChildren(me)
51 | }
52 |
53 | func (me *ComplexContent) initElement(parent element) {
54 | me.elemBase.init(parent, me, "complexContent", &me.hasAttrId, &me.hasAttrMixed)
55 | me.hasElemAnnotation.initChildren(me)
56 | me.hasElemExtensionComplexContent.initChildren(me)
57 | me.hasElemRestrictionComplexContent.initChildren(me)
58 | }
59 |
60 | func (me *ComplexType) initElement(parent element) {
61 | me.elemBase.init(parent, me, "complexType", &me.hasAttrAbstract, &me.hasAttrBlock, &me.hasAttrFinal, &me.hasAttrId, &me.hasAttrMixed, &me.hasAttrName)
62 | me.hasElemAnnotation.initChildren(me)
63 | me.hasElemAll.initChildren(me)
64 | me.hasElemChoice.initChildren(me)
65 | me.hasElemsAttribute.initChildren(me)
66 | me.hasElemGroup.initChildren(me)
67 | me.hasElemSequence.initChildren(me)
68 | me.hasElemComplexContent.initChildren(me)
69 | me.hasElemSimpleContent.initChildren(me)
70 | me.hasElemsAnyAttribute.initChildren(me)
71 | me.hasElemsAttributeGroup.initChildren(me)
72 | }
73 |
74 | func (me *Documentation) initElement(parent element) {
75 | me.elemBase.init(parent, me, "documentation", &me.hasAttrLang, &me.hasAttrSource)
76 | }
77 |
78 | func (me *Element) initElement(parent element) {
79 | me.elemBase.init(parent, me, "element", &me.hasAttrAbstract, &me.hasAttrBlock, &me.hasAttrDefault, &me.hasAttrFinal, &me.hasAttrFixed, &me.hasAttrForm, &me.hasAttrId, &me.hasAttrName, &me.hasAttrNillable, &me.hasAttrRef, &me.hasAttrType, &me.hasAttrMaxOccurs, &me.hasAttrMinOccurs, &me.hasAttrSubstitutionGroup)
80 | me.hasElemAnnotation.initChildren(me)
81 | me.hasElemUnique.initChildren(me)
82 | me.hasElemsKey.initChildren(me)
83 | me.hasElemComplexType.initChildren(me)
84 | me.hasElemKeyRef.initChildren(me)
85 | me.hasElemsSimpleType.initChildren(me)
86 | }
87 |
88 | func (me *ExtensionComplexContent) initElement(parent element) {
89 | me.elemBase.init(parent, me, "extension", &me.hasAttrBase, &me.hasAttrId)
90 | me.hasElemAnnotation.initChildren(me)
91 | me.hasElemAll.initChildren(me)
92 | me.hasElemsAttribute.initChildren(me)
93 | me.hasElemsChoice.initChildren(me)
94 | me.hasElemsGroup.initChildren(me)
95 | me.hasElemsSequence.initChildren(me)
96 | me.hasElemsAnyAttribute.initChildren(me)
97 | me.hasElemsAttributeGroup.initChildren(me)
98 | }
99 |
100 | func (me *ExtensionSimpleContent) initElement(parent element) {
101 | me.elemBase.init(parent, me, "extension", &me.hasAttrBase, &me.hasAttrId)
102 | me.hasElemAnnotation.initChildren(me)
103 | me.hasElemsAttribute.initChildren(me)
104 | me.hasElemsAnyAttribute.initChildren(me)
105 | me.hasElemsAttributeGroup.initChildren(me)
106 | }
107 |
108 | func (me *Field) initElement(parent element) {
109 | me.elemBase.init(parent, me, "field", &me.hasAttrId, &me.hasAttrXpath)
110 | me.hasElemAnnotation.initChildren(me)
111 | }
112 |
113 | func (me *Group) initElement(parent element) {
114 | me.elemBase.init(parent, me, "group", &me.hasAttrId, &me.hasAttrName, &me.hasAttrRef, &me.hasAttrMaxOccurs, &me.hasAttrMinOccurs)
115 | me.hasElemAnnotation.initChildren(me)
116 | me.hasElemAll.initChildren(me)
117 | me.hasElemChoice.initChildren(me)
118 | me.hasElemSequence.initChildren(me)
119 | }
120 |
121 | func (me *Import) initElement(parent element) {
122 | me.elemBase.init(parent, me, "import", &me.hasAttrId, &me.hasAttrNamespace, &me.hasAttrSchemaLocation)
123 | me.hasElemAnnotation.initChildren(me)
124 | }
125 |
126 | func (me *Key) initElement(parent element) {
127 | me.elemBase.init(parent, me, "key", &me.hasAttrId, &me.hasAttrName)
128 | me.hasElemAnnotation.initChildren(me)
129 | me.hasElemField.initChildren(me)
130 | me.hasElemSelector.initChildren(me)
131 | }
132 |
133 | func (me *KeyRef) initElement(parent element) {
134 | me.elemBase.init(parent, me, "keyref", &me.hasAttrId, &me.hasAttrName, &me.hasAttrRefer)
135 | me.hasElemAnnotation.initChildren(me)
136 | me.hasElemField.initChildren(me)
137 | me.hasElemSelector.initChildren(me)
138 | }
139 |
140 | func (me *List) initElement(parent element) {
141 | me.elemBase.init(parent, me, "list", &me.hasAttrId, &me.hasAttrItemType)
142 | me.hasElemAnnotation.initChildren(me)
143 | me.hasElemsSimpleType.initChildren(me)
144 | }
145 |
146 | func (me *Notation) initElement(parent element) {
147 | me.elemBase.init(parent, me, "notation", &me.hasAttrId, &me.hasAttrName, &me.hasAttrPublic, &me.hasAttrSystem)
148 | me.hasElemAnnotation.initChildren(me)
149 | }
150 |
151 | func (me *Redefine) initElement(parent element) {
152 | me.elemBase.init(parent, me, "redefine", &me.hasAttrId, &me.hasAttrSchemaLocation)
153 | me.hasElemAnnotation.initChildren(me)
154 | me.hasElemsGroup.initChildren(me)
155 | me.hasElemsAttributeGroup.initChildren(me)
156 | me.hasElemsComplexType.initChildren(me)
157 | me.hasElemsSimpleType.initChildren(me)
158 | }
159 |
160 | func (me *RestrictionComplexContent) initElement(parent element) {
161 | me.elemBase.init(parent, me, "restriction", &me.hasAttrBase, &me.hasAttrId)
162 | me.hasElemAnnotation.initChildren(me)
163 | me.hasElemAll.initChildren(me)
164 | me.hasElemsAttribute.initChildren(me)
165 | me.hasElemsChoice.initChildren(me)
166 | me.hasElemsSequence.initChildren(me)
167 | me.hasElemsAnyAttribute.initChildren(me)
168 | me.hasElemsAttributeGroup.initChildren(me)
169 | }
170 |
171 | func (me *RestrictionSimpleContent) initElement(parent element) {
172 | me.elemBase.init(parent, me, "restriction", &me.hasAttrBase, &me.hasAttrId)
173 | me.hasElemAnnotation.initChildren(me)
174 | me.hasElemLength.initChildren(me)
175 | me.hasElemPattern.initChildren(me)
176 | me.hasElemsAttribute.initChildren(me)
177 | me.hasElemsEnumeration.initChildren(me)
178 | me.hasElemFractionDigits.initChildren(me)
179 | me.hasElemMaxExclusive.initChildren(me)
180 | me.hasElemMaxInclusive.initChildren(me)
181 | me.hasElemMaxLength.initChildren(me)
182 | me.hasElemMinExclusive.initChildren(me)
183 | me.hasElemMinInclusive.initChildren(me)
184 | me.hasElemMinLength.initChildren(me)
185 | me.hasElemTotalDigits.initChildren(me)
186 | me.hasElemWhiteSpace.initChildren(me)
187 | me.hasElemsAnyAttribute.initChildren(me)
188 | me.hasElemsAttributeGroup.initChildren(me)
189 | me.hasElemsSimpleType.initChildren(me)
190 | }
191 |
192 | func (me *RestrictionSimpleEnumeration) initElement(parent element) {
193 | me.elemBase.init(parent, me, "enumeration", &me.hasAttrValue)
194 | }
195 |
196 | func (me *RestrictionSimpleFractionDigits) initElement(parent element) {
197 | me.elemBase.init(parent, me, "fractionDigits", &me.hasAttrValue)
198 | }
199 |
200 | func (me *RestrictionSimpleLength) initElement(parent element) {
201 | me.elemBase.init(parent, me, "length", &me.hasAttrValue)
202 | }
203 |
204 | func (me *RestrictionSimpleMaxExclusive) initElement(parent element) {
205 | me.elemBase.init(parent, me, "maxExclusive", &me.hasAttrValue)
206 | }
207 |
208 | func (me *RestrictionSimpleMaxInclusive) initElement(parent element) {
209 | me.elemBase.init(parent, me, "maxInclusive", &me.hasAttrValue)
210 | }
211 |
212 | func (me *RestrictionSimpleMaxLength) initElement(parent element) {
213 | me.elemBase.init(parent, me, "maxLength", &me.hasAttrValue)
214 | }
215 |
216 | func (me *RestrictionSimpleMinExclusive) initElement(parent element) {
217 | me.elemBase.init(parent, me, "minExclusive", &me.hasAttrValue)
218 | }
219 |
220 | func (me *RestrictionSimpleMinInclusive) initElement(parent element) {
221 | me.elemBase.init(parent, me, "minInclusive", &me.hasAttrValue)
222 | }
223 |
224 | func (me *RestrictionSimpleMinLength) initElement(parent element) {
225 | me.elemBase.init(parent, me, "minLength", &me.hasAttrValue)
226 | }
227 |
228 | func (me *RestrictionSimplePattern) initElement(parent element) {
229 | me.elemBase.init(parent, me, "pattern", &me.hasAttrValue)
230 | }
231 |
232 | func (me *RestrictionSimpleTotalDigits) initElement(parent element) {
233 | me.elemBase.init(parent, me, "totalDigits", &me.hasAttrValue)
234 | }
235 |
236 | func (me *RestrictionSimpleType) initElement(parent element) {
237 | me.elemBase.init(parent, me, "restriction", &me.hasAttrBase, &me.hasAttrId)
238 | me.hasElemAnnotation.initChildren(me)
239 | me.hasElemLength.initChildren(me)
240 | me.hasElemPattern.initChildren(me)
241 | me.hasElemsEnumeration.initChildren(me)
242 | me.hasElemFractionDigits.initChildren(me)
243 | me.hasElemMaxExclusive.initChildren(me)
244 | me.hasElemMaxInclusive.initChildren(me)
245 | me.hasElemMaxLength.initChildren(me)
246 | me.hasElemMinExclusive.initChildren(me)
247 | me.hasElemMinInclusive.initChildren(me)
248 | me.hasElemMinLength.initChildren(me)
249 | me.hasElemTotalDigits.initChildren(me)
250 | me.hasElemWhiteSpace.initChildren(me)
251 | me.hasElemsSimpleType.initChildren(me)
252 | }
253 |
254 | func (me *RestrictionSimpleWhiteSpace) initElement(parent element) {
255 | me.elemBase.init(parent, me, "whiteSpace", &me.hasAttrValue)
256 | }
257 |
258 | func (me *Schema) initElement(parent element) {
259 | me.elemBase.init(parent, me, "schema", &me.hasAttrId, &me.hasAttrLang, &me.hasAttrVersion, &me.hasAttrBlockDefault, &me.hasAttrFinalDefault, &me.hasAttrSchemaLocation, &me.hasAttrTargetNamespace, &me.hasAttrAttributeFormDefault, &me.hasAttrElementFormDefault)
260 | me.hasElemAnnotation.initChildren(me)
261 | me.hasElemsAttribute.initChildren(me)
262 | me.hasElemsElement.initChildren(me)
263 | me.hasElemsGroup.initChildren(me)
264 | me.hasElemsImport.initChildren(me)
265 | me.hasElemsNotation.initChildren(me)
266 | me.hasElemsRedefine.initChildren(me)
267 | me.hasElemsAttributeGroup.initChildren(me)
268 | me.hasElemsComplexType.initChildren(me)
269 | me.hasElemsSimpleType.initChildren(me)
270 | }
271 |
272 | func (me *Selector) initElement(parent element) {
273 | me.elemBase.init(parent, me, "selector", &me.hasAttrId, &me.hasAttrXpath)
274 | me.hasElemAnnotation.initChildren(me)
275 | }
276 |
277 | func (me *Sequence) initElement(parent element) {
278 | me.elemBase.init(parent, me, "sequence", &me.hasAttrId, &me.hasAttrMaxOccurs, &me.hasAttrMinOccurs)
279 | me.hasElemAnnotation.initChildren(me)
280 | me.hasElemsAny.initChildren(me)
281 | me.hasElemsChoice.initChildren(me)
282 | me.hasElemsElement.initChildren(me)
283 | me.hasElemsGroup.initChildren(me)
284 | me.hasElemsSequence.initChildren(me)
285 | }
286 |
287 | func (me *SimpleContent) initElement(parent element) {
288 | me.elemBase.init(parent, me, "simpleContent", &me.hasAttrId)
289 | me.hasElemAnnotation.initChildren(me)
290 | me.hasElemExtensionSimpleContent.initChildren(me)
291 | me.hasElemRestrictionSimpleContent.initChildren(me)
292 | }
293 |
294 | func (me *SimpleType) initElement(parent element) {
295 | me.elemBase.init(parent, me, "simpleType", &me.hasAttrFinal, &me.hasAttrId, &me.hasAttrName)
296 | me.hasElemAnnotation.initChildren(me)
297 | me.hasElemRestrictionSimpleType.initChildren(me)
298 | me.hasElemList.initChildren(me)
299 | me.hasElemUnion.initChildren(me)
300 | }
301 |
302 | func (me *Union) initElement(parent element) {
303 | me.elemBase.init(parent, me, "union", &me.hasAttrId, &me.hasAttrMemberTypes)
304 | me.hasElemAnnotation.initChildren(me)
305 | me.hasElemsSimpleType.initChildren(me)
306 | }
307 |
308 | func (me *Unique) initElement(parent element) {
309 | me.elemBase.init(parent, me, "unique", &me.hasAttrId, &me.hasAttrName)
310 | me.hasElemAnnotation.initChildren(me)
311 | me.hasElemField.initChildren(me)
312 | me.hasElemSelector.initChildren(me)
313 | }
314 |
--------------------------------------------------------------------------------
/hasattr.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | import (
4 | xsdt "github.com/metaleap/go-xsd/types"
5 | )
6 |
7 | type hasAttrAbstract struct {
8 | Abstract bool `xml:"abstract,attr"`
9 | }
10 |
11 | type hasAttrAttributeFormDefault struct {
12 | AttributeFormDefault string `xml:"attributeFormDefault,attr"`
13 | }
14 |
15 | type hasAttrBase struct {
16 | Base xsdt.Qname `xml:"base,attr"`
17 | }
18 |
19 | type hasAttrBlock struct {
20 | Block string `xml:"block,attr"`
21 | }
22 |
23 | type hasAttrBlockDefault struct {
24 | BlockDefault string `xml:"blockDefault,attr"`
25 | }
26 |
27 | type hasAttrDefault struct {
28 | Default string `xml:"default,attr"`
29 | }
30 |
31 | type hasAttrFinal struct {
32 | Final string `xml:"final,attr"`
33 | }
34 |
35 | type hasAttrFinalDefault struct {
36 | FinalDefault string `xml:"finalDefault,attr"`
37 | }
38 |
39 | type hasAttrFixed struct {
40 | Fixed string `xml:"fixed,attr"`
41 | }
42 |
43 | type hasAttrForm struct {
44 | Form string `xml:"form,attr"`
45 | }
46 |
47 | type hasAttrElementFormDefault struct {
48 | ElementFormDefault string `xml:"elementFormDefault,attr"`
49 | }
50 |
51 | type hasAttrId struct {
52 | Id xsdt.Id `xml:"id,attr"`
53 | }
54 |
55 | type hasAttrItemType struct {
56 | ItemType xsdt.Qname `xml:"itemType,attr"`
57 | }
58 |
59 | type hasAttrLang struct {
60 | Lang xsdt.Language `xml:"lang,attr"`
61 | }
62 |
63 | type hasAttrMaxOccurs struct {
64 | MaxOccurs string `xml:"maxOccurs,attr"`
65 | }
66 |
67 | func (me *hasAttrMaxOccurs) Value() (l xsdt.Long) {
68 | if len(me.MaxOccurs) == 0 {
69 | l = 1
70 | } else if me.MaxOccurs == "unbounded" {
71 | l = -1
72 | } else {
73 | l.Set(me.MaxOccurs)
74 | }
75 | return
76 | }
77 |
78 | type hasAttrMemberTypes struct {
79 | MemberTypes string `xml:"memberTypes,attr"`
80 | }
81 |
82 | type hasAttrMinOccurs struct {
83 | MinOccurs uint64 `xml:"minOccurs,attr"`
84 | }
85 |
86 | type hasAttrMixed struct {
87 | Mixed bool `xml:"mixed,attr"`
88 | }
89 |
90 | type hasAttrName struct {
91 | Name xsdt.NCName `xml:"name,attr"`
92 | }
93 |
94 | type hasAttrNamespace struct {
95 | Namespace string `xml:"namespace,attr"`
96 | }
97 |
98 | type hasAttrNillable struct {
99 | Nillable bool `xml:"nillable,attr"`
100 | }
101 |
102 | type hasAttrProcessContents struct {
103 | ProcessContents string `xml:"processContents,attr"`
104 | }
105 |
106 | type hasAttrPublic struct {
107 | Public string `xml:"public,attr"`
108 | }
109 |
110 | type hasAttrRef struct {
111 | Ref xsdt.Qname `xml:"ref,attr"`
112 | }
113 |
114 | type hasAttrRefer struct {
115 | Refer xsdt.Qname `xml:"refer,attr"`
116 | }
117 |
118 | type hasAttrSchemaLocation struct {
119 | SchemaLocation xsdt.AnyURI `xml:"schemaLocation,attr"`
120 | }
121 |
122 | type hasAttrSource struct {
123 | Source xsdt.AnyURI `xml:"source,attr"`
124 | }
125 |
126 | type hasAttrSubstitutionGroup struct {
127 | SubstitutionGroup xsdt.Qname `xml:"substitutionGroup,attr"`
128 | }
129 |
130 | type hasAttrSystem struct {
131 | System xsdt.AnyURI `xml:"system,attr"`
132 | }
133 |
134 | type hasAttrTargetNamespace struct {
135 | TargetNamespace xsdt.AnyURI `xml:"targetNamespace,attr"`
136 | }
137 |
138 | type hasAttrType struct {
139 | Type xsdt.Qname `xml:"type,attr"`
140 | }
141 |
142 | type hasAttrUse struct {
143 | Use string `xml:"use,attr"`
144 | }
145 |
146 | type hasAttrValue struct {
147 | Value string `xml:"value,attr"`
148 | }
149 |
150 | type hasAttrVersion struct {
151 | Version xsdt.Token `xml:"version,attr"`
152 | }
153 |
154 | type hasAttrXpath struct {
155 | Xpath string `xml:"xpath,attr"`
156 | }
157 |
--------------------------------------------------------------------------------
/haselem.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | type hasCdata struct {
4 | CDATA string `xml:",chardata"`
5 | }
6 |
7 | type hasElemAll struct {
8 | All *All `xml:"all"`
9 | }
10 |
11 | type hasElemAnnotation struct {
12 | Annotation *Annotation `xml:"annotation"`
13 | }
14 |
15 | type hasElemsAny struct {
16 | Anys []*Any `xml:"any"`
17 | }
18 |
19 | type hasElemsAnyAttribute struct {
20 | AnyAttributes []*AnyAttribute `xml:"anyAttribute"`
21 | }
22 |
23 | type hasElemsAppInfo struct {
24 | AppInfos []*AppInfo `xml:"appinfo"`
25 | }
26 |
27 | type hasElemsAttribute struct {
28 | Attributes []*Attribute `xml:"attribute"`
29 | }
30 |
31 | type hasElemsAttributeGroup struct {
32 | AttributeGroups []*AttributeGroup `xml:"attributeGroup"`
33 | }
34 |
35 | type hasElemChoice struct {
36 | Choice *Choice `xml:"choice"`
37 | }
38 |
39 | type hasElemsChoice struct {
40 | Choices []*Choice `xml:"choice"`
41 | }
42 |
43 | type hasElemComplexContent struct {
44 | ComplexContent *ComplexContent `xml:"complexContent"`
45 | }
46 |
47 | type hasElemComplexType struct {
48 | ComplexType *ComplexType `xml:"complexType"`
49 | }
50 |
51 | type hasElemsComplexType struct {
52 | ComplexTypes []*ComplexType `xml:"complexType"`
53 | }
54 |
55 | type hasElemsDocumentation struct {
56 | Documentations []*Documentation `xml:"documentation"`
57 | }
58 |
59 | type hasElemsElement struct {
60 | Elements []*Element `xml:"element"`
61 | }
62 |
63 | type hasElemsEnumeration struct {
64 | Enumerations []*RestrictionSimpleEnumeration `xml:"enumeration"`
65 | }
66 |
67 | type hasElemExtensionComplexContent struct {
68 | ExtensionComplexContent *ExtensionComplexContent `xml:"extension"`
69 | }
70 |
71 | type hasElemExtensionSimpleContent struct {
72 | ExtensionSimpleContent *ExtensionSimpleContent `xml:"extension"`
73 | }
74 |
75 | type hasElemField struct {
76 | Field *Field `xml:"field"`
77 | }
78 |
79 | type hasElemFractionDigits struct {
80 | FractionDigits *RestrictionSimpleFractionDigits `xml:"fractionDigits"`
81 | }
82 |
83 | type hasElemGroup struct {
84 | Group *Group `xml:"group"`
85 | }
86 |
87 | type hasElemsGroup struct {
88 | Groups []*Group `xml:"group"`
89 | }
90 |
91 | type hasElemsImport struct {
92 | Imports []*Import `xml:"import"`
93 | }
94 |
95 | type hasElemsInclude struct {
96 | Includes []*Include `xml:"include"`
97 | }
98 |
99 | type hasElemsKey struct {
100 | Keys []*Key `xml:"key"`
101 | }
102 |
103 | type hasElemKeyRef struct {
104 | KeyRef *KeyRef `xml:"keyref"`
105 | }
106 |
107 | type hasElemLength struct {
108 | Length *RestrictionSimpleLength `xml:"length"`
109 | }
110 |
111 | type hasElemList struct {
112 | List *List `xml:"list"`
113 | }
114 |
115 | type hasElemMaxExclusive struct {
116 | MaxExclusive *RestrictionSimpleMaxExclusive `xml:"maxExclusive"`
117 | }
118 |
119 | type hasElemMaxInclusive struct {
120 | MaxInclusive *RestrictionSimpleMaxInclusive `xml:"maxInclusive"`
121 | }
122 |
123 | type hasElemMaxLength struct {
124 | MaxLength *RestrictionSimpleMaxLength `xml:"maxLength"`
125 | }
126 |
127 | type hasElemMinExclusive struct {
128 | MinExclusive *RestrictionSimpleMinExclusive `xml:"minExclusive"`
129 | }
130 |
131 | type hasElemMinInclusive struct {
132 | MinInclusive *RestrictionSimpleMinInclusive `xml:"minInclusive"`
133 | }
134 |
135 | type hasElemMinLength struct {
136 | MinLength *RestrictionSimpleMinLength `xml:"minLength"`
137 | }
138 |
139 | type hasElemsNotation struct {
140 | Notations []*Notation `xml:"notation"`
141 | }
142 |
143 | type hasElemPattern struct {
144 | Pattern *RestrictionSimplePattern `xml:"pattern"`
145 | }
146 |
147 | type hasElemsRedefine struct {
148 | Redefines []*Redefine `xml:"redefine"`
149 | }
150 |
151 | type hasElemRestrictionComplexContent struct {
152 | RestrictionComplexContent *RestrictionComplexContent `xml:"restriction"`
153 | }
154 |
155 | type hasElemRestrictionSimpleContent struct {
156 | RestrictionSimpleContent *RestrictionSimpleContent `xml:"restriction"`
157 | }
158 |
159 | type hasElemRestrictionSimpleType struct {
160 | RestrictionSimpleType *RestrictionSimpleType `xml:"restriction"`
161 | }
162 |
163 | type hasElemSelector struct {
164 | Selector *Selector `xml:"selector"`
165 | }
166 |
167 | type hasElemSequence struct {
168 | Sequence *Sequence `xml:"sequence"`
169 | }
170 |
171 | type hasElemsSequence struct {
172 | Sequences []*Sequence `xml:"sequence"`
173 | }
174 |
175 | type hasElemSimpleContent struct {
176 | SimpleContent *SimpleContent `xml:"simpleContent"`
177 | }
178 |
179 | type hasElemsSimpleType struct {
180 | SimpleTypes []*SimpleType `xml:"simpleType"`
181 | }
182 |
183 | type hasElemTotalDigits struct {
184 | TotalDigits *RestrictionSimpleTotalDigits `xml:"totalDigits"`
185 | }
186 |
187 | type hasElemUnion struct {
188 | Union *Union `xml:"union"`
189 | }
190 |
191 | type hasElemUnique struct {
192 | Unique *Unique `xml:"unique"`
193 | }
194 |
195 | type hasElemWhiteSpace struct {
196 | WhiteSpace *RestrictionSimpleWhiteSpace `xml:"whiteSpace"`
197 | }
198 |
--------------------------------------------------------------------------------
/hasmakepkg.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | func (me *hasElemAll) makePkg(bag *PkgBag) {
4 | if me.All != nil {
5 | me.All.makePkg(bag)
6 | }
7 | }
8 |
9 | func (me *hasElemAnnotation) makePkg(bag *PkgBag) {
10 | if me.Annotation != nil {
11 | me.Annotation.makePkg(bag)
12 | }
13 | }
14 |
15 | func (me *hasElemsAny) makePkg(bag *PkgBag) {
16 | for _, any := range me.Anys {
17 | any.makePkg(bag)
18 | }
19 | }
20 |
21 | func (me *hasElemsAnyAttribute) makePkg(bag *PkgBag) {
22 | for _, aa := range me.AnyAttributes {
23 | aa.makePkg(bag)
24 | }
25 | }
26 |
27 | func (me *hasElemsAppInfo) makePkg(bag *PkgBag) {
28 | for _, ai := range me.AppInfos {
29 | ai.makePkg(bag)
30 | }
31 | }
32 |
33 | func (me *hasElemsAttribute) makePkg(bag *PkgBag) {
34 | for _, ea := range me.Attributes {
35 | ea.makePkg(bag)
36 | }
37 | }
38 |
39 | func (me *hasElemsAttributeGroup) makePkg(bag *PkgBag) {
40 | for _, ag := range me.AttributeGroups {
41 | ag.makePkg(bag)
42 | }
43 | }
44 |
45 | func (me *hasElemChoice) makePkg(bag *PkgBag) {
46 | if me.Choice != nil {
47 | me.Choice.makePkg(bag)
48 | }
49 | }
50 |
51 | func (me *hasElemsChoice) makePkg(bag *PkgBag) {
52 | for _, ch := range me.Choices {
53 | ch.makePkg(bag)
54 | }
55 | }
56 |
57 | func (me *hasElemComplexContent) makePkg(bag *PkgBag) {
58 | if me.ComplexContent != nil {
59 | me.ComplexContent.makePkg(bag)
60 | }
61 | }
62 |
63 | func (me *hasElemComplexType) makePkg(bag *PkgBag) {
64 | if me.ComplexType != nil {
65 | me.ComplexType.makePkg(bag)
66 | }
67 | }
68 |
69 | func (me *hasElemsComplexType) makePkg(bag *PkgBag) {
70 | for _, ct := range me.ComplexTypes {
71 | ct.makePkg(bag)
72 | }
73 | }
74 |
75 | func (me *hasElemsDocumentation) makePkg(bag *PkgBag) {
76 | for _, doc := range me.Documentations {
77 | doc.makePkg(bag)
78 | }
79 | }
80 |
81 | func (me *hasElemsElement) makePkg(bag *PkgBag) {
82 | for _, el := range me.Elements {
83 | el.makePkg(bag)
84 | }
85 | }
86 |
87 | func (me *hasElemsEnumeration) makePkg(bag *PkgBag) {
88 | for _, enum := range me.Enumerations {
89 | enum.makePkg(bag)
90 | }
91 | }
92 |
93 | func (me *hasElemExtensionComplexContent) makePkg(bag *PkgBag) {
94 | if me.ExtensionComplexContent != nil {
95 | me.ExtensionComplexContent.makePkg(bag)
96 | }
97 | }
98 |
99 | func (me *hasElemExtensionSimpleContent) makePkg(bag *PkgBag) {
100 | if me.ExtensionSimpleContent != nil {
101 | me.ExtensionSimpleContent.makePkg(bag)
102 | }
103 | }
104 |
105 | func (me *hasElemField) makePkg(bag *PkgBag) {
106 | if me.Field != nil {
107 | me.Field.makePkg(bag)
108 | }
109 | }
110 |
111 | func (me *hasElemFractionDigits) makePkg(bag *PkgBag) {
112 | if me.FractionDigits != nil {
113 | me.FractionDigits.makePkg(bag)
114 | }
115 | }
116 |
117 | func (me *hasElemGroup) makePkg(bag *PkgBag) {
118 | if me.Group != nil {
119 | me.Group.makePkg(bag)
120 | }
121 | }
122 |
123 | func (me *hasElemsGroup) makePkg(bag *PkgBag) {
124 | for _, gr := range me.Groups {
125 | gr.makePkg(bag)
126 | }
127 | }
128 |
129 | func (me *hasElemsImport) makePkg(bag *PkgBag) {
130 | for _, imp := range me.Imports {
131 | imp.makePkg(bag)
132 | }
133 | }
134 |
135 | func (me *hasElemsKey) makePkg(bag *PkgBag) {
136 | for _, k := range me.Keys {
137 | k.makePkg(bag)
138 | }
139 | }
140 |
141 | func (me *hasElemKeyRef) makePkg(bag *PkgBag) {
142 | if me.KeyRef != nil {
143 | me.KeyRef.makePkg(bag)
144 | }
145 | }
146 |
147 | func (me *hasElemLength) makePkg(bag *PkgBag) {
148 | if me.Length != nil {
149 | me.Length.makePkg(bag)
150 | }
151 | }
152 |
153 | func (me *hasElemList) makePkg(bag *PkgBag) {
154 | if me.List != nil {
155 | me.List.makePkg(bag)
156 | }
157 | }
158 |
159 | func (me *hasElemMaxExclusive) makePkg(bag *PkgBag) {
160 | if me.MaxExclusive != nil {
161 | me.MaxExclusive.makePkg(bag)
162 | }
163 | }
164 |
165 | func (me *hasElemMaxInclusive) makePkg(bag *PkgBag) {
166 | if me.MaxInclusive != nil {
167 | me.MaxInclusive.makePkg(bag)
168 | }
169 | }
170 |
171 | func (me *hasElemMaxLength) makePkg(bag *PkgBag) {
172 | if me.MaxLength != nil {
173 | me.MaxLength.makePkg(bag)
174 | }
175 | }
176 |
177 | func (me *hasElemMinExclusive) makePkg(bag *PkgBag) {
178 | if me.MinExclusive != nil {
179 | me.MinExclusive.makePkg(bag)
180 | }
181 | }
182 |
183 | func (me *hasElemMinInclusive) makePkg(bag *PkgBag) {
184 | if me.MinInclusive != nil {
185 | me.MinInclusive.makePkg(bag)
186 | }
187 | }
188 |
189 | func (me *hasElemMinLength) makePkg(bag *PkgBag) {
190 | if me.MinLength != nil {
191 | me.MinLength.makePkg(bag)
192 | }
193 | }
194 |
195 | func (me *hasElemsNotation) makePkg(bag *PkgBag) {
196 | for _, not := range me.Notations {
197 | not.makePkg(bag)
198 | }
199 | }
200 |
201 | func (me *hasElemPattern) makePkg(bag *PkgBag) {
202 | if me.Pattern != nil {
203 | me.Pattern.makePkg(bag)
204 | }
205 | }
206 |
207 | func (me *hasElemsRedefine) makePkg(bag *PkgBag) {
208 | for _, rd := range me.Redefines {
209 | rd.makePkg(bag)
210 | }
211 | }
212 |
213 | func (me *hasElemRestrictionComplexContent) makePkg(bag *PkgBag) {
214 | if me.RestrictionComplexContent != nil {
215 | me.RestrictionComplexContent.makePkg(bag)
216 | }
217 | }
218 |
219 | func (me *hasElemRestrictionSimpleContent) makePkg(bag *PkgBag) {
220 | if me.RestrictionSimpleContent != nil {
221 | me.RestrictionSimpleContent.makePkg(bag)
222 | }
223 | }
224 |
225 | func (me *hasElemRestrictionSimpleType) makePkg(bag *PkgBag) {
226 | if me.RestrictionSimpleType != nil {
227 | me.RestrictionSimpleType.makePkg(bag)
228 | }
229 | }
230 |
231 | func (me *hasElemSelector) makePkg(bag *PkgBag) {
232 | if me.Selector != nil {
233 | me.Selector.makePkg(bag)
234 | }
235 | }
236 |
237 | func (me *hasElemSequence) makePkg(bag *PkgBag) {
238 | if me.Sequence != nil {
239 | me.Sequence.makePkg(bag)
240 | }
241 | }
242 |
243 | func (me *hasElemsSequence) makePkg(bag *PkgBag) {
244 | for _, seq := range me.Sequences {
245 | seq.makePkg(bag)
246 | }
247 | }
248 |
249 | func (me *hasElemSimpleContent) makePkg(bag *PkgBag) {
250 | if me.SimpleContent != nil {
251 | me.SimpleContent.makePkg(bag)
252 | }
253 | }
254 |
255 | func (me *hasElemsSimpleType) makePkg(bag *PkgBag) {
256 | for _, st := range me.SimpleTypes {
257 | st.makePkg(bag)
258 | }
259 | }
260 |
261 | func (me *hasElemTotalDigits) makePkg(bag *PkgBag) {
262 | if me.TotalDigits != nil {
263 | me.TotalDigits.makePkg(bag)
264 | }
265 | }
266 |
267 | func (me *hasElemUnion) makePkg(bag *PkgBag) {
268 | if me.Union != nil {
269 | me.Union.makePkg(bag)
270 | }
271 | }
272 |
273 | func (me *hasElemUnique) makePkg(bag *PkgBag) {
274 | if me.Unique != nil {
275 | me.Unique.makePkg(bag)
276 | }
277 | }
278 |
279 | func (me *hasElemWhiteSpace) makePkg(bag *PkgBag) {
280 | if me.WhiteSpace != nil {
281 | me.WhiteSpace.makePkg(bag)
282 | }
283 | }
284 |
285 | func (me *hasAttrAbstract) beforeMakePkg(bag *PkgBag) {
286 | }
287 |
288 | func (me *hasAttrBase) beforeMakePkg(bag *PkgBag) {
289 | }
290 |
291 | func (me *hasAttrBlock) beforeMakePkg(bag *PkgBag) {
292 | }
293 |
294 | func (me *hasAttrDefault) beforeMakePkg(bag *PkgBag) {
295 | }
296 |
297 | func (me *hasAttrFinal) beforeMakePkg(bag *PkgBag) {
298 | }
299 |
300 | func (me *hasAttrFixed) beforeMakePkg(bag *PkgBag) {
301 | }
302 |
303 | func (me *hasAttrForm) beforeMakePkg(bag *PkgBag) {
304 | }
305 |
306 | func (me *hasAttrId) beforeMakePkg(bag *PkgBag) {
307 | }
308 |
309 | func (me *hasAttrLang) beforeMakePkg(bag *PkgBag) {
310 | }
311 |
312 | func (me *hasAttrMixed) beforeMakePkg(bag *PkgBag) {
313 | }
314 |
315 | func (me *hasAttrName) beforeMakePkg(bag *PkgBag) {
316 | bag.Stacks.Name.Push(me.Name)
317 | }
318 |
319 | func (me *hasAttrNamespace) beforeMakePkg(bag *PkgBag) {
320 | }
321 |
322 | func (me *hasAttrNillable) beforeMakePkg(bag *PkgBag) {
323 | }
324 |
325 | func (me *hasAttrPublic) beforeMakePkg(bag *PkgBag) {
326 | }
327 |
328 | func (me *hasAttrRef) beforeMakePkg(bag *PkgBag) {
329 | }
330 |
331 | func (me *hasAttrRefer) beforeMakePkg(bag *PkgBag) {
332 | }
333 |
334 | func (me *hasAttrSource) beforeMakePkg(bag *PkgBag) {
335 | }
336 |
337 | func (me *hasAttrSystem) beforeMakePkg(bag *PkgBag) {
338 | }
339 |
340 | func (me *hasAttrType) beforeMakePkg(bag *PkgBag) {
341 | }
342 |
343 | func (me *hasAttrUse) beforeMakePkg(bag *PkgBag) {
344 | }
345 |
346 | func (me *hasAttrValue) beforeMakePkg(bag *PkgBag) {
347 | }
348 |
349 | func (me *hasAttrVersion) beforeMakePkg(bag *PkgBag) {
350 | }
351 |
352 | func (me *hasAttrXpath) beforeMakePkg(bag *PkgBag) {
353 | }
354 |
355 | func (me *hasAttrBlockDefault) beforeMakePkg(bag *PkgBag) {
356 | }
357 |
358 | func (me *hasAttrFinalDefault) beforeMakePkg(bag *PkgBag) {
359 | }
360 |
361 | func (me *hasAttrItemType) beforeMakePkg(bag *PkgBag) {
362 | }
363 |
364 | func (me *hasAttrMaxOccurs) beforeMakePkg(bag *PkgBag) {
365 | }
366 |
367 | func (me *hasAttrMemberTypes) beforeMakePkg(bag *PkgBag) {
368 | }
369 |
370 | func (me *hasAttrMinOccurs) beforeMakePkg(bag *PkgBag) {
371 | }
372 |
373 | func (me *hasAttrProcessContents) beforeMakePkg(bag *PkgBag) {
374 | }
375 |
376 | func (me *hasAttrSchemaLocation) beforeMakePkg(bag *PkgBag) {
377 | }
378 |
379 | func (me *hasAttrSubstitutionGroup) beforeMakePkg(bag *PkgBag) {
380 | }
381 |
382 | func (me *hasAttrTargetNamespace) beforeMakePkg(bag *PkgBag) {
383 | }
384 |
385 | func (me *hasAttrAttributeFormDefault) beforeMakePkg(bag *PkgBag) {
386 | }
387 |
388 | func (me *hasAttrElementFormDefault) beforeMakePkg(bag *PkgBag) {
389 | }
390 |
391 | func (me *hasAttrAbstract) afterMakePkg(bag *PkgBag) {
392 | }
393 |
394 | func (me *hasAttrBase) afterMakePkg(bag *PkgBag) {
395 | }
396 |
397 | func (me *hasAttrBlock) afterMakePkg(bag *PkgBag) {
398 | }
399 |
400 | func (me *hasAttrDefault) afterMakePkg(bag *PkgBag) {
401 | }
402 |
403 | func (me *hasAttrFinal) afterMakePkg(bag *PkgBag) {
404 | }
405 |
406 | func (me *hasAttrFixed) afterMakePkg(bag *PkgBag) {
407 | }
408 |
409 | func (me *hasAttrForm) afterMakePkg(bag *PkgBag) {
410 | }
411 |
412 | func (me *hasAttrId) afterMakePkg(bag *PkgBag) {
413 | }
414 |
415 | func (me *hasAttrLang) afterMakePkg(bag *PkgBag) {
416 | }
417 |
418 | func (me *hasAttrMixed) afterMakePkg(bag *PkgBag) {
419 | }
420 |
421 | func (me *hasAttrName) afterMakePkg(bag *PkgBag) {
422 | bag.Stacks.Name.Pop()
423 | }
424 |
425 | func (me *hasAttrNamespace) afterMakePkg(bag *PkgBag) {
426 | }
427 |
428 | func (me *hasAttrNillable) afterMakePkg(bag *PkgBag) {
429 | }
430 |
431 | func (me *hasAttrPublic) afterMakePkg(bag *PkgBag) {
432 | }
433 |
434 | func (me *hasAttrRef) afterMakePkg(bag *PkgBag) {
435 | }
436 |
437 | func (me *hasAttrRefer) afterMakePkg(bag *PkgBag) {
438 | }
439 |
440 | func (me *hasAttrSource) afterMakePkg(bag *PkgBag) {
441 | }
442 |
443 | func (me *hasAttrSystem) afterMakePkg(bag *PkgBag) {
444 | }
445 |
446 | func (me *hasAttrType) afterMakePkg(bag *PkgBag) {
447 | }
448 |
449 | func (me *hasAttrUse) afterMakePkg(bag *PkgBag) {
450 | }
451 |
452 | func (me *hasAttrValue) afterMakePkg(bag *PkgBag) {
453 | }
454 |
455 | func (me *hasAttrVersion) afterMakePkg(bag *PkgBag) {
456 | }
457 |
458 | func (me *hasAttrXpath) afterMakePkg(bag *PkgBag) {
459 | }
460 |
461 | func (me *hasAttrBlockDefault) afterMakePkg(bag *PkgBag) {
462 | }
463 |
464 | func (me *hasAttrFinalDefault) afterMakePkg(bag *PkgBag) {
465 | }
466 |
467 | func (me *hasAttrItemType) afterMakePkg(bag *PkgBag) {
468 | }
469 |
470 | func (me *hasAttrMaxOccurs) afterMakePkg(bag *PkgBag) {
471 | }
472 |
473 | func (me *hasAttrMemberTypes) afterMakePkg(bag *PkgBag) {
474 | }
475 |
476 | func (me *hasAttrMinOccurs) afterMakePkg(bag *PkgBag) {
477 | }
478 |
479 | func (me *hasAttrProcessContents) afterMakePkg(bag *PkgBag) {
480 | }
481 |
482 | func (me *hasAttrSchemaLocation) afterMakePkg(bag *PkgBag) {
483 | }
484 |
485 | func (me *hasAttrSubstitutionGroup) afterMakePkg(bag *PkgBag) {
486 | }
487 |
488 | func (me *hasAttrTargetNamespace) afterMakePkg(bag *PkgBag) {
489 | }
490 |
491 | func (me *hasAttrAttributeFormDefault) afterMakePkg(bag *PkgBag) {
492 | }
493 |
494 | func (me *hasAttrElementFormDefault) afterMakePkg(bag *PkgBag) {
495 | }
496 |
--------------------------------------------------------------------------------
/hasparents.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | func (me *hasElemAll) initChildren(p element) {
4 | if me.All != nil {
5 | me.All.initElement(p)
6 | }
7 | }
8 |
9 | func (me *hasElemAnnotation) initChildren(p element) {
10 | if me.Annotation != nil {
11 | me.Annotation.initElement(p)
12 | }
13 | }
14 |
15 | func (me *hasElemsAny) initChildren(p element) {
16 | for _, any := range me.Anys {
17 | any.initElement(p)
18 | }
19 | }
20 |
21 | func (me *hasElemsAnyAttribute) initChildren(p element) {
22 | for _, aa := range me.AnyAttributes {
23 | aa.initElement(p)
24 | }
25 | }
26 |
27 | func (me *hasElemsAppInfo) initChildren(p element) {
28 | for _, ai := range me.AppInfos {
29 | ai.initElement(p)
30 | }
31 | }
32 |
33 | func (me *hasElemsAttribute) initChildren(p element) {
34 | for _, ea := range me.Attributes {
35 | ea.initElement(p)
36 | }
37 | }
38 |
39 | func (me *hasElemsAttributeGroup) initChildren(p element) {
40 | for _, ag := range me.AttributeGroups {
41 | ag.initElement(p)
42 | }
43 | }
44 |
45 | func (me *hasElemChoice) initChildren(p element) {
46 | if me.Choice != nil {
47 | me.Choice.initElement(p)
48 | }
49 | }
50 |
51 | func (me *hasElemsChoice) initChildren(p element) {
52 | for _, ch := range me.Choices {
53 | ch.initElement(p)
54 | }
55 | }
56 |
57 | func (me *hasElemComplexContent) initChildren(p element) {
58 | if me.ComplexContent != nil {
59 | me.ComplexContent.initElement(p)
60 | }
61 | }
62 |
63 | func (me *hasElemComplexType) initChildren(p element) {
64 | if me.ComplexType != nil {
65 | me.ComplexType.initElement(p)
66 | }
67 | }
68 |
69 | func (me *hasElemsComplexType) initChildren(p element) {
70 | for _, ct := range me.ComplexTypes {
71 | ct.initElement(p)
72 | }
73 | }
74 |
75 | func (me *hasElemsDocumentation) initChildren(p element) {
76 | for _, doc := range me.Documentations {
77 | doc.initElement(p)
78 | }
79 | }
80 |
81 | func (me *hasElemsElement) initChildren(p element) {
82 | for _, el := range me.Elements {
83 | el.initElement(p)
84 | }
85 | }
86 |
87 | func (me *hasElemsEnumeration) initChildren(p element) {
88 | for _, enum := range me.Enumerations {
89 | enum.initElement(p)
90 | }
91 | }
92 |
93 | func (me *hasElemExtensionComplexContent) initChildren(p element) {
94 | if me.ExtensionComplexContent != nil {
95 | me.ExtensionComplexContent.initElement(p)
96 | }
97 | }
98 |
99 | func (me *hasElemExtensionSimpleContent) initChildren(p element) {
100 | if me.ExtensionSimpleContent != nil {
101 | me.ExtensionSimpleContent.initElement(p)
102 | }
103 | }
104 |
105 | func (me *hasElemField) initChildren(p element) {
106 | if me.Field != nil {
107 | me.Field.initElement(p)
108 | }
109 | }
110 |
111 | func (me *hasElemFractionDigits) initChildren(p element) {
112 | if me.FractionDigits != nil {
113 | me.FractionDigits.initElement(p)
114 | }
115 | }
116 |
117 | func (me *hasElemGroup) initChildren(p element) {
118 | if me.Group != nil {
119 | me.Group.initElement(p)
120 | }
121 | }
122 |
123 | func (me *hasElemsGroup) initChildren(p element) {
124 | for _, gr := range me.Groups {
125 | gr.initElement(p)
126 | }
127 | }
128 |
129 | func (me *hasElemsImport) initChildren(p element) {
130 | for _, imp := range me.Imports {
131 | imp.initElement(p)
132 | }
133 | }
134 |
135 | func (me *hasElemsKey) initChildren(p element) {
136 | for _, k := range me.Keys {
137 | k.initElement(p)
138 | }
139 | }
140 |
141 | func (me *hasElemKeyRef) initChildren(p element) {
142 | if me.KeyRef != nil {
143 | me.KeyRef.initElement(p)
144 | }
145 | }
146 |
147 | func (me *hasElemLength) initChildren(p element) {
148 | if me.Length != nil {
149 | me.Length.initElement(p)
150 | }
151 | }
152 |
153 | func (me *hasElemList) initChildren(p element) {
154 | if me.List != nil {
155 | me.List.initElement(p)
156 | }
157 | }
158 |
159 | func (me *hasElemMaxExclusive) initChildren(p element) {
160 | if me.MaxExclusive != nil {
161 | me.MaxExclusive.initElement(p)
162 | }
163 | }
164 |
165 | func (me *hasElemMaxInclusive) initChildren(p element) {
166 | if me.MaxInclusive != nil {
167 | me.MaxInclusive.initElement(p)
168 | }
169 | }
170 |
171 | func (me *hasElemMaxLength) initChildren(p element) {
172 | if me.MaxLength != nil {
173 | me.MaxLength.initElement(p)
174 | }
175 | }
176 |
177 | func (me *hasElemMinExclusive) initChildren(p element) {
178 | if me.MinExclusive != nil {
179 | me.MinExclusive.initElement(p)
180 | }
181 | }
182 |
183 | func (me *hasElemMinInclusive) initChildren(p element) {
184 | if me.MinInclusive != nil {
185 | me.MinInclusive.initElement(p)
186 | }
187 | }
188 |
189 | func (me *hasElemMinLength) initChildren(p element) {
190 | if me.MinLength != nil {
191 | me.MinLength.initElement(p)
192 | }
193 | }
194 |
195 | func (me *hasElemsNotation) initChildren(p element) {
196 | for _, not := range me.Notations {
197 | not.initElement(p)
198 | }
199 | }
200 |
201 | func (me *hasElemPattern) initChildren(p element) {
202 | if me.Pattern != nil {
203 | me.Pattern.initElement(p)
204 | }
205 | }
206 |
207 | func (me *hasElemsRedefine) initChildren(p element) {
208 | for _, rd := range me.Redefines {
209 | rd.initElement(p)
210 | }
211 | }
212 |
213 | func (me *hasElemRestrictionComplexContent) initChildren(p element) {
214 | if me.RestrictionComplexContent != nil {
215 | me.RestrictionComplexContent.initElement(p)
216 | }
217 | }
218 |
219 | func (me *hasElemRestrictionSimpleContent) initChildren(p element) {
220 | if me.RestrictionSimpleContent != nil {
221 | me.RestrictionSimpleContent.initElement(p)
222 | }
223 | }
224 |
225 | func (me *hasElemRestrictionSimpleType) initChildren(p element) {
226 | if me.RestrictionSimpleType != nil {
227 | me.RestrictionSimpleType.initElement(p)
228 | }
229 | }
230 |
231 | func (me *hasElemSelector) initChildren(p element) {
232 | if me.Selector != nil {
233 | me.Selector.initElement(p)
234 | }
235 | }
236 |
237 | func (me *hasElemSequence) initChildren(p element) {
238 | if me.Sequence != nil {
239 | me.Sequence.initElement(p)
240 | }
241 | }
242 |
243 | func (me *hasElemsSequence) initChildren(p element) {
244 | for _, seq := range me.Sequences {
245 | seq.initElement(p)
246 | }
247 | }
248 |
249 | func (me *hasElemSimpleContent) initChildren(p element) {
250 | if me.SimpleContent != nil {
251 | me.SimpleContent.initElement(p)
252 | }
253 | }
254 |
255 | func (me *hasElemsSimpleType) initChildren(p element) {
256 | for _, st := range me.SimpleTypes {
257 | st.initElement(p)
258 | }
259 | }
260 |
261 | func (me *hasElemTotalDigits) initChildren(p element) {
262 | if me.TotalDigits != nil {
263 | me.TotalDigits.initElement(p)
264 | }
265 | }
266 |
267 | func (me *hasElemUnion) initChildren(p element) {
268 | if me.Union != nil {
269 | me.Union.initElement(p)
270 | }
271 | }
272 |
273 | func (me *hasElemUnique) initChildren(p element) {
274 | if me.Unique != nil {
275 | me.Unique.initElement(p)
276 | }
277 | }
278 |
279 | func (me *hasElemWhiteSpace) initChildren(p element) {
280 | if me.WhiteSpace != nil {
281 | me.WhiteSpace.initElement(p)
282 | }
283 | }
284 |
--------------------------------------------------------------------------------
/types/doc.go:
--------------------------------------------------------------------------------
1 | // A tiny package imported by all "go-xsd"-generated packages.
2 | //
3 | // Maps all XSD built-in simple-types to Go types, which affords us easy mapping of any XSD type references in the schema to Go imports: every xs:string and xs:boolean automatically becomes xsdt.String and xsdt.Boolean etc.
4 | // Types are mapped to Go types depending on how encoding/xml.Unmarshal() can handle them: ie. it parses bools and numbers, but dates/durations have too many format mismatches and thus are just declared string types.
5 | // Same for base64- and hex-encoded binary data: since Unmarshal() won't decode them, we leave them as strings. If you need their binary data, your code needs to import Go's base64/hex codec packages and use them as necessary.
6 | package xsdt
7 |
--------------------------------------------------------------------------------
/xsd-makepkg/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "log"
6 | "os/exec"
7 | "strings"
8 |
9 | "github.com/metaleap/go-util/dev/go"
10 |
11 | xsd "github.com/metaleap/go-xsd"
12 | )
13 |
14 | var (
15 | flagGoFmt = flag.Bool("gofmt", true, "Run 'gofmt' against the generated Go wrapper package?")
16 | flagGoInst = flag.Bool("goinst", true, "Run 'go-buildrun' against the generated Go wrapper package?")
17 | flagSchema = flag.String("uri", "", "The XML Schema Definition file URIs to generate a Go wrapper packages from, whitespace-separated. (For each, the protocol prefix can be omitted, it then defaults to http://. Only protocols understood by the net/http package are supported.)")
18 | flagLocalCopy = flag.Bool("local", true, "Local copy: only downloads if file does not exist locally")
19 | flagForceParse = flag.Bool("parse", false, "Not necessary unless the generated Go wrapper package won't compile.")
20 | flagBasePath = flag.String("basepath", "", "Defaults to "+xsd.PkgGen.BasePath+". A $GOPATH/src/-relative path (always a slash-style path, even on Windows) where XSD files are downloaded to / loaded from and generated Go wrapper packages are created. Any XSD imports are also rewritten as Go imports from that path (but are not otherwise auto-magically processed in any way).")
21 |
22 | // if no schemas are specified in *flagSchema, we run the pkg-maker through a default series of various XSDs...
23 | schemas = []string{
24 | "www.w3.org/2001/xml.xsd",
25 | "www.w3.org/2001/03/xml.xsd",
26 | "www.w3.org/TR/2002/WD-SVG11-20020108/xml.xsd",
27 | "www.w3.org/TR/2002/WD-SVG11-20020108/xlink.xsd",
28 | "www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd",
29 | "www.w3.org/2007/schema-for-xslt20.xsd",
30 | "www.w3.org/Math/XMLSchema/mathml2/common/xlink-href.xsd",
31 | "www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd",
32 | "docs.oasis-open.org/election/external/xAL.xsd",
33 | "docbook.org/xml/5.0/xsd/xml.xsd",
34 | "docbook.org/xml/5.0/xsd/xlink.xsd",
35 | "docbook.org/xml/5.0/xsd/docbook.xsd",
36 | "kbcafe.com/rss/atom.xsd.xml",
37 | "thearchitect.co.uk/schemas/rss-2_0.xsd",
38 | "schemas.opengis.net/kml/2.2.0/atom-author-link.xsd",
39 | "schemas.opengis.net/kml/2.2.0/ogckml22.xsd",
40 | "khronos.org/files/collada_schema_1_4",
41 | "khronos.org/files/collada_schema_1_5",
42 | }
43 | )
44 |
45 | func main() {
46 | var (
47 | sd *xsd.Schema
48 | err error
49 | raw []byte
50 | outFilePath string
51 | )
52 | flag.Parse()
53 | if len(*flagSchema) > 0 {
54 | schemas = strings.Split(*flagSchema, " ")
55 | }
56 | if len(*flagBasePath) > 0 {
57 | xsd.PkgGen.BasePath, xsd.PkgGen.BaseCodePath = *flagBasePath, udevgo.GopathSrc(strings.Split(*flagBasePath, "/")...)
58 | }
59 | for _, s := range schemas {
60 | log.Printf("LOAD:\t%v\n", s)
61 | if sd, err = xsd.LoadSchema(s, *flagLocalCopy); err != nil {
62 | log.Printf("\tERROR: %v\n", err)
63 | } else if sd != nil {
64 | xsd.PkgGen.ForceParseForDefaults = *flagForceParse || (s == "schemas.opengis.net/kml/2.2.0/ogckml22.xsd") // KML schema uses 0 and 1 as defaults for booleans...
65 | if outFilePath, err = sd.MakeGoPkgSrcFile(); err == nil {
66 | log.Printf("MKPKG:\t%v\n", outFilePath)
67 | if *flagGoFmt {
68 | if raw, err = exec.Command("gofmt", "-w=true", "-s=true", "-e=true", outFilePath).CombinedOutput(); len(raw) > 0 {
69 | log.Printf("GOFMT:\t%s\n", string(raw))
70 | }
71 | if err != nil {
72 | log.Printf("GOFMT:\t%v\n", err)
73 | }
74 | }
75 | if *flagGoInst {
76 | if raw, err = exec.Command("go-buildrun", "-d=__doc.html", "-f="+outFilePath).CombinedOutput(); len(raw) > 0 {
77 | println(string(raw))
78 | }
79 | if err != nil {
80 | log.Printf("GOINST:\t%v\n", err)
81 | }
82 | }
83 | } else {
84 | log.Printf("\tERROR:\t%v\n", err)
85 | }
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/README.md:
--------------------------------------------------------------------------------
1 | # tests
2 | --
3 | import "github.com/metaleap/go-xsd/xsd-makepkg/tests"
4 |
5 | A simple test function shared by the various test programs inside this directory (rss, atom, collada, svg etc.)
6 |
7 | ## Usage
8 |
9 | ```go
10 | var (
11 | OnDocLoaded func(interface{})
12 | )
13 | ```
14 |
15 | #### func TestViaRemarshal
16 |
17 | ```go
18 | func TestViaRemarshal(dirPath string, makeEmptyDoc func() interface{})
19 | ```
20 | Attempts to xml.Unmarshal() all files in the "infiles" sub-directory of the
21 | specified directory path into the interface{} structure returned by the
22 | specified constructor. For each such input file, then attempts to
23 | xml.MarshalIndent() said structure back into a new output XML file with the same
24 | name, in the "outfiles" sub-directory of the specified directory path.
25 |
26 | --
27 | **godocdown** http://github.com/robertkrimen/godocdown
--------------------------------------------------------------------------------
/xsd-makepkg/tests/doc.go:
--------------------------------------------------------------------------------
1 | // A simple test function shared by the various test programs inside this directory (rss, atom, collada, svg etc.)
2 | package tests
3 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/tests.go:
--------------------------------------------------------------------------------
1 | package tests
2 |
3 | import (
4 | "encoding/xml"
5 | "fmt"
6 | "log"
7 | "path/filepath"
8 | "strings"
9 |
10 | "github.com/metaleap/go-util/fs"
11 |
12 | xmlx "github.com/go-forks/go-pkg-xmlx"
13 | )
14 |
15 | var (
16 | OnDocLoaded func(interface{})
17 | )
18 |
19 | func verifyDocs(origData, faksData []byte) (errs []error) {
20 | orig, faks := xmlx.New(), xmlx.New()
21 | err := orig.LoadBytes(origData, nil)
22 | if err == nil {
23 | if err = faks.LoadBytes(faksData, nil); err == nil {
24 | errs = verifyNode(orig.Root, faks.Root)
25 | }
26 | }
27 | return
28 | }
29 |
30 | func verifyNode(orig, faks *xmlx.Node) (errs []error) {
31 | type both struct {
32 | origNodes, faksNodes []*xmlx.Node
33 | }
34 | var (
35 | curBoth *both
36 | cn *xmlx.Node
37 | tmp string
38 | i int
39 | subErrs []error
40 | )
41 | attVal := func(xn *xmlx.Node, att *xmlx.Attr) (v string) {
42 | if v = xn.As("", att.Name.Local); len(v) == 0 {
43 | v = xn.As(att.Name.Space, att.Name.Local)
44 | }
45 | return
46 | }
47 | cleanNodes := func(xns ...*xmlx.Node) {
48 | for _, xn := range xns {
49 | for _, cn = range xn.Children {
50 | if cn.Type != xmlx.NT_ELEMENT {
51 | xn.RemoveChild(cn)
52 | }
53 | }
54 | }
55 | }
56 | cleanNodes(orig, faks)
57 | for _, a := range orig.Attributes {
58 | if tmp = attVal(faks, a); tmp != a.Value {
59 | errs = append(errs, fmt.Errorf("Attribute '%s:%s' of <%s> element: different values (orig='%s' faks='%s')", a.Name.Space, a.Name.Local, orig.Name.Local, a.Value, tmp))
60 | }
61 | }
62 | if len(orig.Children) > len(faks.Children) {
63 | errs = append(errs, fmt.Errorf("Orig <%s> element has %v children, but faks has %v.", orig.Name.Local, len(orig.Children), len(faks.Children)))
64 | }
65 | if orig.Value != faks.Value {
66 | errs = append(errs, fmt.Errorf("Orig <%s> element value differs from faks value.", orig.Name.Local))
67 | }
68 | namedNodes := map[string]*both{}
69 | for _, cn = range orig.Children {
70 | if curBoth = namedNodes[cn.Name.Local]; curBoth == nil {
71 | curBoth = &both{}
72 | namedNodes[cn.Name.Local] = curBoth
73 | }
74 | curBoth.origNodes = append(curBoth.origNodes, cn)
75 | }
76 | for _, cn = range faks.Children {
77 | if curBoth = namedNodes[cn.Name.Local]; curBoth != nil {
78 | curBoth.faksNodes = append(curBoth.faksNodes, cn)
79 | }
80 | }
81 | for tmp, curBoth = range namedNodes {
82 | if len(curBoth.origNodes) != len(curBoth.faksNodes) {
83 | errs = append(errs, fmt.Errorf("Orig <%s> element has %v <%s> elements but faks <%s> element has %v.", orig.Name.Local, len(curBoth.origNodes), tmp, faks.Name.Local, len(curBoth.faksNodes)))
84 | } else if len(curBoth.origNodes) == 1 {
85 | errs = append(errs, verifyNode(curBoth.origNodes[0], curBoth.faksNodes[0])...)
86 | } else {
87 | for i, cn = range curBoth.origNodes {
88 | if subErrs = verifyNode(cn, curBoth.faksNodes[i]); len(subErrs) > 0 {
89 | errs = append(errs, subErrs...)
90 | }
91 | }
92 | }
93 | }
94 | return
95 | }
96 |
97 | // Attempts to xml.Unmarshal() all files in the "infiles" sub-directory of the specified directory path into the interface{} structure returned by the specified constructor.
98 | // For each such input file, then attempts to xml.MarshalIndent() said structure back into a new output XML file with the same name, in the "outfiles" sub-directory of the specified directory path.
99 | func TestViaRemarshal(dirPath string, makeEmptyDoc func() interface{}) {
100 | var dirPathInFiles = filepath.Join(dirPath, "infiles")
101 | var dirPathOutFiles = filepath.Join(dirPath, "outfiles")
102 | var loadXmlDocFile = func(filename string) bool {
103 | log.Printf("Loading %s", filename)
104 | doc, dataOrig := makeEmptyDoc(), ufs.ReadBinaryFile(filename, true)
105 | err := xml.Unmarshal(dataOrig, doc)
106 | if err != nil {
107 | panic(err)
108 | }
109 | if OnDocLoaded != nil {
110 | OnDocLoaded(doc)
111 | }
112 | outFileName := filepath.Join(dirPathOutFiles, filepath.Base(filename))
113 | log.Printf("Writing %s", outFileName)
114 | dataFaks, err := xml.MarshalIndent(doc, "", "\t")
115 | if err != nil {
116 | panic(err)
117 | }
118 | ufs.WriteTextFile(outFileName, strings.Trim(string(dataFaks), " \r\n\t"))
119 | log.Printf("Verifying...")
120 | if errs := verifyDocs(dataOrig, dataFaks); len(errs) > 0 {
121 | for _, err = range errs {
122 | log.Printf("%v", err)
123 | }
124 | }
125 | return true
126 | }
127 | if errs := ufs.NewDirWalker(false, nil, loadXmlDocFile).Walk(dirPathInFiles); len(errs) > 0 {
128 | panic(errs[0])
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-atom/feed/infiles/samplefeed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Example Feed
5 |
6 | 2003-12-13T18:30:02Z
7 |
8 | John Doe
9 |
10 | urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6
11 |
12 |
13 | Atom-Powered Robots Run Amok
14 |
15 | urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a
16 | 2003-12-13T18:30:02Z
17 | Some text.
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-atom/feed/outfiles/samplefeed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Some text.
6 | urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a
7 | 2003-12-13T18:30:02Z
8 | Atom-Powered Robots Run Amok
9 |
10 | Example Feed
11 |
12 | John Doe
13 |
14 | 2003-12-13T18:30:02Z
15 | urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6
16 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-atom/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/xml"
5 |
6 | "github.com/metaleap/go-xsd/xsd-makepkg/tests"
7 |
8 | "github.com/metaleap/go-util/dev/go"
9 |
10 | atom "github.com/metaleap/go-xsd-pkg/kbcafe.com/rss/atom.xsd.xml_go"
11 | )
12 |
13 | type AtomEntryDoc struct {
14 | XMLName xml.Name `xml:"entry"`
15 | atom.TentryType
16 | }
17 |
18 | type AtomFeedDoc struct {
19 | XMLName xml.Name `xml:"feed"`
20 | atom.TfeedType
21 | }
22 |
23 | func main() {
24 | var (
25 | entryDirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-atom", "entry")
26 | entryMakeEmptyDoc = func() interface{} { return &AtomEntryDoc{} }
27 | feedDirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-atom", "feed")
28 | feedMakeEmptyDoc = func() interface{} { return &AtomFeedDoc{} }
29 | )
30 | tests.TestViaRemarshal(entryDirBasePath, entryMakeEmptyDoc)
31 | tests.TestViaRemarshal(feedDirBasePath, feedMakeEmptyDoc)
32 | }
33 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/1.4.1/infiles/cube.dae:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | alorino
5 | Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11
6 | Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
7 | curveConstrainSampling=0;exportCameraAsLookat=0;
8 | exportLights=1;exportCameras=1;exportJointsAndSkin=1;
9 | exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
10 | exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
11 | exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
12 | dereferenceXRefs=0;cameraXFov=0;cameraYFov=1
13 |
14 | Copyright 2006 Sony Computer Entertainment Inc.
15 | Licensed under the SCEA Shared Source License, Version 1.0 (the
16 | "License"); you may not use this file except in compliance with the
17 | License. You may obtain a copy of the License at:
18 | http://research.scea.com/scea_shared_source_license.html
19 | Unless required by applicable law or agreed to in writing, software
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 |
26 | 2006-06-21T21:25:37Z
27 | 2006-06-21T21:25:37Z
28 |
29 | Y_UP
30 |
31 |
32 |
33 |
34 |
35 |
36 | 37.8493
37 | 1
38 | 10
39 | 1000
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 37.8501
49 | 1
50 | 0.01
51 | 1000
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 1 1 1
62 | 1
63 | 0
64 | 0
65 |
66 |
67 |
68 |
69 |
70 |
71 | 1 1 1
72 | 1
73 | 0
74 | 0
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | 0 0 0 1
94 |
95 |
96 | 0 0 0 1
97 |
98 |
99 | 0.137255 0.403922 0.870588 1
100 |
101 |
102 | 0.5 0.5 0.5 1
103 |
104 |
105 | 10
106 |
107 |
108 | 0 0 0 1
109 |
110 |
111 | 0.5
112 |
113 |
114 | 0 0 0 1
115 |
116 |
117 | 1
118 |
119 |
120 | 0
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | 0 0 0 1
132 |
133 |
134 | 0 0 0 1
135 |
136 |
137 | 0.658824 0.101961 0.109804 1
138 |
139 |
140 | 0.368627 0.368627 0.368627 1
141 |
142 |
143 | 10
144 |
145 |
146 | 0 0 0 1
147 |
148 |
149 | 0.5
150 |
151 |
152 | 0 0 0 1
153 |
154 |
155 | 1
156 |
157 |
158 | 0
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | -50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 | 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 | 4 4 4 4 4
195 | 0 0 1 1 5 2 4 3 6 4 7 5 3 6 2 7 0 8 4 9 6 10 2 11 3 12 7 13 5 14 1 15 5 16 7 17 6 18 4 19
196 |
197 |
198 |
199 |
200 | 4
201 | 0 20 2 21 3 22 1 23
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 | -141.666 92.4958 296.3
210 | 0 1 0 -26
211 | 1 0 0 -15.1954
212 | 0 0 1 0
213 |
214 |
215 |
216 | -325 225 400
217 | 0 0 1 0
218 | 0 1 0 0
219 | 1 0 0 0
220 |
221 |
222 |
223 | 0 0 1 0
224 | 0 1 0 0
225 | 1 0 0 0
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 | -141.666 92.4958 296.3
237 | 0 1 0 -26
238 | 1 0 0 -15.1954
239 | 0 0 1 0
240 |
241 |
242 |
243 | 3 4 10
244 | 0 0 1 0
245 | 0 1 0 0
246 | 1 0 0 0
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/1.4.1/infiles/cube_triangulate.dae:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | alorino
5 | Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11
6 | Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
7 | curveConstrainSampling=0;exportCameraAsLookat=0;
8 | exportLights=1;exportCameras=1;exportJointsAndSkin=1;
9 | exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
10 | exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
11 | exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
12 | dereferenceXRefs=0;cameraXFov=0;cameraYFov=1
13 |
14 | Copyright 2006 Sony Computer Entertainment Inc.
15 | Licensed under the SCEA Shared Source License, Version 1.0 (the
16 | "License"); you may not use this file except in compliance with the
17 | License. You may obtain a copy of the License at:
18 | http://research.scea.com/scea_shared_source_license.html
19 | Unless required by applicable law or agreed to in writing, software
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 |
26 | 2006-06-21T21:25:37Z
27 | 2006-06-21T21:25:37Z
28 |
29 | Y_UP
30 |
31 |
32 |
33 |
34 |
35 |
36 | 37.8493
37 | 1
38 | 10
39 | 1000
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 37.8501
49 | 1
50 | 0.01
51 | 1000
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 1 1 1
62 | 1
63 | 0
64 | 0
65 |
66 |
67 |
68 |
69 |
70 |
71 | 1 1 1
72 | 1
73 | 0
74 | 0
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | 0 0 0 1
94 |
95 |
96 | 0 0 0 1
97 |
98 |
99 | 0.137255 0.403922 0.870588 1
100 |
101 |
102 | 0.5 0.5 0.5 1
103 |
104 |
105 | 10
106 |
107 |
108 | 0 0 0 1
109 |
110 |
111 | 0.5
112 |
113 |
114 | 0 0 0 1
115 |
116 |
117 | 1
118 |
119 |
120 | 0
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | 0 0 0 1
132 |
133 |
134 | 0 0 0 1
135 |
136 |
137 | 0.658824 0.101961 0.109804 1
138 |
139 |
140 | 0.368627 0.368627 0.368627 1
141 |
142 |
143 | 10
144 |
145 |
146 | 0 0 0 1
147 |
148 |
149 | 0.5
150 |
151 |
152 | 0 0 0 1
153 |
154 |
155 | 1
156 |
157 |
158 | 0
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | -50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 | 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 | 0 0 1 1 5 2 0 0 5 2 4 3 6 4 7 5 3 6 6 4 3 6 2 7 0 8 4 9 6 10 0 8 6 10 2 11 3 12 7 13 5 14 3 12 5 14 1 15 5 16 7 17 6 18 5 16 6 18 4 19
195 |
196 |
197 |
198 |
199 | 0 20 2 21 3 22 0 20 3 22 1 23
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 | -141.666 92.4958 296.3
208 | 0 1 0 -26
209 | 1 0 0 -15.1954
210 | 0 0 1 0
211 |
212 |
213 |
214 | -325 225 400
215 | 0 0 1 0
216 | 0 1 0 0
217 | 1 0 0 0
218 |
219 |
220 |
221 | 0 0 1 0
222 | 0 1 0 0
223 | 1 0 0 0
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 | -141.666 92.4958 296.3
235 | 0 1 0 -26
236 | 1 0 0 -15.1954
237 | 0 0 1 0
238 |
239 |
240 |
241 | 3 4 10
242 | 0 0 1 0
243 | 0 1 0 0
244 | 1 0 0 0
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/1.5/infiles/cube.dae:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | alorino
6 | Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11
7 | Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
8 | curveConstrainSampling=0;exportCameraAsLookat=0;
9 | exportLights=1;exportCameras=1;exportJointsAndSkin=1;
10 | exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
11 | exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
12 | exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
13 | dereferenceXRefs=0;cameraXFov=0;cameraYFov=1
14 | Copyright 2006 Sony Computer Entertainment Inc.
15 | Licensed under the SCEA Shared Source License, Version 1.0 (the
16 | "License"); you may not use this file except in compliance with the
17 | License. You may obtain a copy of the License at:
18 | http://research.scea.com/scea_shared_source_license.html
19 | Unless required by applicable law or agreed to in writing, software
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | 2006-06-21T21:25:37Z
26 | 2006-06-21T21:25:37Z
27 |
28 | Y_UP
29 |
30 |
31 |
32 |
33 |
34 |
35 | 37.8493
36 | 1
37 | 10
38 | 1000
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 37.8501
48 | 1
49 | 0.01
50 | 1000
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | 1 1 1
61 | 1
62 | 0
63 | 0
64 |
65 |
66 |
67 |
68 |
69 |
70 | 1 1 1
71 | 1
72 | 0
73 | 0
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | 0 0 0 1
93 |
94 |
95 | 0 0 0 1
96 |
97 |
98 | 0.137255 0.403922 0.870588 1
99 |
100 |
101 | 0.5 0.5 0.5 1
102 |
103 |
104 | 10
105 |
106 |
107 | 0 0 0 1
108 |
109 |
110 | 0.5
111 |
112 |
113 | 0 0 0 1
114 |
115 |
116 | 1
117 |
118 |
119 | 0
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | 0 0 0 1
131 |
132 |
133 | 0 0 0 1
134 |
135 |
136 | 0.658824 0.101961 0.109804 1
137 |
138 |
139 | 0.368627 0.368627 0.368627 1
140 |
141 |
142 | 10
143 |
144 |
145 | 0 0 0 1
146 |
147 |
148 | 0.5
149 |
150 |
151 | 0 0 0 1
152 |
153 |
154 | 1
155 |
156 |
157 | 0
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 | -50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 | 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | 4 4 4 4 4
194 | 0 0 1 1 5 2 4 3 6 4 7 5 3 6 2 7 0 8 4 9 6 10 2 11 3 12 7 13 5 14 1 15 5 16 7 17 6 18 4 19
195 |
196 |
197 |
198 |
199 | 4
200 | 0 20 2 21 3 22 1 23
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 | -141.666 92.4958 296.3
209 | 0 1 0 -26
210 | 1 0 0 -15.1954
211 | 0 0 1 0
212 |
213 |
214 |
215 | -325 225 400
216 | 0 0 1 0
217 | 0 1 0 0
218 | 1 0 0 0
219 |
220 |
221 |
222 | 0 0 1 0
223 | 0 1 0 0
224 | 1 0 0 0
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 | -141.666 92.4958 296.3
236 | 0 1 0 -26
237 | 1 0 0 -15.1954
238 | 0 0 1 0
239 |
240 |
241 |
242 | 3 4 10
243 | 0 0 1 0
244 | 0 1 0 0
245 | 1 0 0 0
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/1.5/infiles/cube_triangulate.dae:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | alorino
6 | Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11
7 | Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
8 | curveConstrainSampling=0;exportCameraAsLookat=0;
9 | exportLights=1;exportCameras=1;exportJointsAndSkin=1;
10 | exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
11 | exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
12 | exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
13 | dereferenceXRefs=0;cameraXFov=0;cameraYFov=1
14 | Copyright 2006 Sony Computer Entertainment Inc.
15 | Licensed under the SCEA Shared Source License, Version 1.0 (the
16 | "License"); you may not use this file except in compliance with the
17 | License. You may obtain a copy of the License at:
18 | http://research.scea.com/scea_shared_source_license.html
19 | Unless required by applicable law or agreed to in writing, software
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | 2006-06-21T21:25:37Z
26 | 2006-06-21T21:25:37Z
27 |
28 | Y_UP
29 |
30 |
31 |
32 |
33 |
34 |
35 | 37.8493
36 | 1
37 | 10
38 | 1000
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 37.8501
48 | 1
49 | 0.01
50 | 1000
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | 1 1 1
61 | 1
62 | 0
63 | 0
64 |
65 |
66 |
67 |
68 |
69 |
70 | 1 1 1
71 | 1
72 | 0
73 | 0
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | 0 0 0 1
93 |
94 |
95 | 0 0 0 1
96 |
97 |
98 | 0.137255 0.403922 0.870588 1
99 |
100 |
101 | 0.5 0.5 0.5 1
102 |
103 |
104 | 10
105 |
106 |
107 | 0 0 0 1
108 |
109 |
110 | 0.5
111 |
112 |
113 | 0 0 0 1
114 |
115 |
116 | 1
117 |
118 |
119 | 0
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | 0 0 0 1
131 |
132 |
133 | 0 0 0 1
134 |
135 |
136 | 0.658824 0.101961 0.109804 1
137 |
138 |
139 | 0.368627 0.368627 0.368627 1
140 |
141 |
142 | 10
143 |
144 |
145 | 0 0 0 1
146 |
147 |
148 | 0.5
149 |
150 |
151 | 0 0 0 1
152 |
153 |
154 | 1
155 |
156 |
157 | 0
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 | -50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 | 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | 0 0 1 1 5 2 0 0 5 2 4 3 6 4 7 5 3 6 6 4 3 6 2 7 0 8 4 9 6 10 0 8 6 10 2 11 3 12 7 13 5 14 3 12 5 14 1 15 5 16 7 17 6 18 5 16 6 18 4 19
194 |
195 |
196 |
197 |
198 | 0 20 2 21 3 22 0 20 3 22 1 23
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 | -141.666 92.4958 296.3
207 | 0 1 0 -26
208 | 1 0 0 -15.1954
209 | 0 0 1 0
210 |
211 |
212 |
213 | -325 225 400
214 | 0 0 1 0
215 | 0 1 0 0
216 | 1 0 0 0
217 |
218 |
219 |
220 | 0 0 1 0
221 | 0 1 0 0
222 | 1 0 0 0
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 | -141.666 92.4958 296.3
234 | 0 1 0 -26
235 | 1 0 0 -15.1954
236 | 0 0 1 0
237 |
238 |
239 |
240 | 3 4 10
241 | 0 0 1 0
242 | 0 1 0 0
243 | 1 0 0 0
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/1.5/outfiles/cube.dae:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2006-06-21T21:25:37Z
4 | Y_UP
5 |
6 | 2006-06-21T21:25:37Z
7 |
8 |
9 |
10 |
11 |
12 |
13 | alorino
14 |
15 | Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
16 | curveConstrainSampling=0;exportCameraAsLookat=0;
17 | exportLights=1;exportCameras=1;exportJointsAndSkin=1;
18 | exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
19 | exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
20 | exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
21 | dereferenceXRefs=0;cameraXFov=0;cameraYFov=1
22 |
23 | Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11
24 | Copyright 2006 Sony Computer Entertainment Inc.
25 | Licensed under the SCEA Shared Source License, Version 1.0 (the
26 | "License"); you may not use this file except in compliance with the
27 | License. You may obtain a copy of the License at:
28 | http://research.scea.com/scea_shared_source_license.html
29 | Unless required by applicable law or agreed to in writing, software
30 | distributed under the License is distributed on an "AS IS" BASIS,
31 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 | See the License for the specific language governing permissions and
33 | limitations under the License.
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 | -50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | 4 4 4 4 4
98 |
99 |
100 | 0 0 1 1 5 2 4 3 6 4 7 5 3 6 2 7 0 8 4 9 6 10 2 11 3 12 7 13 5 14 1 15 5 16 7 17 6 18 4 19
101 |
102 |
103 | 4
104 |
105 |
106 | 0 20 2 21 3 22 1 23
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | 1 1 1
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 | 1 1 1
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 | 0 0 0 1
140 |
141 |
142 | 0.137255 0.403922 0.870588 1
143 |
144 |
145 | 0 0 0 1
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 | 0.5 0.5 0.5 1
158 |
159 |
160 |
161 |
162 |
163 | 0 0 0 1
164 |
165 |
166 | 0 0 0 1
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 | 0 0 0 1
178 |
179 |
180 | 0.658824 0.101961 0.109804 1
181 |
182 |
183 | 0 0 0 1
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 | 0.368627 0.368627 0.368627 1
196 |
197 |
198 |
199 |
200 |
201 | 0 0 0 1
202 |
203 |
204 | 0 0 0 1
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/1.5/outfiles/cube_triangulate.dae:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2006-06-21T21:25:37Z
4 | Y_UP
5 |
6 | 2006-06-21T21:25:37Z
7 |
8 |
9 |
10 |
11 |
12 |
13 | alorino
14 |
15 | Collada Maya Export Options: bakeTransforms=0;exportPolygonMeshes=1;bakeLighting=0;isSampling=0;
16 | curveConstrainSampling=0;exportCameraAsLookat=0;
17 | exportLights=1;exportCameras=1;exportJointsAndSkin=1;
18 | exportAnimations=1;exportTriangles=0;exportInvisibleNodes=0;
19 | exportNormals=1;exportTexCoords=1;exportVertexColors=1;exportTangents=0;
20 | exportTexTangents=0;exportConstraints=0;exportPhysics=0;exportXRefs=1;
21 | dereferenceXRefs=0;cameraXFov=0;cameraYFov=1
22 |
23 | Maya 7.0 | ColladaMaya v2.01 Jun 9 2006 at 16:08:19 | FCollada v1.11
24 | Copyright 2006 Sony Computer Entertainment Inc.
25 | Licensed under the SCEA Shared Source License, Version 1.0 (the
26 | "License"); you may not use this file except in compliance with the
27 | License. You may obtain a copy of the License at:
28 | http://research.scea.com/scea_shared_source_license.html
29 | Unless required by applicable law or agreed to in writing, software
30 | distributed under the License is distributed on an "AS IS" BASIS,
31 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 | See the License for the specific language governing permissions and
33 | limitations under the License.
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 | -50 50 50 50 50 50 -50 -50 50 50 -50 50 -50 50 -50 50 50 -50 -50 -50 -50 50 -50 -50
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | 0 0 1 1 5 2 0 0 5 2 4 3 6 4 7 5 3 6 6 4 3 6 2 7 0 8 4 9 6 10 0 8 6 10 2 11 3 12 7 13 5 14 3 12 5 14 1 15 5 16 7 17 6 18 5 16 6 18 4 19
98 |
99 |
100 |
101 |
102 | 0 20 2 21 3 22 0 20 3 22 1 23
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | 1 1 1
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 | 1 1 1
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | 0 0 0 1
138 |
139 |
140 | 0.137255 0.403922 0.870588 1
141 |
142 |
143 | 0 0 0 1
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 | 0.5 0.5 0.5 1
156 |
157 |
158 |
159 |
160 |
161 | 0 0 0 1
162 |
163 |
164 | 0 0 0 1
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 | 0 0 0 1
176 |
177 |
178 | 0.658824 0.101961 0.109804 1
179 |
180 |
181 | 0 0 0 1
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | 0.368627 0.368627 0.368627 1
194 |
195 |
196 |
197 |
198 |
199 | 0 0 0 1
200 |
201 |
202 | 0 0 0 1
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-collada/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/xml"
5 | "log"
6 |
7 | "github.com/metaleap/go-xsd/xsd-makepkg/tests"
8 |
9 | "github.com/metaleap/go-util/dev/go"
10 |
11 | collada14 "github.com/metaleap/go-xsd-pkg/khronos.org/files/collada_schema_1_4_go"
12 | collada15 "github.com/metaleap/go-xsd-pkg/khronos.org/files/collada_schema_1_5_go"
13 | )
14 |
15 | type Col14Doc struct {
16 | XMLName xml.Name `xml:"COLLADA"`
17 | collada14.TxsdCollada
18 | }
19 |
20 | type Col15Doc struct {
21 | XMLName xml.Name `xml:"COLLADA"`
22 | collada15.TxsdCollada
23 | }
24 |
25 | func main() {
26 | var (
27 | col14DirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-collada", "1.4.1")
28 | col14MakeEmptyDoc = func() interface{} { return &Col14Doc{} }
29 | col15DirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-collada", "1.5")
30 | col15MakeEmptyDoc = func() interface{} { return &Col15Doc{} }
31 | )
32 | if false {
33 | tests.OnDocLoaded = func(doc interface{}) {
34 | if c14, ok := doc.(*Col14Doc); ok {
35 | log.Print("ISC14")
36 | for _, camLib := range c14.CamerasLibraries {
37 | log.Print("CAMLIB")
38 | for _, cam := range camLib.Cameras {
39 | log.Printf("CAM aspect: %#v\n", cam.Optics.TechniqueCommon.Perspective.AspectRatio)
40 | }
41 | }
42 | }
43 | }
44 | }
45 | tests.TestViaRemarshal(col14DirBasePath, col14MakeEmptyDoc)
46 | tests.TestViaRemarshal(col15DirBasePath, col15MakeEmptyDoc)
47 | }
48 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-kml/infiles/doc.kml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | alex-ensemle
6 | Created with <a href="http://sketchup.google.com">Google SketchUp</a>
7 | 1
8 |
9 | 233.7145392362
10 | 87.53120326691
11 | 52.52096539762
12 | 13.40971798781
13 | 105.1522961342
14 | 22.59064284836
15 |
16 |
17 | Tour
18 |
19 | Scene 2
20 | 1
21 |
22 | 231.0285112108
23 | 41.90231233603
24 | 52.52204043736
25 | 13.40778681277
26 | 637.0868613123
27 | 670.8642042001
28 |
29 |
30 |
31 | Scene 42
32 | 1
33 |
34 | 234.0405148609
35 | 1.520408311538
36 | 52.52081432939
37 | 13.4092224728
38 | 210.1809412605
39 | 394.9373575241
40 |
41 |
42 |
43 | Scene 46
44 | 1
45 |
46 | 234.2466129812
47 | 2.605111944025
48 | 52.5207992629
49 | 13.40919646551
50 | 183.4342782737
51 | 368.7598758814
52 |
53 |
54 |
55 | Scene 47
56 | 1
57 |
58 | 238.7947537832
59 | 84.34240939119
60 | 52.52088796403
61 | 13.40941294272
62 | 6.056799243995
63 | 365.081714339
64 |
65 |
66 |
67 | Szene 36
68 | 1
69 |
70 | 234.554131994
71 | 89.27332195026
72 | 52.52098778808
73 | 13.40955562159
74 | 148.3909818628
75 | 238.855030569
76 |
77 |
78 |
79 | Scene 44
80 | 1
81 |
82 | 227.3162816419
83 | 87.70627341263
84 | 52.52093605102
85 | 13.40959779432
86 | 25.94872406782
87 | 249.0964871505
88 |
89 |
90 |
91 | Scene 38
92 | 1
93 |
94 | 220.36078808
95 | 35.82549617825
96 | 52.52149635307
97 | 13.41019728414
98 | 95.27493521225
99 | 202.8693606468
100 |
101 |
102 |
103 | Scene 41
104 | 1
105 |
106 | 233.1672207281
107 | 69.61052835863
108 | 52.52125725743
109 | 13.41031016758
110 | 58.97396952365
111 | 45.50162852764
112 |
113 |
114 |
115 | model
116 | 1
117 |
118 | 233.9789798983
119 | 85.47986263808
120 | 52.52101021107
121 | 13.40979579843
122 | 54.62381406979
123 | 8.4
124 |
125 |
126 |
127 | Scene 3
128 | 1
129 |
130 | 141.339300639
131 | 84.83980862361
132 | 52.52098853519
133 | 13.41013373999
134 | 73.99573064962
135 | 8.4
136 |
137 |
138 |
139 | Scene 4
140 | 1
141 |
142 | 152.9996594078
143 | 86.38250239675
144 | 52.52058797034
145 | 13.40925371706
146 | 118.7903338535
147 | 8.4
148 |
149 |
150 |
151 | Scene 5
152 | 1
153 |
154 | 194.8245037126
155 | 78.36868187296
156 | 52.52122930214
157 | 13.40858634211
158 | 38.81220511443
159 | 13.22762788357
160 |
161 |
162 |
163 | Scene 6
164 | 1
165 |
166 | 186.9348837138
167 | 87.46036935047
168 | 52.5208678822
169 | 13.40819598555
170 | 48.60892493113
171 | 8.4
172 |
173 |
174 |
175 | Scene 8
176 | 1
177 |
178 | 96.76516656909
179 | 86.53687435254
180 | 52.52096553595
181 | 13.4098083872
182 | 147.7719734624
183 | 8.917789468056
184 |
185 |
186 |
187 | Scene 7
188 | 1
189 |
190 | 101.3360194181
191 | 85.78976589827
192 | 52.52042734034
193 | 13.40965027491
194 | 114.4541609754
195 | 8.4
196 |
197 |
198 |
199 | Scene 9
200 | 1
201 |
202 | 52.79505077617
203 | 83.62325995844
204 | 52.52082607727
205 | 13.40936275489
206 | 97.01328195934
207 | 8.4
208 |
209 |
210 |
211 | Scene 13
212 | 1
213 |
214 | 53.37277467435
215 | 68.91775444721
216 | 52.5205614986
217 | 13.40880078105
218 | 83.28377400939
219 | 34.06426604508
220 |
221 |
222 |
223 | Scene 17
224 | 1
225 |
226 | 44.52131064883
227 | 89.07749201863
228 | 52.52060175339
229 | 13.41002483182
230 | 124.2607630593
231 | 7.888213242617
232 |
233 |
234 |
235 | Scene 39
236 | 1
237 |
238 | 324.770805802
239 | 88.38601353692
240 | 52.5203440181
241 | 13.4092839739
242 | 72.63987643487
243 | 8.124052723933
244 |
245 |
246 |
247 | Scene 40
248 | 1
249 |
250 | 318.8456450499
251 | 89.43307969644
252 | 52.52048522322
253 | 13.40959793783
254 | 73.52704856209
255 | 7.967360654994
256 |
257 |
258 |
259 | Scene 18
260 | 1
261 |
262 | 285.571620949
263 | 87.79183918239
264 | 52.52034733142
265 | 13.40988962647
266 | 51.69084933439
267 | 9.391816918987
268 |
269 |
270 |
271 | Scene 23
272 | 1
273 |
274 | 117.4969912319
275 | 29.11020814674
276 | 52.52059448276
277 | 13.40949533884
278 | 255.2893669053
279 | 48.88635313853
280 |
281 |
282 |
283 | Scene 45
284 | 1
285 |
286 | 118.0962236336
287 | 21.84203944706
288 | 52.520601307
289 | 13.40957627757
290 | 231.9339444059
291 | 38.0173635574
292 |
293 |
294 |
295 | Scene 43
296 | 1
297 |
298 | 113.2817834754
299 | 14.52650316965
300 | 52.52073906053
301 | 13.4095095867
302 | 79.67600099932
303 | 99.53973409449
304 |
305 |
306 |
307 | Scene 48
308 | 1
309 |
310 | 112.1626417613
311 | 35.81543413712
312 | 52.5205624483
313 | 13.40987714907
314 | 368.9730384293
315 | 113.8871010178
316 |
317 |
318 |
319 | Scene 25
320 | 1
321 |
322 | 358.1223590418
323 | 65.83834128503
324 | 52.52073941289
325 | 13.40985555524
326 | 38.27862031646
327 | 25.12201278608
328 |
329 |
330 |
331 | Scene 24
332 | 1
333 |
334 | 41.80349781356
335 | 82.24998162917
336 | 52.52081939525
337 | 13.40985456748
338 | 41.99669832581
339 | 8.4
340 |
341 |
342 |
343 | Scene 26
344 | 1
345 |
346 | 46.45393100387
347 | 88.45816145551
348 | 52.52078933308
349 | 13.40996255537
350 | 2.236196288613
351 | 7.276953428368
352 |
353 |
354 |
355 | Scene 27
356 | 1
357 |
358 | 337.7863673095
359 | 85.00063272226
360 | 52.52086853442
361 | 13.41007245514
362 | 14.7807937038
363 | 8.477762090279
364 |
365 |
366 |
367 | Scene 36
368 | 1
369 |
370 | 322.2839022828
371 | 87.06605646191
372 | 52.52088958073
373 | 13.41010476858
374 | 0.2985695275778
375 | 7.15
376 |
377 |
378 |
379 | Scene 28
380 | 1
381 |
382 | 264.3063088688
383 | 87.06351290917
384 | 52.52098378121
385 | 13.40973793114
386 | 27.29073199542
387 | 7.15
388 |
389 |
390 |
391 | Scene 30
392 | 1
393 |
394 | 263.9783559441
395 | 88.96951942219
396 | 52.52110923132
397 | 13.40979534166
398 | 23.43156795038
399 | 7.15
400 |
401 |
402 |
403 | Scene 37
404 | 1
405 |
406 | 261.3927384415
407 | 87.01363337846
408 | 52.52110628525
409 | 13.40995129256
410 | 37.7627991075
411 | 7.15
412 |
413 |
414 |
415 | Scene 31
416 | 1
417 |
418 | 234.9740719742
419 | 88.55362889221
420 | 52.52095860361
421 | 13.40969181882
422 | 164.9351330775
423 | 7.918353335037
424 |
425 |
426 |
427 | Scene 29
428 | 1
429 |
430 | 234.0057854045
431 | 64.02535108975
432 | 52.52133004464
433 | 13.41043662907
434 | 104.9612034507
435 | 85.57890273515
436 |
437 |
438 |
439 | Scene 33
440 | 1
441 |
442 | 231.0285112108
443 | 41.90231233603
444 | 52.52204043736
445 | 13.40778681277
446 | 637.0868613123
447 | 670.8642042001
448 |
449 |
450 |
451 | Scene 34
452 | 1
453 |
454 | 231.0285112108
455 | 41.90231233603
456 | 52.52204043736
457 | 13.40778681277
458 | 637.0868613123
459 | 670.8642042001
460 |
461 |
462 |
463 | Scene 32
464 | 1
465 |
466 | 231.0285112108
467 | 41.90231233603
468 | 52.52204043736
469 | 13.40778681277
470 | 637.0868613123
471 | 670.8642042001
472 |
473 |
474 |
475 |
476 | Model
477 |
478 |
479 |
480 | relativeToGround
481 |
482 | 52.52048719573
483 | 13.40949134166
484 | 0
485 |
486 |
487 | -0
488 | 0
489 | 0
490 |
491 |
492 | 1
493 | 1
494 | 1
495 |
496 |
497 | models/untitled.dae
498 |
499 |
500 |
501 |
502 |
503 |
504 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-kml/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/xml"
5 |
6 | "github.com/metaleap/go-xsd/xsd-makepkg/tests"
7 |
8 | "github.com/metaleap/go-util/dev/go"
9 |
10 | kml "github.com/metaleap/go-xsd-pkg/schemas.opengis.net/kml/2.2.0/ogckml22.xsd_go"
11 | )
12 |
13 | type KmlDoc struct {
14 | XMLName xml.Name `xml:"http://www.opengis.net/kml/2.2 kml"`
15 | kml.TKmlType
16 | }
17 |
18 | func main() {
19 | var (
20 | dirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-kml")
21 | makeEmptyDoc = func() interface{} { return &KmlDoc{} }
22 | )
23 | tests.TestViaRemarshal(dirBasePath, makeEmptyDoc)
24 | }
25 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-rss/infiles/go-ngine-blog.rss:
--------------------------------------------------------------------------------
1 |
2 | DevBlog - go:ngine http://go-ngine.com/blog/Sun, 28 Oct 2012 14:53:48 +0000 en-US Site Server v6.0.0 (http://www.squarespace.com) Now even works under Mac OS X... Engine dev progress go:ngine Sun, 28 Oct 2012 14:48:54 +0000 http://go-ngine.com/blog/2012/10/28/now-even-works-under-mac-os-x507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508d45dbe4b09d6a6297afa2 under OpenGL 3.2 core profile only, that is. Of course. That means some rather recent version of OS X required -- not the latest but perhaps the one before -- not sure right now which version introduced OpenGL 3.2 for Mac users. Surreal feel to see my OpenGL Go code running as a native binary under OS X :)
]]>Yay, finally some decent timing stats! Engine dev progress go:ngine Sun, 28 Oct 2012 08:05:05 +0000 http://go-ngine.com/blog/2012/10/28/yay-finally-some-decent-timing-stats507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508ce732e4b0b3e60effe78f Now we're talking milliseconds and nanoseconds! ]]> Hashing uints in Go Coding Go Development go:ngine Sat, 27 Oct 2012 05:20:37 +0000 http://go-ngine.com/blog/2012/10/27/hashing-uints-in-go507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508b6f24e4b01df2979e331e So I needed to hash three unsigned integers into one integer value uniquely identifying that particular combination of uints, to be used as a "hash key" in a map[int]sometype .Simple arithmetics (add or mult) are out to uniquely hash different combinations: the set 1,2,4 should produce a different hash key than 1,4,2 and 2,1,4 and 2,4,1 and 4,1,2 and 4,2,1.
Found Robert Jenkins' 96 bit Mix Function with a neat source snippet right there (Java). Implemented in Go and seems to work even though I'm not sure if Golangs >> right-shift operator (spec'd as integer >> unsigned integer ) really works like Java's >>> "unsigned right shift" ...
Update: actually by now it dawned on me I can just use a [3]uint as a hash key in Golang here, which is fine in this use-case. Simplicity FTW!
But if you're curious about this topic, here's an incredible testing & comparison of hashing algos .
]]> Painless XML parsing in Go; plus, how to analyse your Go source tree for package references Coding OpenGL Go Parsing Development XML go:ngine Fri, 19 Oct 2012 15:28:54 +0000 http://go-ngine.com/blog/2012/10/19/painless-xml-parsing-in-go-plus-how-to-analyse-your-source-tree-for-package-references507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508171bce4b09ec41a87ca83 Getting seriously tricky stuff done in Go is, time and again, surprisingly simple.Here's an interesting "convoluted custom" use-case I just had while working on go:ngine . So the engine is supposed to support OpenGL versions 3.2 or higher, but during development, 99% of the time I just run under OpenGL 4.2. To stay in the flow, I don't want to consult the GL specs every time I use a GL function or enumeration. At the same time, when I push to GitHub, I'd like to make sure any and all GL function or enumeration references in all go:ngine sources are either GL 3.2 or lower, or else wrapped in some conditional logic (ie. "only go ahead here if client GL version supports it")...
So for talking to OpenGL, go:ngine uses the fantastic GoGL binding . Specifically it uses the gl42 sub-package -- don't worry, that package even works under OpenGL 3.2! --- at least, if we (A) ignore the version-related error (but not any other kind of error) returned by gl42.Init() and (B) ensure we don't use API functions or enum values newer than the detected run-time GL version. So part (A) is easy, but ensuring (B) at all times (when mostly I happily develop using just my 4.2-capable GPU) could over time become an issue. What to do?
Ideally, I'd have a simple code checker tool that I would run just occasionally -- every other week, or right before major commits. It would:
run over the entire go:ngine code-base for each .go source file, collect all its references to the gl42 package record the name of every gl42 function or enum value referenced (ignoring GL types here since from what I gather none have been added ever since 3.2) then for each such tracked reference, check a GL Specification XML file for the minimum version that would support it if the version for the func/enum reference is 3.2 or lower, ignore it otherwise, keep it and later show a summary like this: GL v4.2 used 4x: function TexStorage2D: c:\gd\src\github.com\go3d\go-util\gl\buffers.go c:\gd\src\github.com\go3d\go-util\gl\textures.go function TexStorage3D: c:\gd\src\github.com\go3d\go-util\gl\textures.go enum ATOMIC_COUNTER_BUFFER: c:\gd\src\github.com\go3d\go-util\gl\buffers.go c:\gd\src\github.com\go3d\go-util\gl\counters.go function TexStorage1D: c:\gd\src\github.com\go3d\go-util\gl\textures.go GL v4.0 used 2x: enum TESS_CONTROL_SHADER: c:\gd\src\github.com\go3d\go-ngine\client\glcore\shaders.go enum TESS_EVALUATION_SHADER: c:\gd\src\github.com\go3d\go-ngine\client\glcore\shaders.go The above is actually real output of said tool, because I just wrote it today in just a few hours and it's only a 100 lines or so in total! That's why I find Go amazingly fun to work with... (OK, maybe JavaScript could have done all this half the space, but I like statically-typed native-compiled code so anyway and Go's strict compiler saved me from a few bugs just right there today.)
Parsing all .go source files was surprisingly simple just working off the go/ast and go/parser package examples. Parsing the XML GL-specification file using the encoding/xml package would have been a major pain point , but before even taking the trouble to write out all XML tags as Go structs (I didn't really want to "unmarshal" anything, thanks very much...), I luckily came across the awesome go-pkg-xmlx package -- it made loading and searching the 1.4MB spec file painless and also crucially, Just-Worked right off the bat! Kudos to jteeuwen , once again great work and a superb contribution to the Go eco-system. (go:ngine also uses his Go GLFW binding , which also works a charm across platforms. Yay!) If you wanna see (or use) the code to parse the .go source tree, load the XML spec and checks any and all gogl/gl42 references across a given code-base against specific OpenGL versions, it's right here on GitHub .
]]> First post! Actually, post zero. go:ngine Thu, 18 Oct 2012 07:30:53 +0000 http://go-ngine.com/blog/2012/10/18/first-post-actually-post-zero507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:507fb02b84aebdcd9b9396e0 I'm too eager to get back to coding this thing, so I'll catch up with y'all here later (yeah, yeah)... just testing the blogging engine here. ]]>
3 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-rss/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/xml"
5 |
6 | "github.com/metaleap/go-xsd/xsd-makepkg/tests"
7 |
8 | "github.com/metaleap/go-util/dev/go"
9 |
10 | rss "github.com/metaleap/go-xsd-pkg/thearchitect.co.uk/schemas/rss-2_0.xsd_go"
11 | )
12 |
13 | type RssDoc struct {
14 | XMLName xml.Name `xml:"rss"`
15 | rss.TxsdRss
16 | }
17 |
18 | func main() {
19 | var (
20 | dirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-rss")
21 | makeEmptyDoc = func() interface{} { return &RssDoc{} }
22 | )
23 | tests.TestViaRemarshal(dirBasePath, makeEmptyDoc)
24 | }
25 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-rss/outfiles/go-ngine-blog.rss:
--------------------------------------------------------------------------------
1 |
2 |
3 | Site Server v6.0.0 (http://www.squarespace.com)
4 | -
5 |
Now even works under Mac OS X...
6 | Engine dev progress
7 | http://go-ngine.com/blog/2012/10/28/now-even-works-under-mac-os-x
8 | Sun, 28 Oct 2012 14:48:54 +0000
9 | <p>under OpenGL 3.2 core profile only, that is. Of course. That means some rather recent version of OS X required -- not the latest but perhaps the one before -- not sure right now which version introduced OpenGL 3.2 for Mac users. Surreal feel to see my OpenGL Go code running as a native binary under OS X :)<br></p><img src="http://static.squarespace.com/static/507f8e7184aebdcd9b93536a/t/508d46cce4b01df297a0fc23/1351435988930/12-10-28-mac-os-x.png?format=500w" /><br/>
10 | 507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508d45dbe4b09d6a6297afa2
11 |
12 | -
13 |
Yay, finally some decent timing stats!
14 | Engine dev progress
15 | http://go-ngine.com/blog/2012/10/28/yay-finally-some-decent-timing-stats
16 | Sun, 28 Oct 2012 08:05:05 +0000
17 | <p>Now we're talking milliseconds and nanoseconds!</p><img src="http://static.squarespace.com/static/507f8e7184aebdcd9b93536a/t/508ce760e4b01df297a08642/1351411554167/golang-3d-engine-timing-fps-tracking-benchmark.png?format=500w" /><br/>
18 | 507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508ce732e4b0b3e60effe78f
19 |
20 | -
21 |
Hashing uints in Go
22 | Coding
23 | Go
24 | Development
25 | http://go-ngine.com/blog/2012/10/27/hashing-uints-in-go
26 | Sat, 27 Oct 2012 05:20:37 +0000
27 | <p>So I needed to hash three unsigned integers into one integer value uniquely identifying that particular combination of uints, to be used as a "hash key" in a <strong>map[int]sometype</strong>.</p><p>Simple arithmetics (add or mult) are out to uniquely hash different combinations: the set 1,2,4 should produce a different hash key than 1,4,2 and 2,1,4 and 2,4,1 and 4,1,2 and 4,2,1.<br></p><p>Found Robert Jenkins' 96 bit Mix Function with a neat source snippet right there (Java). Implemented in Go and seems to work even though I'm not sure if Golangs <strong>>></strong> right-shift operator (spec'd as <strong>integer >> unsigned integer</strong>) really works like Java's <strong>>>> "unsigned right shift"</strong>...</p><p><strong>Update:</strong> actually by now it dawned on me I can just use a <strong>[3]uint</strong> as a hash key in Golang here, which is fine in this use-case. Simplicity FTW!</p><p>But if you're curious about this topic, here's an <a href="http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed/145633#145633">incredible testing & comparison of hashing algos</a>.</p><p></p>
28 | 507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508b6f24e4b01df2979e331e
29 |
30 | -
31 |
Painless XML parsing in Go; plus, how to analyse your Go source tree for package references
32 | Coding
33 | OpenGL
34 | Go
35 | Parsing
36 | Development
37 | XML
38 | http://go-ngine.com/blog/2012/10/19/painless-xml-parsing-in-go-plus-how-to-analyse-your-source-tree-for-package-references
39 | Fri, 19 Oct 2012 15:28:54 +0000
40 | <p>Getting seriously tricky stuff done in Go is, time and again, surprisingly simple.</p><p>Here's an interesting "convoluted custom" use-case I just had while working on <strong>go:ngine</strong>. So the engine is supposed to support OpenGL versions 3.2 or higher, but during development, 99% of the time I just run under OpenGL 4.2. To stay in the flow, I don't want to consult the GL specs every time I use a GL function or enumeration. At the same time, when I push to GitHub, I'd like to make sure any and all GL function or enumeration references in all go:ngine sources are either GL 3.2 or lower, or else wrapped in some conditional logic (ie. "only go ahead here if client GL version supports it")...</p><p>So for talking to OpenGL, go:ngine uses the <a href="http://github.com/chsc/gogl">fantastic GoGL binding</a>. Specifically it uses the <strong>gl42</strong> sub-package -- don't worry, that package even works under OpenGL 3.2! --- at least, <strong>if</strong> we <em>(A)</em> ignore the version-related error (but not any other kind of error) returned by <strong>gl42.Init()</strong> and <em>(B)</em> ensure we don't use API functions or enum values newer than the detected run-time GL version. So part <em>(A)</em> is easy, but ensuring <em>(B)</em> at all times (when mostly I happily develop using just my 4.2-capable GPU) could over time become an issue. What to do?<br></p><p>Ideally, I'd have a simple code checker tool that I would run just occasionally -- every other week, or right before major commits. It would:</p><ol><li>run over the entire go:ngine code-base</li><li>for each <em>.go</em> source file, collect all its references to the <strong>gl42</strong> package<br></li><li>record the name of every <strong>gl42</strong> function or enum value referenced (ignoring GL types here since from what I gather none have been added ever since 3.2)<br></li><li>then for each such tracked reference, check a <a href="http://bitbucket.org/alfonse/gl-xml-specs/downloads">GL Specification XML file</a> for the minimum version that would support it<br></li><li>if the version for the func/enum reference is 3.2 or lower, ignore it</li><li>otherwise, keep it and later show a summary like this:</li></ol><blockquote>GL v4.2 used 4x:<br> function TexStorage2D:<br> c:\gd\src\github.com\go3d\go-util\gl\buffers.go<br> c:\gd\src\github.com\go3d\go-util\gl\textures.go<br> function TexStorage3D:<br> c:\gd\src\github.com\go3d\go-util\gl\textures.go<br> enum ATOMIC_COUNTER_BUFFER:<br> c:\gd\src\github.com\go3d\go-util\gl\buffers.go<br> c:\gd\src\github.com\go3d\go-util\gl\counters.go<br> function TexStorage1D:<br> c:\gd\src\github.com\go3d\go-util\gl\textures.go<br>GL v4.0 used 2x:<br> enum TESS_CONTROL_SHADER:<br> c:\gd\src\github.com\go3d\go-ngine\client\glcore\shaders.go<br> enum TESS_EVALUATION_SHADER:<br> c:\gd\src\github.com\go3d\go-ngine\client\glcore\shaders.go</blockquote><p>The above is actually real output of said tool, because I just wrote it today in just a few hours and it's only a 100 lines or so in total! That's why I find Go amazingly fun to work with... (OK, maybe JavaScript could have done all this half the space, but I like statically-typed native-compiled code so anyway and Go's strict compiler saved me from a few bugs just right there today.)<br></p><ul><li>Parsing all <em>.go</em> source files was surprisingly simple just working off the <a href="http://golang.org/pkg/go/ast/">go/ast</a> and <a href="http://go-ngine.com#">go/parser</a> package examples.</li><li> Parsing the XML GL-specification file using the <a href="http://golang.org/pkg/encoding/xml/">encoding/xml</a> package <strong>would have been a major pain point</strong>, but before even taking the trouble to write out all XML tags as Go structs (I didn't <em>really</em> want to "unmarshal" anything, thanks very much...), I luckily came across the awesome <a href="http://github.com/jteeuwen/go-pkg-xmlx">go-pkg-xmlx</a> package -- it made loading and searching the 1.4MB spec file painless and also crucially, <strong>Just-Worked</strong> right off the bat! Kudos to <a href="http://github.com/jteeuwen/">jteeuwen</a>, once again great work and a superb contribution to the Go eco-system. (go:ngine also uses his <a href="http://github.com/go-gl/glfw">Go GLFW binding</a>, which also works a <em>charm</em> across platforms. Yay!)<br></li></ul><p>If you wanna see (or use) the code to parse the .go source tree, load the XML spec and checks any and all <strong>gogl/gl42</strong> references across a given code-base against specific OpenGL versions, <a href="http://github.com/metaleap/go-ngine/tree/master/_tools/gl_imp_parser_version_checker">it's right here on GitHub</a>.<br></p>
41 | 507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:508171bce4b09ec41a87ca83
42 |
43 | -
44 |
First post! Actually, post zero.
45 | http://go-ngine.com/blog/2012/10/18/first-post-actually-post-zero
46 | Thu, 18 Oct 2012 07:30:53 +0000
47 | <p>I'm too eager to get back to coding this thing, so I'll catch up with y'all here later (yeah, yeah)... just testing the blogging engine here.<br></p>
48 | 507f8e7184aebdcd9b93536a:507f8e7184aebdcd9b93538c:507fb02b84aebdcd9b9396e0
49 |
50 | en-US
51 | DevBlog - go:ngine
52 | http://go-ngine.com/blog/
53 |
54 | Sun, 28 Oct 2012 14:53:48 +0000
55 |
56 |
57 |
--------------------------------------------------------------------------------
/xsd-makepkg/tests/xsd-test-svg/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "encoding/xml"
5 |
6 | "github.com/metaleap/go-xsd/xsd-makepkg/tests"
7 |
8 | "github.com/metaleap/go-util/dev/go"
9 |
10 | svg "github.com/metaleap/go-xsd-pkg/www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd_go"
11 | )
12 |
13 | type SvgDoc struct {
14 | XMLName xml.Name `xml:"svg"`
15 | svg.TsvgType
16 | }
17 |
18 | func main() {
19 | var (
20 | dirBasePath = udevgo.GopathSrcGithub("metaleap", "go-xsd", "xsd-makepkg", "tests", "xsd-test-svg")
21 | makeEmptyDoc = func() interface{} { return &SvgDoc{} }
22 | )
23 | tests.TestViaRemarshal(dirBasePath, makeEmptyDoc)
24 | }
25 |
--------------------------------------------------------------------------------
/xsd-schema.go:
--------------------------------------------------------------------------------
1 | package xsd
2 |
3 | import (
4 | "bytes"
5 | "encoding/xml"
6 | "fmt"
7 | "io"
8 | "io/ioutil"
9 | "os"
10 | "path"
11 | "path/filepath"
12 | "strings"
13 |
14 | "github.com/metaleap/go-util/fs"
15 | "github.com/metaleap/go-util/net"
16 | "github.com/metaleap/go-util/str"
17 | )
18 |
19 | const (
20 | goPkgPrefix = ""
21 | goPkgSuffix = "_go"
22 | protSep = "://"
23 | xsdNamespaceUri = "http://www.w3.org/2001/XMLSchema"
24 | )
25 |
26 | var (
27 | loadedSchemas = map[string]*Schema{}
28 | )
29 |
30 | type Schema struct {
31 | elemBase
32 |
33 | XMLName xml.Name `xml:"schema"`
34 | XMLNamespacePrefix string `xml:"-"`
35 | XMLNamespaces map[string]string `xml:"-"`
36 | XMLIncludedSchemas []*Schema `xml:"-"`
37 | XSDNamespacePrefix string `xml:"-"`
38 | XSDParentSchema *Schema `xml:"-"`
39 |
40 | hasAttrAttributeFormDefault
41 | hasAttrBlockDefault
42 | hasAttrElementFormDefault
43 | hasAttrFinalDefault
44 | hasAttrLang
45 | hasAttrId
46 | hasAttrSchemaLocation
47 | hasAttrTargetNamespace
48 | hasAttrVersion
49 | hasElemAnnotation
50 | hasElemsAttribute
51 | hasElemsAttributeGroup
52 | hasElemsComplexType
53 | hasElemsElement
54 | hasElemsGroup
55 | hasElemsInclude
56 | hasElemsImport
57 | hasElemsNotation
58 | hasElemsRedefine
59 | hasElemsSimpleType
60 |
61 | loadLocalPath, loadUri string
62 | }
63 |
64 | func (me *Schema) allSchemas(loadedSchemas map[string]bool) (schemas []*Schema) {
65 | schemas = append(schemas, me)
66 | loadedSchemas[me.loadUri] = true
67 | for _, ss := range me.XMLIncludedSchemas {
68 | if v, ok := loadedSchemas[ss.loadUri]; ok && v {
69 | continue
70 | }
71 | schemas = append(schemas, ss.allSchemas(loadedSchemas)...)
72 | }
73 | return
74 | }
75 |
76 | func (me *Schema) collectGlobals(bag *PkgBag, loadedSchemas map[string]bool) {
77 | loadedSchemas[me.loadUri] = true
78 | for _, att := range me.Attributes {
79 | bag.allAtts = append(bag.allAtts, att)
80 | }
81 | for _, agr := range me.AttributeGroups {
82 | bag.allAttGroups = append(bag.allAttGroups, agr)
83 | }
84 | for _, el := range me.Elements {
85 | bag.allElems = append(bag.allElems, el)
86 | }
87 | for _, egr := range me.Groups {
88 | bag.allElemGroups = append(bag.allElemGroups, egr)
89 | }
90 | for _, not := range me.Notations {
91 | bag.allNotations = append(bag.allNotations, not)
92 | }
93 | for _, ss := range me.XMLIncludedSchemas {
94 | if v, ok := loadedSchemas[ss.loadUri]; ok && v {
95 | continue
96 | }
97 | ss.collectGlobals(bag, loadedSchemas)
98 | }
99 | }
100 |
101 | func (me *Schema) globalComplexType(bag *PkgBag, name string, loadedSchemas map[string]bool) (ct *ComplexType) {
102 | var imp string
103 | for _, ct = range me.ComplexTypes {
104 | if bag.resolveQnameRef(ustr.PrefixWithSep(me.XMLNamespacePrefix, ":", ct.Name.String()), "T", &imp) == name {
105 | return
106 | }
107 | }
108 | loadedSchemas[me.loadUri] = true
109 | for _, ss := range me.XMLIncludedSchemas {
110 | if v, ok := loadedSchemas[ss.loadUri]; ok && v {
111 | //fmt.Printf("Ignoring processed schema: %s\n", ss.loadUri)
112 | continue
113 | }
114 | if ct = ss.globalComplexType(bag, name, loadedSchemas); ct != nil {
115 | return
116 | }
117 | }
118 | ct = nil
119 | return
120 | }
121 |
122 | func (me *Schema) globalElement(bag *PkgBag, name string) (el *Element) {
123 | var imp string
124 | if len(name) > 0 {
125 | var rname = bag.resolveQnameRef(name, "", &imp)
126 | for _, el = range me.Elements {
127 | if bag.resolveQnameRef(ustr.PrefixWithSep(me.XMLNamespacePrefix, ":", el.Name.String()), "", &imp) == rname {
128 | return
129 | }
130 | }
131 | for _, ss := range me.XMLIncludedSchemas {
132 | if el = ss.globalElement(bag, name); el != nil {
133 | return
134 | }
135 | }
136 | }
137 | el = nil
138 | return
139 | }
140 |
141 | func (me *Schema) globalSubstitutionElems(el *Element, loadedSchemas map[string]bool) (els []*Element) {
142 | var elName = el.Ref.String()
143 | if len(elName) == 0 {
144 | elName = el.Name.String()
145 | }
146 | for _, tle := range me.Elements {
147 | if (tle != el) && (len(tle.SubstitutionGroup) > 0) {
148 | if tle.SubstitutionGroup.String()[(strings.Index(tle.SubstitutionGroup.String(), ":")+1):] == elName {
149 | els = append(els, tle)
150 | }
151 | }
152 | }
153 | loadedSchemas[me.loadUri] = true
154 | for _, inc := range me.XMLIncludedSchemas {
155 | if v, ok := loadedSchemas[inc.loadUri]; ok && v {
156 | //fmt.Printf("Ignoring processed schema: %s\n", inc.loadUri)
157 | continue
158 | }
159 | els = append(els, inc.globalSubstitutionElems(el, loadedSchemas)...)
160 | }
161 | return
162 | }
163 |
164 | func (me *Schema) MakeGoPkgSrcFile() (goOutFilePath string, err error) {
165 | var goOutDirPath = filepath.Join(filepath.Dir(me.loadLocalPath), goPkgPrefix+filepath.Base(me.loadLocalPath)+goPkgSuffix)
166 | goOutFilePath = filepath.Join(goOutDirPath, path.Base(me.loadUri)+".go")
167 | var bag = newPkgBag(me)
168 | loadedSchemas := make(map[string]bool)
169 | for _, inc := range me.allSchemas(loadedSchemas) {
170 | bag.Schema = inc
171 | inc.makePkg(bag)
172 | }
173 | bag.Schema = me
174 | me.hasElemAnnotation.makePkg(bag)
175 | bag.appendFmt(true, "")
176 | me.makePkg(bag)
177 | if err = ufs.EnsureDirExists(filepath.Dir(goOutFilePath)); err == nil {
178 | err = ufs.WriteTextFile(goOutFilePath, bag.assembleSource())
179 | }
180 | return
181 | }
182 |
183 | func (me *Schema) onLoad(rootAtts []xml.Attr, loadUri, localPath string) (err error) {
184 | var tmpUrl string
185 | var sd *Schema
186 | loadedSchemas[loadUri] = me
187 | me.loadLocalPath, me.loadUri = localPath, loadUri
188 | me.XMLNamespaces = map[string]string{}
189 | for _, att := range rootAtts {
190 | if att.Name.Space == "xmlns" {
191 | me.XMLNamespaces[att.Name.Local] = att.Value
192 | } else if len(att.Name.Space) > 0 {
193 |
194 | } else if att.Name.Local == "xmlns" {
195 | me.XMLNamespaces[""] = att.Value
196 | }
197 | }
198 | for k, v := range me.XMLNamespaces {
199 | if v == xsdNamespaceUri {
200 | me.XSDNamespacePrefix = k
201 | } else if v == me.TargetNamespace.String() {
202 | me.XMLNamespacePrefix = k
203 | }
204 | }
205 | if len(me.XMLNamespaces["xml"]) == 0 {
206 | me.XMLNamespaces["xml"] = "http://www.w3.org/XML/1998/namespace"
207 | }
208 | me.XMLIncludedSchemas = []*Schema{}
209 | for _, inc := range me.Includes {
210 | if tmpUrl = inc.SchemaLocation.String(); strings.Index(tmpUrl, protSep) < 0 {
211 | tmpUrl = path.Join(path.Dir(loadUri), tmpUrl)
212 | }
213 | var ok bool
214 | var toLoadUri string
215 | if pos := strings.Index(tmpUrl, protSep); pos >= 0 {
216 | toLoadUri = tmpUrl[pos+len(protSep):]
217 | } else {
218 | toLoadUri = tmpUrl
219 | }
220 | if sd, ok = loadedSchemas[toLoadUri]; !ok {
221 | if sd, err = LoadSchema(tmpUrl, len(localPath) > 0); err != nil {
222 | return
223 | }
224 | }
225 | sd.XSDParentSchema = me
226 | me.XMLIncludedSchemas = append(me.XMLIncludedSchemas, sd)
227 | }
228 | me.initElement(nil)
229 | return
230 | }
231 |
232 | func (me *Schema) RootSchema(pathSchemas []string) *Schema {
233 | if me.XSDParentSchema != nil {
234 | for _, sch := range pathSchemas {
235 | if me.XSDParentSchema.loadUri == sch {
236 | fmt.Printf("schema loop detected %+v - > %s!\n", pathSchemas, me.XSDParentSchema.loadUri)
237 | return me
238 | }
239 | }
240 | pathSchemas = append(pathSchemas, me.loadUri)
241 | return me.XSDParentSchema.RootSchema(pathSchemas)
242 | }
243 | return me
244 | }
245 |
246 | func ClearLoadedSchemasCache() {
247 | loadedSchemas = map[string]*Schema{}
248 | }
249 |
250 | func loadSchema(r io.Reader, loadUri, localPath string) (sd *Schema, err error) {
251 | var data []byte
252 | var rootAtts []xml.Attr
253 | if data, err = ioutil.ReadAll(r); err == nil {
254 | var t xml.Token
255 | sd = new(Schema)
256 | for xd := xml.NewDecoder(bytes.NewReader(data)); err == nil; {
257 | if t, err = xd.Token(); err == nil {
258 | if startEl, ok := t.(xml.StartElement); ok {
259 | rootAtts = startEl.Attr
260 | break
261 | }
262 | }
263 | }
264 | if err = xml.Unmarshal(data, sd); err == nil {
265 | err = sd.onLoad(rootAtts, loadUri, localPath)
266 | }
267 | if err != nil {
268 | sd = nil
269 | }
270 | }
271 | return
272 | }
273 |
274 | func loadSchemaFile(filename string, loadUri string) (sd *Schema, err error) {
275 | var file *os.File
276 | if file, err = os.Open(filename); err == nil {
277 | defer file.Close()
278 | sd, err = loadSchema(file, loadUri, filename)
279 | }
280 | return
281 | }
282 |
283 | func LoadSchema(uri string, localCopy bool) (sd *Schema, err error) {
284 | var protocol, localPath string
285 | var rc io.ReadCloser
286 |
287 | if pos := strings.Index(uri, protSep); pos < 0 {
288 | protocol = "http" + protSep
289 | } else {
290 | protocol = uri[:pos+len(protSep)]
291 | uri = uri[pos+len(protSep):]
292 | }
293 | if localCopy {
294 | if localPath = filepath.Join(PkgGen.BaseCodePath, uri); !ufs.FileExists(localPath) {
295 | if err = ufs.EnsureDirExists(filepath.Dir(localPath)); err == nil {
296 | err = unet.DownloadFile(protocol+uri, localPath)
297 | }
298 | }
299 | if err == nil {
300 | if sd, err = loadSchemaFile(localPath, uri); sd != nil {
301 | sd.loadLocalPath = localPath
302 | }
303 | }
304 | } else if rc, err = unet.OpenRemoteFile(protocol + uri); err == nil {
305 | defer rc.Close()
306 | sd, err = loadSchema(rc, uri, "")
307 | }
308 | return
309 | }
310 |
--------------------------------------------------------------------------------