XML 架构参考

发布于 2024-09-28 00:02:19 字数 443 浏览 1 评论 0原文

我有两个 XML 模式。第一个 (A.xsd) 位于库 jar 文件 (mylib.jar) 中,第二个 (B.xsd) 位于我的项目。

我想将 A.xsd 导入 B.xsd 并通过 Jaxb2Marshaller 嵌入式验证器验证传入的 XML。

但是我无法使其正常工作:似乎 Jaxb2Marshaller 的内部 XML 验证器不理解对 jar 文件中文件的引用(我只想写一些类似 )。

如何修复它?如何从项目架构中引用库架构?

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.

I want to import A.xsd into the B.xsd and validate incoming XML via Jaxb2Marshaller embedded validator.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

愁以何悠 2024-10-05 00:02:19

查看我对上一个问题的回答,了解如何使用 ResourceResolver 来解决此问题:

您的 LSResourceResolver 实现将处理从类路径加载模式并将其转换为适当的结果。

Check out my answer to a previous question on how a ResourceResolver can be used to solve this problem:

Your implementation of LSResourceResolver will handle loading the schema from the classpath and converting it to the appropriate result.

淡紫姑娘! 2024-10-05 00:02:19

您将需要配置自己的解析器。 jaxb 中的任何内容都不会使用 classpath:。

有一个 JAXB 示例展示了这类事情。

You will need to configure your own resolver. Nothing in jaxb will use classpath:.

There is a JAXB sample which shows this sort of thing.

玉环 2024-10-05 00:02:19

类路径:不是架构位置的有效 url。您必须使用 XML 目录 从 jar 加载模式。

classpath: is not a valid url for schema location. You will have to use XML catalogs to load schemas from jars.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文