这个问题正在与谈论同样的问题,最近许多问题链接:圆形组,和微软的XSD.EXE,所以我觉得应该来回答,即使是很“老”。
这种混淆是通过为圆形组什么资格引起的。据部分3.8.6 of the XSD规格:
"Circular groups are disallowed. That is, within the {particles} of a group there must not be at any depth a particle whose {term} is the group itself."
基于上述,你的例子不是圆形组,由于该组本身不依赖于自身作为粒子。您的架构有效。
这是一个圆形的基团:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns="http://www.fixprotocol.org/ns/fast/t/1.0" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.fixprotocol.org/ns/fast/t/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="elem1">
<xsd:complexType>
<xsd:group ref="grp1"/>
</xsd:complexType>
</xsd:element>
<xsd:group name="grp1">
<xsd:sequence>
<xsd:choice>
<xsd:group ref="grp1"/>
</xsd:choice>
</xsd:sequence>
</xsd:group>
</xsd:schema>
人们不能改写正圆基。但是,您的示例可以用几种方法重写:下面的模式显示基于递归复杂类型的等效内容模型。
<?xml version="1.0" encoding="utf-8" ?>
<!-- XML Schema generated by QTAssistant/XSD Module (http://www.paschidev.com) -->
<xsd:schema xmlns="http://www.fixprotocol.org/ns/fast/t/1.0" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.fixprotocol.org/ns/fast/t/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation xmlns="">Generated from "Set1" under "Release2"</xsd:documentation>
</xsd:annotation>
<xsd:complexType name="grp1">
<xsd:sequence>
<xsd:element minOccurs="0" name="elem2" type="grp1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="elem1" type="grp1"/>
</xsd:schema>
看到下面的模式实际上适用于xsd也是“有趣的”。exe:
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema xmlns="http://www.fixprotocol.org/ns/fast/t/1.0" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.fixprotocol.org/ns/fast/t/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation xmlns="">Generated from "Set1" under "Release2"</xsd:documentation>
</xsd:annotation>
<xsd:element name="elem1">
<xsd:complexType>
<xsd:group ref="grp1"/>
</xsd:complexType>
</xsd:element>
<xsd:group name="grp1">
<xsd:sequence>
<xsd:element minOccurs="0" name="elem2">
<xsd:complexType>
<xsd:group ref="grp1"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:group>
</xsd:schema>
从XML实例的角度来看,所有三个有效的模式是等价的。
什么是XSD.EXE错误? – 2010-11-02 19:03:49
错误:为模式'tmp'生成类时出错。 - 来自targetNamespace的组'grp2'='...'的定义无效:循环组引用。 如果这是一个XSD错误,我可以尝试联系负责它的组织,并告诉他们一个错误。如果没有,我会尝试找到一个替代的代码生成器,或尝试修复单声道的xsd.exe中的错误(挂起而不是显示错误)。 – Yurik 2010-11-03 14:30:39