Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: design pattern for nested xml?

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 8/4/2009 12:18:00 PM
lawpoop wrote:
> 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.

In my view you should at least be consistent in one XML document format 
so use offices to wrap office elements and use regions to wrap region 
elements or don't do it at all. Using one style for a part of the 
document and a different for another is confusing.

> 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?

You need to have a single root element but the name does not have to be 
unique.

-- 

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent