我正在尝试编写一个xsd,以便可以在运行时向其中插入另一个xml (我有一个xsd )文件。我不想为了引用它而导入xsd定义-我想为xml文件提供一个占位符,以便在运行时将其视为xml文档的一部分。
我正在尝试的内容如下:
<?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<!DOCTYPE doc [
<!ENTITY FilterPassbandDefinitions PUBLIC "passband-lookup.xml" "">
]>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="pathmapping" xmlns:pm="pathmapping">
<xs:element name="pathMapping">
<xs:complexType>
<xs:sequence>
<xs:element name="paths" type="pm:Path" minOccurs="1" maxOccurs="unbounded" />
<xs:element name="technologies" type="pm:Technology" minOccurs="1" maxOccurs="unbounded" />
<xs:element name="devices" type="pm:Device" minOccurs="1" maxOccurs="unbounded" />
<xs:element name="arrayPanel" type="pm:ArrayPanel" minOccurs="1" maxOccurs="unbounded" />
&FilterPassbandDefinitions;
</xs:sequence>
</xs:complexType>
</xs:element>但是在尝试验证xsd时,我得到了以下抱怨:“'standalone = "no”‘组件上不允许更多的伪属性。
如果我去掉'standalone = "no“‘,我会得到如下信息:”内容中不允许使用DOCTYPE“
提前谢谢。
编辑18-03-21:
我有这两个xml文件,eclipse似乎没有什么可抱怨的。它基于这个链接:Can we import XML file into another XML file?
我有以下几点:
otherFile.xml
<?xml version="1.0" encoding="UTF-8" ?>
<doc>
<foo>
<bar><baz>this is my content</baz></bar>
</foo>
</doc>test.xml:
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE doc [
<!ENTITY otherFile SYSTEM "otherFile.xml">
]>
<doc>
<foo>
<bar>&otherFile;</bar>
</foo>
</doc>我现在要做的是为这些文件定义一个xsd。
发布于 2018-03-18 17:42:10
这让我非常困惑,但是您的实体声明的系统ID为"",这是对当前文档的引用,所以实体引用&FilterPassbandDefinitions递归地拉入当前文档的副本,这是在不允许的情况下包含DOCTYPE声明。如果您将系统ID更改为指向适当的文档,则这应该是有效的。(尽管它是否真的实现了您想要做的事情是另一个问题--我想我不明白您想要做什么。)
https://stackoverflow.com/questions/49344815
复制相似问题