You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by zo...@ca.ibm.com on 2002/12/09 16:39:43 UTC

Re: problem regarding the sorting of attributes in Xalan

Whoops!  I messed up the xalan-j-users address the first time.

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   Tie Line 969-6044;  Phone (905) 413-6044
mailto:zongaro@ca.ibm.com
----- Forwarded by Henry Zongaro/Toronto/IBM on 12/09/2002 10:39 AM -----


Henry Zongaro
12/09/2002 10:05 AM


        To:     Siva Prasad Reddy <ko...@hotvoice.com>
        cc:     xalan-j-users@apache.org
        From:   Henry Zongaro/Toronto/IBM@IBMCA
        Subject:        Re: problem regarding the sorting of attributes in Xalan
 





Hi Siva,

     I'm sorry no one responded to your posting; I just searched the 
archives and actually couldn't find your original query.  If you don't get 
a response to a query within about a week, it's probably a good idea to 
post again at that point.  The delay doesn't necessarily mean that no one 
knows the answer; it could just mean that people missed the question, and 
the longer it goes, the less likely it is to generate a response.  In any 
event, I'll copy the xalan-j-users mailing list for the benefit of others.

     The order of attributes in XML is considered not to be significant 
for most purposes.  This is true in SAX and DOM and in most (if not all) 
of the XML Recommendations.  In your particular example, the 
Node.getAttributes() method returns a NamedNodeMap; according to the DOM 
Level 2 Core Recommendation "NamedNodeMaps are not maintained in any particular order".

     Although your note doesn't say, I assume you are using Xerces-J for 
your parsing, so any follow-up notes should go to the xalan-j-users 
mailing list, unless they are specifically about XSLT or XPath processing. 
 I don't believe Xerces provides a way of getting at the attributes in the 
order in which they appeared in the document, but it doesn't hurt to check 
their FAQ.

Thanks,

Henry
[1] http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1780488922
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   Tie Line 969-6044;  Phone (905) 413-6044
mailto:zongaro@ca.ibm.com




Siva Prasad Reddy <ko...@hotvoice.com>
12/09/2002 05:06 AM

 
        To:     Henry Zongaro/Toronto/IBM@IBMCA
        cc: 
        Subject:        problem regarding the sorting of attributes in Xalan

 

hai,
    This mail is sent to u after not getting a response from forums.
I have used DOM for parsing Document.After parsing while printing 
the whole document i am having a problem where in the attibutes 
are getting sorted by attribute name.Is there any solution where 
they dont get sorted.
               While using JAXP without Xalan.jar, sorting does 
not occur but if u include Xalan.jar sorting occurs.
    The code i used for generating xml string is as follows.
NamedNodeMap namedNodeMap = node.getAttributes();
for(int j=0;j<namedNodeMap.getLength();j++) {
                 if(((Attr)namedNodeMap.item(j)).getSpecified()) {
                                 System.out.println("attribute 
name"+namedNodeMap.item(j).getNodeName);
 System.out.println("attributevalue"+namedNodeMap.item(j).getNodeValue());
                 }
}

If there is any other way please suggest.Tx in advance
Thanks
 Siva



--------------------------------------------------------------------------
Global Internet phone calls, voicemail, fax, e-mail and instant messaging.
Sign-up today at http://www.hotvoice.com