Hi, I am generating the xmlstring from the xml document.In doing so attributes are getting sorted by attribute name when xalan.jar is placed in the classpath.If xalan.jar is not there attributes are not getting sorted.The code I used for generating attributes is as follows NamedNodeMap namedNodeMap = node.getAttributes(); for(int j=0;j<namedNodeMap.getLength();j++) { if(((Attr)namedNodeMap.item(j)).getSpecified()) System.out.println(namedNodeMap.item(j).getNodeName()); System.out.println(namedNodeMap.item(j).getNodeValue()); } I dont want the attributes to be sorted even though xalan.jar is present. Thanks in advance Bhaskar Dabbigodla
Thanks and Regards,<br />Bhaskar Dabbigodla<br />SCJP1.4 (98%)
Hi Bhaskar, What's the big deal here? Why would you want attributes to be sorted or not. That does not make sense to me. The XML specification says that attributes order is not meaningfull. No parser should rely on attributes ordering and moreover. Cheers
Bhaskar Dabbigodla
Greenhorn
Joined: Aug 02, 2002
Posts: 10
posted
0
Thank you Beno�t, Thank you very much for your reply. In my scenario I am Compressing/Decompressing an XML document. After Decompression I need to have the XML document with attributes unaltered( Attributes should not be sorted). Thanks in Advance Bhaskar Dabbigodla
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
So why would you use a XML parser in the decompression process? If using a XML parser makes sense then the ordering of attributes shouldn't. Cheers,
Bhaskar Dabbigodla
Greenhorn
Joined: Aug 02, 2002
Posts: 10
posted
0
Input and Output for my Java library is XML document.
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
You're still not saying why ordering (or rather unaltered ordering) is functionally important