JiBX: How to run codegen on a schema that imports into the no-namespace schema
I have a schema here where I am trying to include/import another schema that has no namespace (and this cannot be changed because it comes from another vendor and it would no longer validate their XML). Here is the first Schema:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:samp="http://sample/namespace"
targetNamespace="http://sample/namespace"
elementFormDefault="unqualified" attributeFormDefault="unqualified"
xmlns:otr1="http://sample/import/namespace1"
xmlns:otr2="http://sample/import/namespace2">
<xs:import namespace="http://sample/import/namespace1" schemaLocation="other1.xsd" />
<xs:import namespace="http://sample/import/namespace2" schemaLocation="other2.xsd" />
<!-- This one below is having problems, it is valid XML, and I am able to use it
but I am not meeting the actual requirments I have (explained later) -->
<xs:import schemaLocation=="NO_NAME_SPACE_PROBLEM.xsd"/>
...
<xs:element ref="some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA"/>
...
</xs:schema>
And the "NO_NAME_SPACE_SHEMA_PROBLEM.xsd" which can be changed to some extent, but it cannot have namespace.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xsd:element name="some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA"
type="xsd:string" nillable="true"/>
</xs:schema>
The problem I get when running JiBX codegen:
[echo] Running code generation
[java] Output to directory C:\DOCUME~1\user1\LOCALS~1\Temp\nguser\Temp-Src
[java] ERROR validation.ValidationContext - Error: Referenced element '{http://sample/namespac开发者_如何学运维e}:some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA` is not defined for element at (line 69, col 32, in parent.xsd)
[java] Terminating due to errors in input schemas
[java] Error: Referenced element '{http://sample/namespace}:some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA' is not defined for element at (line 69, col 32, in parent.xsd)
The error message for the reference to {http://sample/namespace}:some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
seems strange, as you are not referencing {http://sample/namespace}:some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
but some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
.
I can see only two options:
- You did not paste the full parent schema sample; in your actual schema you bound xmlns (i.e. without a prefix) to the sample namespace. This would explain the error message, and you could fix it by not binding xmlns.
- There is a bug in JiBX when importing schemas without a target namespace.
精彩评论