• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to order root element's attributes?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, there:

I am using the following DOM code to create a root element and set its attributes:

// add root element
org.w3c.dom.Element root = doc.createElementNS( "http://www.w3.org/2001/XMLSchema",
"xsd:root" );

root.setAttribute( "targetNamespace", "http://www.w3.org/2001/XMLSchema" );

root.setAttribute( "elementFormDefault", "qualified" );

root.setAttribute( "attributeFormDefault", "unqualified" );

root.setAttribute( "version", "1.2" );

doc.appendChild( root );



Generated results look like this:
<xsd:root attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.plmxml.org/Sample" version="1.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>

It seems the order of attributes does not exactly follow the above code.

what I want is the following:
<xsd:root xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.plmxml.org/Sample" attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.2"/>

I am wondering how I can order them?

thanks,
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XML's specification says that the order of attributes in an XML element is not significant. In other words, attributes may appear in any order. Is there some reason you think your document must satisfy some other rules?
 
Jack Wanes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
XML's specification says that the order of attributes in an XML element is not significant. In other words, attributes may appear in any order. Is there some reason you think your document must satisfy some other rules?



Thnaks. I just want to make them look better, thats all. I guess that should be ok then.
 
reply
    Bookmark Topic Watch Topic
  • New Topic