JiBX:如何在导入无命名空间架构的架构上运行 codegen
我这里有一个模式,我试图在其中包含/导入另一个没有命名空间的模式(并且不能更改它,因为它来自另一个供应商,并且它将不再验证其 XML)。这是第一个架构:
<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>
“NO_NAME_SPACE_SHEMA_PROBLEM.xsd”可以在一定程度上进行更改,但不能有命名空间。
<?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>
运行 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/namespace}: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)
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/namespace}: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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用
{http://sample/namespace}:some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
的错误消息似乎很奇怪,因为您没有引用{http://sample/namespace }:some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
但some-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
。我只能看到两个选项:
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
butsome-elem-from-NO_NAME_SPACE_PROBLEM_SCHEMA
.I can see only two options: