Closed vog closed 7 years ago
First analysis:
The main issue is the xsPrefix
property in class SchemaProcessor
. That one is supposed to contain "the one" XSD namespace prefix. Fortunately, it is only really used in two methods:
build_list()
getBuiltInType()
I propose to get rid of xsPrefix
.
This is straight forward in getBuiltInType()
: Just split the QName type
into prefix and localname, lookup the prefix in this.localNamespaces
and compare with this.xsdManager.xsNS
. In other words, handle the QName the same way as extractName()
does, perhaps moving common code into a third method.
However, I'm not sure about build_list()
. It seems to me that the following line:
definition.type = this.xsPrefix + "string";
is a bug and that this.xsPrefix
should be removed there anyway:
definition.type = "string";
@bbpennel What do you think?
@vog I think I agree with your analysis, we should be able to remove this.xsPrefix
, it appears to be a redundant shortcut. And I agree that the usage in build_list()
appears to be a bug. Do you wish to make a pull request for this?
I'll provide a pull request, as I did for the other issues. I just wanted to assure myself that I'm on the right track.
The following valid XML schema:
produces the following error message:
Here, namespace 3 is mapped to
http://www.w3.org/2001/XMLSchema
. It seems thatxsd2json
does not recognizexs:string
as internal XML Schema type.A similar situation occurs if the second namespace definition maps the default namespace, i.e.
xmlns:xs2="http://www.w3.org/2001/XMLSchema"
is replaced withxmlns="http://www.w3.org/2001/XMLSchema"
.Workarounds: