T
Tjerk Wolterink
I posted my problem earlier, but i simplified the examples,
and i know what the cause of the problem is, but i dont know the solution,
my xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="datastyle.xsl"?>
<data xmlns="http://tjerk.com">
<item>a1</item>
<item>b2</item>
<item>c3</item>
<item>d4</item>
<item>e5</item>
<item>f6</item>
<item>a0</item>
</data>
If i would sort the text items elements i would place the
last item a0 at the beginning. But i am also
using the modulo operator to create a table like structure:
The xsl file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:tjerk="http://tjerk.com"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes"/>
<xslaram name="cols" select="3"/>
<xsl:template match="/tjerk:data">
<data>
<xsl:for-each select="./tjerk:item[(position() mod $cols)=1]">
<xsl:sort data-type="text" select="tjerk:item" order="descending" />
<tr>
<xsl:apply-templates select="."/>
<xsl:apply-templates select="following-sibling::tjerk:item[position() <
$cols]"/>
</tr>
</xsl:for-each>
</data>
</xsl:template>
<xsl:template match="tjerk:item">
<td><xsl:value-of select="."/></td>
</xsl:template>
</xsl:stylesheet>
---
The output is:
-
<data>
<tr><td>a0</td></tr>
<tr><td>a1</td><td>b0</td><td>c3</td></tr>
<tr><td>d4</td><td>e5</td><td>f6</td></tr>
</data>
-
But i want the output to be like this:
-
<data>
<tr><td>a0</td><td>a1</td><td>b0</td></tr>
<tr><td>c3</td><td>d4</td><td>e5</td></tr>
<tr><td>f6</td></tr>
</data>
-
The problem is the sort element in the foreach loop,
how can i solve this???
Help is much appreciated.
and i know what the cause of the problem is, but i dont know the solution,
my xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="datastyle.xsl"?>
<data xmlns="http://tjerk.com">
<item>a1</item>
<item>b2</item>
<item>c3</item>
<item>d4</item>
<item>e5</item>
<item>f6</item>
<item>a0</item>
</data>
If i would sort the text items elements i would place the
last item a0 at the beginning. But i am also
using the modulo operator to create a table like structure:
The xsl file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:tjerk="http://tjerk.com"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes"/>
<xslaram name="cols" select="3"/>
<xsl:template match="/tjerk:data">
<data>
<xsl:for-each select="./tjerk:item[(position() mod $cols)=1]">
<xsl:sort data-type="text" select="tjerk:item" order="descending" />
<tr>
<xsl:apply-templates select="."/>
<xsl:apply-templates select="following-sibling::tjerk:item[position() <
$cols]"/>
</tr>
</xsl:for-each>
</data>
</xsl:template>
<xsl:template match="tjerk:item">
<td><xsl:value-of select="."/></td>
</xsl:template>
</xsl:stylesheet>
---
The output is:
-
<data>
<tr><td>a0</td></tr>
<tr><td>a1</td><td>b0</td><td>c3</td></tr>
<tr><td>d4</td><td>e5</td><td>f6</td></tr>
</data>
-
But i want the output to be like this:
-
<data>
<tr><td>a0</td><td>a1</td><td>b0</td></tr>
<tr><td>c3</td><td>d4</td><td>e5</td></tr>
<tr><td>f6</td></tr>
</data>
-
The problem is the sort element in the foreach loop,
how can i solve this???
Help is much appreciated.