XML中的递归元素
我试图在XML模式中设计和实现一个递归元素,但总体上我对XML不是很在行。关于如何设计它有什么想法吗?下面的模型基于一种创作风格,其中元素声明是全局的,递归性是通过引用元素定义实现的XML中的递归元素,xml,xsd,Xml,Xsd,我试图在XML模式中设计和实现一个递归元素,但总体上我对XML不是很在行。关于如何设计它有什么想法吗?下面的模型基于一种创作风格,其中元素声明是全局的,递归性是通过引用元素定义实现的 <?xml version="1.0" encoding="utf-8" ?> <!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="recursive">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
或者,您可以通过重新使用类型来实现相同的功能:
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="recursive" type="Trecursive"/>
<xsd:complexType name="Trecursive">
<xsd:sequence>
<xsd:element name="recursive" type="Trecursive" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
或者,您可以选择介于两者之间的某个位置:
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="recursive" type="Trecursive"/>
<xsd:complexType name="Trecursive">
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
有效的XML示例:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<recursive xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">
<recursive>
<recursive/>
</recursive>
</recursive>
下面的模型基于一种创作风格,其中元素声明是全局的,递归性是通过引用元素定义实现的
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="recursive">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
或者,您可以通过重新使用类型来实现相同的功能:
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="recursive" type="Trecursive"/>
<xsd:complexType name="Trecursive">
<xsd:sequence>
<xsd:element name="recursive" type="Trecursive" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
或者,您可以选择介于两者之间的某个位置:
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="recursive" type="Trecursive"/>
<xsd:complexType name="Trecursive">
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
有效的XML示例:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<recursive xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">
<recursive>
<recursive/>
</recursive>
</recursive>
可能的重复可能的重复