Giter VIP home page Giter VIP logo

Comments (2)

droyo avatar droyo commented on September 4, 2024 1

I think I see the issue. In the xsd package, the xsd.copyEltNamesToAnonTypes function correctly only copies the element name to the complexType for the first type (in depth-first order). However, the xsdgen.UseFieldNames Option then sees that the second type is anonymous, and copies the name without checking to see if it is used elsewhere. Removing that option from DefaultOptions should do the trick.

I'm still thinking about the best fix. I wonder if the UseFieldNames option is even necessary anymore, since the xsd package is already copying element names to the anonymous types they contain (avoiding collisions).

from go-xml.

wingedrhino avatar wingedrhino commented on September 4, 2024

Thanks! Removing UseFieldNames fixed things for my use-case. And yes, I can see that other anonymous complexTypes do have proper names assigned. Only the repeat names get assigned an Anon* type.

If there's one extra optimization you could do, it is to check if these Anon* types generated and the named types they share the element name with generate the same source code within the struct (i.e, the contents of the struct {} definition are identical). I checked that a few times, anonymous types were repeated in an XSD with identical structure which could have been refactored out as a type but wasn't done and left that way for legacy reasons. This bit was really trivial to do manually though because it's a lot easier to grok Go source than XSD.

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.