Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - design pattern for nested xml? >Thread Next - Re: design pattern for nested xml? Re: design pattern for nested xml?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/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
