这是一个非常愚蠢的问题,但我不知道答案所以尽量不要傻笑太多。我正在学习如何创建 xsd 文件。我根据各种在线指南创建了一个。我不知道该怎么做(教程中从未提及)是如何在其他 xml 和 xslt 文件中引用此 xsd? xsd 未托管在网站上,我不希望它托管在网站上,因为它仅供内部使用。所以我的问题是,我该如何做到这一点?
最佳答案
有两种方法可以解决这个问题...
第一个:
<xs:import namespace="http://www.example.org/Something" schemaLocation="path/of/your/xsd/file.xsd" />
第二个:
构建目录文件以识别资源的命名空间..参见here
(例如来自 http://mojo.codehaus.org/xml-maven-plugin/examples/catalog.html )
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<public publicId="http://www.w3.org/1999/XSL/Transform" uri="./schema-for-xslt20.xsd"/>
<system systemId="http://www.example.com/sample.dtd" uri="./sample.dtd"/>
</catalog>
关于xml - 如何引用自己创建的 xsd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25210350/