droyo / go-xml

utility and code-generation libraries for XML
MIT License
304 stars 115 forks source link

could not find base type anySimpleType in namespace http://www.w3.org/2001/XMLSchema #117

Closed remiphilippe closed 3 years ago

remiphilippe commented 4 years ago

Hello, I'm trying to generate the schema for STIX 1.2 (https://github.com/STIXProject/schemas), but any schema I try (tried cybox common and common that both have anySimpletype) always fails with the error:

> xsdgen -vv common.xsd # Note common is this file: https://github.com/STIXProject/schemas/blob/master/common.xsd
read common.xsd
setting namespaces to ["http://docs.oasis-open.org/cti/ns/stix/common-1"]
complexType ControlledVocabularyStringType: could not find base type anySimpleType in namespace http://www.w3.org/2001/XMLSchema

I do see this defined in the builtins but it doesn't seem to be picked up (pretty close to this one: https://github.com/droyo/go-xml/issues/112, but not the same error). Is there an XSD I should be passing despite the builtin?

Thanks!

remiphilippe commented 4 years ago

After a bit more research, looks like anySimpleType was introduced with XSD 1.1 (https://www.liquid-technologies.com/Reference/XmlStudio/XsdEditorNotation_BuiltInXsdTypes.html), not sure if xsd 1.1 parsing is supported

StabbyCutyou commented 4 years ago

Not sure what kind of usable code it outputs, but changing this line https://github.com/droyo/go-xml/blob/master/xsd/builtin.go#L96 to "AnySimpleType" prevents this error.

droyo commented 4 years ago

@StabbyCutyou found the bug, it was an oversight in https://github.com/droyo/go-xml/commit/d7de88e1dfd94ebd3b0562f49285b7809286a360

I've made the suggested change, @remiphilippe how does it look now?