Giter VIP home page Giter VIP logo

Comments (7)

droyo avatar droyo commented on September 4, 2024

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.

droyo avatar droyo commented on September 4, 2024

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.

droyo avatar droyo commented on September 4, 2024

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.

droyo avatar droyo commented on September 4, 2024

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.

droyo avatar droyo commented on September 4, 2024

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.

droyo avatar droyo commented on September 4, 2024

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.

junghao avatar junghao commented on September 4, 2024

Cool, it's been fixed. Thank you very much.

from go-xml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.