N
noureensyed
Hi there,
1. I have the following XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xslutput method ="xml" />
<xslaram name="sort-id" select="'Last Name'"/>
<xslaram name="sort-order" select="'ascending'"/>
<xslaram name="sort-type" select="'text'"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="DATATABLE[@ID='TARGET']">
<xsl:copy>
<xsl:apply-templates select="@* | ROW">
<xsl:sort select="COLUMN[@ID = $sort-id]/@VALUE"
data-type="{$sort-type}" order="{$sort-order}" lang="en" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
2. When I apply this to an XML of the form:
<DATATABLES>
<DATATABLE ID="TARGET">
<ROW ID="0">
<COLUMN>...</COLUMN>
<COLUMN>...</COLUMN>
</ROW>
<ROW ID="1">... </ROW>
<ROW ID="2">
<COLUMN>...</COLUMN>
......
</ROW>
</DATATABLE>
<DATATABLE ID="something else">....
</DATATABLE>
</DATATABLES>
I get the desired result, all good! BUT if I change the sort-order
param to "'descending'", my resulting xml loses the ID="TARGET"
attribute!!!? How can I fix this behaviour and why is it happening?
Thank you.
1. I have the following XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xslutput method ="xml" />
<xslaram name="sort-id" select="'Last Name'"/>
<xslaram name="sort-order" select="'ascending'"/>
<xslaram name="sort-type" select="'text'"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="DATATABLE[@ID='TARGET']">
<xsl:copy>
<xsl:apply-templates select="@* | ROW">
<xsl:sort select="COLUMN[@ID = $sort-id]/@VALUE"
data-type="{$sort-type}" order="{$sort-order}" lang="en" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
2. When I apply this to an XML of the form:
<DATATABLES>
<DATATABLE ID="TARGET">
<ROW ID="0">
<COLUMN>...</COLUMN>
<COLUMN>...</COLUMN>
</ROW>
<ROW ID="1">... </ROW>
<ROW ID="2">
<COLUMN>...</COLUMN>
......
</ROW>
</DATATABLE>
<DATATABLE ID="something else">....
</DATATABLE>
</DATATABLES>
I get the desired result, all good! BUT if I change the sort-order
param to "'descending'", my resulting xml loses the ID="TARGET"
attribute!!!? How can I fix this behaviour and why is it happening?
Thank you.