L
lawpoop
I have two questions about the 'best' way to design an xml document.
The first is about tagging a collection of similar items as such, and
the other is about a nested structure.
I'm designing an app that can handle an arbitrary tree of a company's
organizational structure. Offices are actual physical locations, while
regions are nestable logical groupings of the offices.
When a region has office(s) as children, I've include the office tags
in <offices></offices>. However, I don't include nested regions in
<regions></regions> tags. Should I? Why or why not? I've noticed that
Michael Kay seems to always enclose repeating items in collection
tags, while other examples don't.
Here's an example.
<company>
<region>
<name>Northeast</name>
<region>
<name>New York</name>
<offices>
<office>
<name>New York Office</name>
<address>...</address>
</office>
<office>
<name>Albany</name>
<address>...</address>
<office>
</offices>
</region>
<region>
<name>Boston</name>
</region>
<region>
<name>Newark</name>
</region>
<region>
<name>Gulf Coast</name>
<region>
<name>Dallas</name>
</region>
<region>
<name>Dallas</name>
</region>
</region>
</company>
As far as my second question, if I should enclose any set of regions
in <regions></regions> tags, then shouldn't I include the entire tree
in <regions></regions> tags? In that case, couldn't I replace
<company>, or must the root node always be unique, even with nested
xmls?
The first is about tagging a collection of similar items as such, and
the other is about a nested structure.
I'm designing an app that can handle an arbitrary tree of a company's
organizational structure. Offices are actual physical locations, while
regions are nestable logical groupings of the offices.
When a region has office(s) as children, I've include the office tags
in <offices></offices>. However, I don't include nested regions in
<regions></regions> tags. Should I? Why or why not? I've noticed that
Michael Kay seems to always enclose repeating items in collection
tags, while other examples don't.
Here's an example.
<company>
<region>
<name>Northeast</name>
<region>
<name>New York</name>
<offices>
<office>
<name>New York Office</name>
<address>...</address>
</office>
<office>
<name>Albany</name>
<address>...</address>
<office>
</offices>
</region>
<region>
<name>Boston</name>
</region>
<region>
<name>Newark</name>
</region>
<region>
<name>Gulf Coast</name>
<region>
<name>Dallas</name>
</region>
<region>
<name>Dallas</name>
</region>
</region>
</company>
As far as my second question, if I should enclose any set of regions
in <regions></regions> tags, then shouldn't I include the entire tree
in <regions></regions> tags? In that case, couldn't I replace
<company>, or must the root node always be unique, even with nested
xmls?