Simple XML Schema Definition snippet – hierarchy


Write a XSD for the following XML document with nested elements:

 

<?xml version=”1.0″?>

<wn:root xmlns:wn=”wn-uniqueurl”>

 <wn:item info=”item1″>

  <wn:item info=”item1.1″/>

 </wn:item>

 <wn:item info=”item2″>

  <wn:item info=”item2.1″>

   <wn:item info=”item2.1.1″/>

  </wn:item>

 </wn:item>

 <wn:item info=”item3″/>

</wn:root>

 

Here is one:

 

<?xml version=”1.0″ encoding=’ISO-8859-1′ ?>

<s:schema

 xmlns:s=’http://www.w3.org/2001/XMLSchema’

 targetNamespace=’wn-uniqueurl’

 xmlns=’wn-uniqueurl’

 elementFormDefault=’qualified’

 attributeFormDefault=’unqualified’>

 

 <s:element name=’root’ type=’rootType’ />

 <s:complexType name=’rootType’>

  <s:sequence>

   <s:element name=’item’ type=’itemType’ minOccurs=’0′ maxOccurs=’unbounded’/>

  </s:sequence>

 </s:complexType>

 <s:complexType name=’itemType’>

  <s:sequence>

   <s:element name=’item’ type=’itemType’ minOccurs=’0′ maxOccurs=’unbounded’/>

  </s:sequence>

  <s:attribute name=’info’ type=’s:string’ />

 </s:complexType>

</s:schema>

 

A technical writer would want to know more details about how to use Microsoft Office Word 2003 XML capabilities, and knowing how to write her/his own XSD helps.

 

Comments (0)