ra****@rogers.c om wrote:
We have a requirement for recursive elements within a XML document? Is
it possible to design it through XML Schema?
Yes, certainly.
And what are implications
using recursive elements when using DOM Parser in Java?
None in particular, of course if you do
xmlDocument.get ElementsByTagNa me('element')
or
element.getElem entsByTagName(' element')
you could end up with elements on different nesting levels then but you
can still process them in document order.
Any samples demonstrating this concept in XSD is helpful?
Here is an XML sample:
<?xml version="1.0" encoding="UTF-8"?>
<element xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "test2005031301 Xsd.xml">
<child-element />
<element>
<childElement />
<element>
<element />
</element>
</element>
</element>
and here the schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:element name="element">
<xs:complexType >
<xs:sequence>
<xs:any processContents ="skip" minOccurs="0" />
<xs:element ref="element" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
So you can use
<xs:element ref
to refer to the element itself.
And you need to make sure that somewhere the recursion can stop, meaning
the nested element needs to be allowed to not occur where needed for
instance with minOccurs="0".
--
Martin Honnen
http://JavaScript.FAQTs.com/