Comments (7)
Reading through the xsd file, I see FloatType
defined as
<xs:complexType name="FloatType">
<xs:annotation>
<xs:documentation>
Representation of floating-point numbers used as measurements.
</xs:documentation>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="xs:double">
<xs:attribute name="unit" type="xs:string" use="optional"/>
<xs:attributeGroup ref="fsx:uncertaintyDouble"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
So, at least from my initial reading, the problem is that there is no field for the content between the tags. In this case, we should know that the content should be captured by the use of <simpleContent>
in the definition of FloatType
, so I can add a field to the xsd.SimpleType
and xsd.ComplexType
types to denote that its content is significant. However, I need to re-read the spec to determine if this covers all cases.
from go-xml.
I'm actually having some trouble coming up with what the desired type declaration would be. Presumably something like
type LatitudeBaseType struct {
Unit string `xml:"unit,attr"`
PlusError float64 `xml:"plusError,attr"`
MinusError float64 `xml:"minusError,attr"`
Value float64
}
The problem I'm having is getting the right struct tag for the encoding/xml
package to unmarshal the content into the Value
field. Here's a simplified example: https://play.golang.org/p/05LsLKSHKe
from go-xml.
It looks like this will work:
type LatitudeBaseType struct {
Unit string `xml:"unit,attr"`
PlusError float64 `xml:"plusError,attr"`
MinusError float64 `xml:"minusError,attr"`
Value float64 `xml:",chardata"`
}
from go-xml.
To answer my previous question, a complex type should capture character data when its content is made of simpleContent
or complexContent
with mixed=true
.
from go-xml.
OK, actually reading the code, it appears that I was already handling a similar case, here, where the chardata field is added if a complex type extended a simple type. However, it did not catch the case where a complex type restricted a complex type that extended a simple type. I'm getting dizzy...
from go-xml.
Hi @junghao , thanks for your patience. PR #10 should have fixed this issue. Here's a snippet of the code generated from your xsd:
// Base latitude type. Because of the limitations of schema, defining
// this type and then extending it to create the real latitude type is the only way to
// restrict values while adding datum as an attribute.
type LatitudeBaseType struct {
Value float64 `xml:",chardata"`
Unit string `xml:"unit,attr"`
PlusError float64 `xml:"plusError,attr"`
MinusError float64 `xml:"minusError,attr"`
}
Let me know if that works for you.
from go-xml.
Cool, it's been fixed. Thank you very much.
from go-xml.
Related Issues (20)
- xsdgen: gen type "measResults": Unknown built-in type "anySimpleType" HOT 6
- Timezone is not considered in MarshalText method HOT 4
- Schema with restriction and base="xsd:dateTime" HOT 1
- Unable to unmarshal embedded xhtml HOT 3
- could not find base type anySimpleType in namespace http://www.w3.org/2001/XMLSchema HOT 3
- Cannot use non-namespaced (but included) types in schema HOT 4
- complexType DetailedHashSum: could not find type "BinaryDataType" in namespace http://service.ddex.net/xml/avs/avs for element DataType HOT 3
- complexType localElement: could not find type in namespace for attribute substitutionGroup HOT 11
- utf-8 name in xsd HOT 3
- Issue with `type="xsd:date" maxOccurs="unbounded"` HOT 1
- Failed to parse chardata. HOT 2
- Element ref not generating and linking types correctly. HOT 3
- question about walking the xsd HOT 3
- Does not generate code HOT 1
- Tests generated for `gentests/books/books_test.go` do not pass
- replace rule not working to create shared types
- aqwari.net is down HOT 1
- xsdgen problem with string
- Fix simpleType length restriction
- <xsd:attribute ref="xml:space" use="required"> Reference attribute conversion failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-xml.