Giter VIP home page Giter VIP logo

Comments (10)

kortschak avatar kortschak commented on September 4, 2024 1

I have a case where all the files necessary are available in a single directory. Handing xsdgen the paths to all of the xsd files fails to result in a successful codegen; doing schema surgery and manually inlining the includes in the root does give a successful result.

$ xsdgen -v *.xsd
complexType parent: could not find type id-type in namespace http://www.gexf.net/1.2draft for attribute for

Am I missing something here? or is this not expected to work?

from go-xml.

droyo avatar droyo commented on September 4, 2024

The current handling of imports is a bit of a hack. The xsdgen tool requires that you provide paths to all required files on the command line, including files imported by an XSD, and imports of imports and so on. #35 is open to have a utility to retrieve those files recursively.

So as far as I can tell, you should be able to generate code for your schema, you will just have to go through the extremely tedious process of acquiring and referencing all of the relevant XSD files. If that is feasible, you can try that and let me know if it doesn't work. If it does work we can mark this issue as a duplicate of #35.

from go-xml.

droyo avatar droyo commented on September 4, 2024

This is expected to work. Looking at your example I see "id-type" defined in gexf.xsd, under targetNamespace "http://www.gexf.net/1.2draft", defined here. It's then used in data.xsd.

I believe what is happening is that the same targetNamespace is split across multiple files. The way xsd.Parse works, it expects for a targetNamespace to be fully defined within a single file. In short, I'm not properly handling the <include> statement: https://www.w3.org/TR/xmlschema-1/#compound-schema

There is a step during the xsd parsing process, resolvePartialTypes, that looks up types like id-type. I think the way forward is to pull this step out of the per-document parsing, and defer it to the very end, after all documents have been parsed.

from go-xml.

aaronmmanzano avatar aaronmmanzano commented on September 4, 2024

I believe I've handled the splitting of namespaces across files in my PR. I'm sure it needs work, and you may prefer it be handled in another manner else where within the logic, but it may be a start.

from go-xml.

davidalpert avatar davidalpert commented on September 4, 2024

this is an older issue but I ran into the same problem. I took a crack at resolving it on a local branch by:

  • added an -f flag to the xsdgen CLI app to toggle on following schemas;
  • updated the read file logic so that when the follow schema flag is set it will call xsd.Imports(..) on each file as it's read, recursively reading in those files (and their imports) so that all the imported schema files are all in memory;
  • added a MergeTypes() method to the xsd.Schema type to merge types so long as the target namespaces are equivalent;
  • updated the parse logic to merge schema types by target namespace rather than overwrite them, allowing all the imported types from a given target namespace to collect into a single xsd.Schema object;

this seems to work, as it satisfies the assumptions of the resolvePartialTypes method, that all type resolution can happen within a single xsd.Schema object.

if this approach seems reasonable I am happy to offer these changes as a pull request for consideration.

from go-xml.

davidalpert avatar davidalpert commented on September 4, 2024

I didn't find the PR that @aaronmmanzano mentioned until this morning, I assume that #72 is it? I'm going to have a look through to catch up on what I missed in the conversation and see how I can help.

from go-xml.

davidalpert avatar davidalpert commented on September 4, 2024

PR #72 has some merge conflicts with master in parse.go which are complex enough that I don't want to get it wrong.

In the meantime, here are a pair of PRs, separated as I think they serve different purposes, for consideration:

  • #131 optionally follow imports in xsd files
  • #132 teach xsd.Schema how to merge type maps

from go-xml.

droyo avatar droyo commented on September 4, 2024

I merged #131 but I am doing some research and apparently it is valid to have import cycles. Or, at least, it is not explicitly invalid. I have not worked with a wide range of XSD files; does anyone have an idea how common circular imports are? #131 will have an infinite loop on such input.

from go-xml.

nikolawannabe avatar nikolawannabe commented on September 4, 2024

I also ran into this issue when generating code for Onix 3.0.

For me, I had to manually merge the 3 files for the generation to succeed.

from go-xml.

dalcorta avatar dalcorta commented on September 4, 2024

I suggest using fixtrading.org XSD since it is very complex.
I downloaded it from https://www.fixtrading.org/standards/fixml/
fixmlschema_FIX.Latest_EP286.zip

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.