OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
XML element names (was: Ten Years Later - XML 1.0 Fifth Edition?)

On Monday 18 February 2008 11:09, Mukul Gandhi wrote: 

> Some of the directory/file names didn't conform to the XML name
> conventions. Like, some directory names started with numeric. Some
> contained characters like - (hyphen), ~ etc.
> Would somebody agree with me, that XML names should allow such rules?
> My problem could serve as a use case ...


I think the rule of thumb in developing your XML schema is to name elements 
after your object types and represent object properties as element content, 
either attributes or elements. So, most people would design xml as
<dir name="..."/> and <file name="..."/>. Imagine flikr or picasaweb XML, 
they'll go for <album title="..."/> and <picture caption="..."/>. This way 
they can preserve user chosen title and caption.

If you design your XML as dir/@name and file/@name, it would make your XPath 
queries look natural, making it easier to search your XML and write an 
stylesheet for HTML rendering. For example, to find directories with 
pictures, you would use XPath "dir[contains(file/@name, '.jpg')]"
or convert a file to a table row, you would write the following template:

<xsl:template match="file">
  <tr><td><xsl:value-of select="@name"/></td></tr>

Nicholas Sushkin, Senior Software Engineer
http://www.openfinance.com http://www.wealthinformationexchange.com


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS