XSLT, how to sort by element name

quits12

New Member
I'm a newbie in XSLT. I just come up with a question and hope someone can help.Assume I have a source xml,\[code\]<?xml version="1.0"?><docroot> <vc6>foo</vc6> <vc7>bar7</vc7> <vc8 arch="x64">amd64demo</vc8> <vc7>foo7</vc7> <vc6>bar</vc6></docroot> \[/code\]I'd like to turn it into:\[code\]<?xml version="1.0"?><docroot> <vc6>bar</vc6> <vc6>foo</vc6> <vc7>bar7</vc7> <vc7>foo7</vc7> <vc8 arch="x64">amd64demo</vc8></docroot> \[/code\]that is, 1. child elements of should be sorted by element name, so comes before .2. If two children have the same element name, they should be sorted by their text value, so 'bar' is ahead of 'foo'.How to write the xsl? Thank you.
 
Back
Top