By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,912 Members | 1,975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,912 IT Pros & Developers. It's quick & easy.

Specific order of text output from XML using XSLT

P: 1
Hi all,

I'm rather new to XSL (and this forum) and have searched everywhere to find out how to order the output of XML to text using XSLT but haven't found the answer.

The XML is similar to the following:
Expand|Select|Wrap|Line Numbers
  1. <table name="data">
  2. <row>
  3. <field column="groupA" type="java.lang.String">00000030</field>
  4. <field column="name" type="java.lang.String">Smith</field>
  5. <field column="name" type="java.lang.String">Smith</field>
  6. </row>
  7. <row>
  8. <field column="groupB" type="java.lang.String">00000040</field>
  9. <field column="name" type="java.lang.String">Smith</field>
  10. <field column="name" type="java.lang.String">Smith</field>
  11. <field column="name" type="java.lang.String">Smith</field>
  12. </row>
  13. <row>
  14. <field column="groupC" type="java.lang.String">00000050</field>
  15. <field column="name" type="java.lang.String">Smith</field>
  16. <field column="name" type="java.lang.String">Smith</field>
  17. <field column="name" type="java.lang.String">Smith</field>
  18. <field column="name" type="java.lang.String">Smith</field>
  19. </row>
  20. <row>
  21. <field column="clients" type="java.lang.String">00000020</field>
  22. <field column="number" type="java.lang.String">9</field>
  23. </row>
  24. <row>
  25. <field column="rows" type="java.lang.String">00000010</field>
  26. <field column="number" type="java.lang.String">3</field>
  27. </row>
  28. </table>
I won't know the number in the clients or rows until after the processing so it will always appear on the bottom of the XML, however, I need to post these at the top of the text output file. The sort function would be useful except the order of all the other elements should be as written in the XML.


If anyone can point me in the right direction or suggest a solution I would be very grateful. (Of course, if I have posted to the wrong area do let me know.)

Many thanks

Jul 23 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,639
This depends upon how you process the xml.
with XSLT you can get the number of <element-name> elements with the count() function
Expand|Select|Wrap|Line Numbers
  1. <xsl:value-of select="count('XPath-Expression')"/>
Aug 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.