% Is it possible to represent a linked list in XML-Schema. Somthing like:
%
% <xsd:complexType name="Llist" >
% <xsd:sequence>
% <xsd:element name="content" type="xsd:string"/>
% <xsd:element name="next" type="Llist"/>
% </xsd:sequence>
% </xsd:complexType>
I wouldn't call this a linked-list representation. After all, `next'
embeds the next element of the list as content. I'd go so far as to
say it's not a correct representation of a list at all. A linked list would
assign an id to each element, and have next refer to that id
<xsd:complexType name="Llist" >
<xsd:simplecontent>
<xsd:extension base="xsd:string">
<xsd:attribute name="id" type="xsd:ID"/>
<xsd:attribute name="next" type="xsd:IDREF" minOccurs='0'/>
</xsd:extension>
</xsd:complexType>
<xsd:element name='list1' type='Llist'/>
or something like that. The XML would come out like this:
<list1 id='a' next='b'>data 1</list1>
<list1 id='b' next='c'>data 2</list1>
<list1 id='c' next='d'>data 3</list1>
<list1 id='d'>data 4</list1>
Having said that, it doesn't make any sense. A linked list makes sense
as a data structure because it simplifies the implementation of certain
algorithms and sometimes makes memory management easier, but in an XML
document, it sounds goofy, and it's much more work since you have to
keep track of all the ids. Why not make it a real list?
<xsd:complexType name="Rlist" >
<xsd:element name="item" type="xsd:string" minOccurs='0'
maxOccurs='unbounded'/>
</xsd:complexType>
<xsd:element name='list2' type='Rlist'/>
which would appear like this
<list2>
<item>data 1</item>
<item>data 2</item>
<item>data 3</item>
<item>data 4</item>
</list2>