Microsoft
Software
Hardware
Network
Question : Why does this xslt sort not work?
HI,
I have an XSLT that was succesfully sorting an xml file I had created by hand. However, now I am manipulating the XML in code (C#, Net framework 3.5), and when I apply the XSLT transformation, the sort no longer works. I suspect its something to do with the encoding Im using (?). Can anyone shed any light?
the XML:
<ROOT ID="1" TYPE="TUTORIAL" TITLE="Darren test tutorial" IMAGE="./images/TUTORIAL.g
if"
POSITION="0"><ITEM ID="2" TYPE="TOPIC" TITLE="Topic 2" IMAGE="./images/TOPIC.gif"
POSITION="1"></ITEM><ITEM ID="1" TYPE="TOPIC" TITLE="Topic 1" IMAGE="./images/TOPIC.gif"
POSITION="0"><ITEM ID="1" TYPE="PAGE" TITLE="New Page" IMAGE="./images/PAGE.gif"
POSITION="0"></ITEM><ITEM ID="1" TYPE="QPAGE" TITLE="A Question" IMAGE="./images/QPAGE.gif"
POSITION="1"></ITEM></ITEM
></ROOT>
The XSLT:
<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.o
rg/1999/XS
L/Transfor
m
"
version="1.0">
<xsl:template match="ROOT">
<ROOT>
<xsl:attribute name="ID">
<xsl:value-of select="@ID"/>
</xsl:attribute>
<xsl:attribute name="TYPE">
<xsl:value-of select="@TYPE"/>
</xsl:attribute>
<xsl:attribute name="TITLE">
<xsl:value-of select="@TITLE"/>
</xsl:attribute>
<xsl:attribute name="IMAGE">
<xsl:value-of select="@IMAGE"/>
</xsl:attribute>
<xsl:attribute name="POSITION">
<xsl:value-of select="@POSITION"/>
</xsl:attribute>
<xsl:apply-templates mode="getItems" >
<xsl:sort select="@position" data-type="number" order="ascending"/>
</xsl:apply-templates>
</ROOT>
</xsl:template>
<xsl:template match="ITEM" mode="getItems">
<ITEM>
<xsl:attribute name="ID">
<xsl:value-of select="@ID"/>
</xsl:attribute>
<xsl:attribute name="TYPE">
<xsl:value-of select="@TYPE"/>
</xsl:attribute>
<xsl:attribute name="TITLE">
<xsl:value-of select="@TITLE"/>
</xsl:attribute>
<xsl:attribute name="IMAGE">
<xsl:value-of select="@IMAGE"/>
</xsl:attribute>
<xsl:attribute name="POSITION">
<xsl:value-of select="@POSITION"/>
</xsl:attribute>
<xsl:apply-templates mode="getItems" >
<xsl:sort select="@position" data-type="number" order="ascending"/>
</xsl:apply-templates>
</ITEM>
</xsl:template>
</xsl:stylesheet>
Answer : Why does this xslt sort not work?
XSLT is case-sensitive language. Since the attribute POSITION is uppercased in the XML it should be uppercased in the XSLT:
<xsl:sort select="@POSITION" data-type="number" order="ascending"/>
Random Solutions
Copy data from sheets according to sub header.
How to register regsrv32 DLLs in remote machi by using delphi 7 program
Network magic needed
DHCP in SBS 2008
Can a Mail-Enabled Public Folder be restricted from sending to a Distribution List?
doc for code review
Collecting amount of data stored in file shares remotely
visiting New York for the first time, what should I do and what's the must see's?
Laptop Sata Hard drive duplicator ? do the exist?
why appendTo jquery is not working