Affects Version/s: 2.1.11, 2.1.12, 2.1.13, 2.2, 2.2.1, 2.2.2, 2.2.3, 2.2.3u1
Fix Version/s: None
If I have defined classes which use elements from the standard XML namespace "http://www.w3.org/XML/1998/namespace", and then run those through schemagen, schemagen will create a separate xsd for that namespace, and also include bindings for that namespace in the episode file, if I choose to generate one of those.
The problem is that this namespace is treated special in XML (including by xjc), but not by schemagen. For example, the resultant episode file is invalid because it contains a prefix mapping such as this:
That's illegal (you can't bind that namespace to any prefix other than 'xml'), and in fact, xjc knows this; xjc will reject the episode file if I try to include it in an invocation.
Furthermore, the generated schema for my own namespace now has an <xs:import> with a schemaLocation of the generated xml schema, rather than the well-defined schema location.
Since there is a well-defined schema already for this namespace (at http://www.w3.org/2001/xml.xsd), there is no reason for schemagen to generate one when it's generating a schema from source code. Instead, I think it should generate something like this:
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
...and then not generate another xsd for the items in the code.
The comments at http://www.java.net/node/645497 (5 years old) appear to agree with me.
A more generic approach would be to allow me to tell schemagen not generate xsds for certain namespaces of my choice, and instead to just insert an <xs:import> either with no schemaLocation, or with a schemaLocation of my choice (no schemaLocation would work for consumers who are using an XMLCatalog to find the appropriate schemas).