我有这个xsd:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://myschema.com/schema"
targetNamespace="http://myschema.com/schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="aType" mixed="true">
<xs:group ref="aElements" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
<xs:group name="aElements">
<xs:choice>
<xs:element name="a" type="aType"/>
</xs:choice>
</xs:group>
<xs:element name="b">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="aElements"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
我尝试针对它验证这个xml文档:
<?xml version="1.0" encoding="utf-8" ?>
<b xmlns="http://myschema.com/schema">
<a/>
</b>
然而,Visual Studio 2008的xml验证器抱怨&lt; a&gt;元素:
命名空间“http://myschema.com/schema”中的元素“b”在命名空间“http://myschema.com/schema”中包含无效的子元素“a”。预期可能元素列表:'a'。
有什么问题?
编辑:哎呀,当我放弃示例时,我忘记在元素中使元素可选,从而导致无限递归。但是,这个模型仍然存在问题。
ANSWER :答案是xs:schema标记应包含elementFormDefault =“qualified”属性。
答案 0 :(得分:0)
您使用aElements
定义aType
,使用aType
定义aElements
。我不是xsd专家,但这应该如何工作?
答案 1 :(得分:0)
使用XSD开发编辑器可以让您的生活更轻松。我们多年来一直在使用Liquid XML Studio,它让生活变得更加轻松。