[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] A proposal for application level XML 'namespaces'
Dear All, Amazing Amy stirred the XML namespaces hornets' nest recently. I've been thinking about the subject too. Much of this is based on discussions that have passed before. I've come more around to David's (sorry can't remember which one) approach of not using namespaces! But to accommodate my paranoia about clashes of data, I propose making the document level element be defined as a reverse domain name, (e.g.: com.example.myschema), but then have child elements just have a local name. Therefore you would have something like: <com.example.myschema> <child>12</child> </com.example.myschema> If you use XML Schema to define your XML you'd do something like: <xs:schema xmlns:xs="..."> <xs:element name="com.example.myschema"> ... </xs:schema> To allow for shorter names the W3C would run an IANA like registry of short name prefixes, such as xml, html, svg, thus allowing document elements with <html.html>, <svg.svg> etc. All non-registry names would have to have three or more parts. References across namespaces would require the full reverse domain. For example, if your XML uses HTML you'd do: <com.example.myschema> <html.html>...</html.html> </com.example.myschema> Similarly for attributes. For example, if it was felt appropriate to bring the XML namespace under this convention (I'm not sure it is), you'd do: <com.example.myschema> <child xml.id="foo">12</child> </com.example.myschema> That's about it for element and attribute names. That leaves QNames. As a general principle I'd make QNames be reverse domain name also, for example: <myQName>com.example.value1</myQName> To allow for shorter names the XML namespace would have added to it an attribute called xml.prefixes. An xml.prefixes attribute would declare a set of {short name}/{full name} pairs, for example: xml.prefixes="ex com.example cl com.codalogic". These mappings would apply to all child elements (and their attributes) of the element it is defined in. Then when an application saw a short name in a QName (such as 'ex') it would know to expand it to its full name ('com.example'). To make it easier for an application, the schema (or similar) would define where an xml.prefixes attribute is allowed to occur. For example, you'd have to do something like: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="com.example.myschema"> <xs:complexType> ... <xs:attribute ref="xml.prefixes"/> </xs:complexType> </xs:element> ... To enable: <com.example.myschema xml.prefixes="ex com.example"> <myQName>ex.value1</myQName> </com.example.myschema> Use of xml.prefixes would be a convention that XML vocabulary writers were encouraged to use where appropriate, but wouldn't be required. It has no impact on the XML parser itself. Any thoughts? Pete Cordell Codalogic Ltd Interface XML to C++ the easy way using C++ XML data binding to convert XSD schemas to C++ classes. Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com for more info [Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|