weird attribute problem

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">


<xsl:eek:utput method ="xml" />


<xsl:param name="sort-id" select="'Last Name'"/>
<xsl:param name="sort-order" select="'ascending'"/>
<xsl:param 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top