xsl:sort is not working properly when special character like ", : ;" are presents. What might be the problem here?
I am trying to render html from xml data with java dom4j library. Though the real project has multiple sorting criteria, I am illustrating a summery here to the specific problem.
The expected sorting order is ASCIIbatical order. The online String Sort Toll is also giving my expected output.
I have some xml data ex:
<employee>
<name>
<![CDATA[test 1.8 - test]]>
</name>
<name>
<![CDATA[test 4 - test]]>
</name>
<name>
<![CDATA[Test 2 - test]]>
</name>
</employee>
I am trying to sort them with xsl transformer with . The snippet for sorting it...
<xsl:for-each select="employee/name">
<xsl:sort select="name" case-order="upper-first"/>
...
Expected Output Order:
Test 2 - test
test 1.8 - test
test 4 - test
The Output Order I am getting:
test 1.8 - test
Test 2 - test
test 4 - test
Like this getting the order
; - ;
& - &
T1 - T1
In stead of
& - &
; - ;
T1 - T1
First, your code snippet sorts
employees, notnames.Now, the result you get is the expected output after sorting the names. If you want the entry of
Test 2 - testto come first because it starts with a capitalT, then you need to do:and you will need a processor that supports XSLT 2.0 or higher for that.
I don't see what the presence of the dot or any other character has to do with any of this.