View Single Post
  #1 (permalink)  
Old July 21st, 2003, 07:10 AM
tandrew tandrew is offline
Registered User
 
Join Date: Jul 2003
Location: Melbourne, VIC, Australia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Document Design to represent a Hierarchy

Hi There,

I was wanting some advice regarding the best-practice approach to
representing a hierarchy in XML. Let me explain by an example of the two
different approaches I have seen.

In the first example all of the data in the document is enclosed within what
might be an ambiguous <categories> node. However on some occasions there
might be some need for this node to have some attributes. And then for
individual <category> nodes within that, they again have a <categories> node
within which child <category> nodes exist.

In the second example, the <categories> nodes are eliminated and hierarchy
is represented simply by there being <category> nodes within <category>
nodes.

Example 1

<root>
<categories>
    <category>
        ...
    </category>
    <category>
        ...
        <categories>
            <category> ... </category>
            <category> ... </category>
        </categories>
    <category>
</categories>
</root>

Example 2

<root>
<category>
    ...
</category>
<category>
    ...
    <category>
    </category>
    <category>
    </category>
</category>
</root>

What I would like guidance on is which approach would be considered
"best-practice", or are both valid in different circumstances? Additionally,
does anyone have some good references on where I could research these XML
design issues further? Are there any ramifications with regard to writing an
XSD schema for such document?

Thanks in Advance,
Trevor Andrew
Reply With Quote