Forum Moderators: open

Message Too Old, No Replies

Hierarchical XML Schema

Having difficulty creating this schema

         

f00sion

6:40 am on Jan 10, 2005 (gmt 0)

10+ Year Member



I have an xml document that stores categories and sub-categories as well as products in those categories. There is no limit to the depth of categories that this doc can have and im having a bit of a problem creating a schema for this one, any assitance would be greatly appreciated. Here is the sample:


<Category ParentID="0">
<Name>RC Flight Sims</Name>
<ID>52</ID>
<Category ParentID="52">
<Name>Subcat1</Name>
<ID>53</ID>
<Category ParentID="53">
<Name>category3</Name>
<ID>54</ID>
<Product ParentID="54">
<Name>Widget 1</Name>
<pID>1234</pID>
</Product>
</Category>
</Category>
<Product ParentID="52">
<Name>red widget</Name>
<pID>246</pID>
</Product>
</Category>

irnbru

4:04 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



Are you in control of the XML? If so, simplify it ...

<root>
<categories>
<Category ParentID="0">
<Name>RC Flight Sims</Name>
<ID>52</ID>
</Category>
<Category ParentID="52">
<Name>Subcat1</Name>
<ID>53</ID>
</Category>
<Category ParentID="53">
<Name>category3</Name>
<ID>54</ID>
</Category>
</categories>
<products>
<Product catID="54">
<Name>Widget 1</Name>
<pID>1234</pID>
</Product>
<Product catID="52">
<Name>red widget</Name>
<pID>246</pID>
</Product>
</products>
</root>

Your schema should then be simplified too ....

Your category tree is then related through the ID/parentID element/attribute relationship.

Your product/category relationship is via the pID/catID relationship.

HTH