问题描述
我有两个XML Schema。第一个( A.xsd
)位于库jar文件( mylib.jar
)和第二个( mylib.jar
) code> B.xsd )在我的项目中。
I have two XML Schemas. First (A.xsd
) is located in a library jar file (mylib.jar
) and the second one (B.xsd
) is in my project.
我想导入 A.xsd
进入 B.xsd
并通过 Jaxb2Marshaller
嵌入验证器验证传入的XML。
I want to import A.xsd
into the B.xsd
and validate incoming XML via Jaxb2Marshaller
embedded validator.
但是我无法使其正常工作:似乎 Jaxb2Marshaller
的内部XML验证器不理解对文件的引用jar文件(我只想写类似< xs:import namespace =http://my/schema.xsdschemaLocation =classpath:schema.xsd>
)。
However I'm unable to make it work properly: it seems that inner XML validator of Jaxb2Marshaller
does not understand references to files in jar-files (I just want to write something like <xs:import namespace="http://my/schema.xsd" schemaLocation="classpath:schema.xsd">
).
如何解决?如何从项目模式引用库模式?
How it could be fixed? How could library schema be referenced from a project schema?
推荐答案
查看我之前关于ResourceResolver如何成为问题的答案用来解决这个问题:
Check out my answer to a previous question on how a ResourceResolver can be used to solve this problem:
- JAXB SchemaFactory source order must follow import order between schemas?
您的LSResourceResolver实现将处理从类路径加载模式并将其转换为适当的结果。
Your implementation of LSResourceResolver will handle loading the schema from the classpath and converting it to the appropriate result.
这篇关于XML Schema参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!