This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Recursive definition of XML Element
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Recursive definition of XML Element
- From: "Ma, Yanrui" <YMa at seisint dot com>
- Date: Wed, 10 Oct 2001 19:33:58 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Is recursive definition of XML elements allowed? I have a need for a
recursive xml element like this:
<Node process="T">
<Node process="S">
<Node process="C1">
<Node process="C2">
<Node process="P1"/>
<Node process="P2"/>
<Node process="P3"/>
</Node>
<Node process="C3">
<Node process="P4"/>
<Node process="P5"/>
<Node process="P6"/>
</Node>
</Node>
</Node>
<Node process="Y1"/>
</Node>
My corresponding schema file (.xsd) is like:
<xs:complexType name="NodeType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:choice>
<xs:element name="Node" type="NodeType"/>
<xs:element name="NodeRef">
<xs:complexType>
<xs:attribute name="name"
type="xs:string" use="optional"/>
<xs:attribute name="node"
type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Cluster">
<xs:complexType>
<xs:sequence
maxOccurs="unbounded">
<xs:element
name="Node" type="NodeType"/>
</xs:sequence>
<xs:attribute name="name"
type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="process" type="xs:string"/>
</xs:complexType>
The xml file itself can be parsed, but when parsed together with xsd
validation(using xerces/xalan), the following error happens:
"The attribute 'process' is already used in element 'Node'."
Any idea? Is the above XML valid, or is this a bug/defect of Apache parser?
If the XML is invalid, could you suggest an alternative?
Thanks,
Yanrui
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list