Hi Peter,
If you want to arrange something by a given number of fixed columns then
something like...
== XML =================================
<?xml version="1.0"?>
<headdata>
<extension>
<person>
<name>Aaaa</name>
<funktion>A1</funktion>
</person>
<person>
<name>Bbbb</name>
<funktion>B2</funktion>
</person>
<person>
<name>Cccc</name>
<funktion>C3</funktion>
</person>
<person>
<name>Dddd</name>
<funktion>D4</funktion>
</person>
<person>
<name>Eeee</name>
<funktion>E5</funktion>
</person>
</extension>
</headdata>
== end of XML ==========================
== XSL1 =================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="no-cols" select="3"/>
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:apply-templates select="headdata/extension/person[position()
mod $no-cols = 1 or $no-cols = 1]" mode="row-start"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="person" mode="row-start">
<tr>
<xsl:apply-templates select=". | following-sibling::person[position()
< $no-cols]"/>
</tr>
</xsl:template>
<xsl:template match="person">
<td>
<xsl:value-of select="name"/>
<br/>
<xsl:text>more info: </xsl:text>
<xsl:value-of select="funktion"/>
</td>
</xsl:template>
</xsl:stylesheet>
== end of XSL1 ==========================
or...
== XSL2 =================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="no-cols" select="3"/>
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="headdata/extension/person[position() mod
$no-cols = 1 or $no-cols = 1]">
<tr>
<xsl:for-each select=". | following-sibling::person[position()
< $no-cols]">
<td>
<xsl:value-of select="name"/>
<br/>
<xsl:text>more info: </xsl:text>
<xsl:value-of select="funktion"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
== end of XSL2 ==========================
If your XML doesn't look like that then the XSL code might need changing -
but as you haven't posted any example XML that's something you will have to
figure.
The code will also need to be drastically different if you are sorting the
data as it is placed into the table - because axes work on the original
order of the nodes in the input document rather than the sorted node-set.
Cheers
Marrow
"Peter Rohleder" <pe************@epost.de> wrote in message
news:3E************@epost.de...
Hi Marrow,
you write:
(...) Perhaps if you post some example XML and describe what you are actually
trying to achieve? It is difficult to see what the problem might be
from just an incomplete fragment of XSLT code.
I suspect you might be wanting to organize things into a table with a
fixed 3 coulumns?
yes, thats true!
I solved the problem by replacing following part, which doesn't work:
<!-- Part 4 doens'nt work-->
<xsl:call-template name="handlePerson">
<xsl:with-param name="persondata"
select="following-sibling::*[1]"/>
</xsl:call-template>
(...)
by(new code):
-----------
<xsl:for-each select="following-sibling::*">
<xsl:if test="position() < 3">
<td>
<xsl:call-template name="handlePerson">
<xsl:with-param name="persondata" select="."/> </xsl:call-template>
</td>
</xsl:if>
</xsl:for-each>
-----------
Now it works, but i still have no idea why the code above doesn't work
and the new code works.
Thanks for your response.
Peter Rohleder