XML 架构:用相应的架构替换导入 [英] XML Schema: replacing imports with corresponding schema
问题描述
我有一个 XML 架构,其中包含多个导入,而这些导入又包含导入.我需要生成语义相等的模式,其中所有导入都是内联的.我想替换这些:
I have a XML Schema that contains multiple imports which in turn contain imports. I need to generate semantically equal schema where all imports are inlined. I want to replace these:
<xs:import namespace="http://some.name/" schemaLocation="./path/to/it.xsd"/>
带有引用模式的内容.而且我需要将输出作为字符串,而不是某些内部表示.
with the contents of referenced schemata. And I need to get output as a string, not as some internal representation.
我尝试了 Apache Xerces,但没有找到将 XSModel 写入字符串的方法.有吗?
I tried Apache Xerces but did not find a way to write XSModel to a string. Is there?
我尝试了 Apache XmlSchema 2 但是当它写入 XML Schema 时它不会替换导入声明带架构.
I tried Apache XmlSchema 2 but when it writes XML Schema it does not replace import declarations with schema.
有什么图书馆可以做到吗?有什么建议吗?
Is there any library that can do it? Any suggestions?
谢谢.
推荐答案
xsd:include 通常可以被内联,但 xsd:import 不能.这是因为 xsd:import 用于引用不同目标命名空间的架构文档,并且您不能在同一个架构文档中拥有具有不同目标命名空间的组件.
xsd:include can usually be inlined, but xsd:import can't. That's because xsd:import is used to reference a schema document for a different target namespace, and you can't have components with different target namespaces in the same schema document.
这篇关于XML 架构:用相应的架构替换导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!