Comments (10)
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.
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.
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.
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.
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 thexsdgen
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.
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.
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:
from go-xml.
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.
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.
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)
- 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.