T
Tjerk Wolterink
i have xml like this:
<data>
<item type="a">
1
</item>
<item type="a">
2
</item>
<item type="b">
3
</item>
<item type="a">
4
</item>
<item type="a">
5
</item>
<item type="b">
6
</item>
<item type="a">
7
</item>
</data>
i want some xsl toget this for $type=a:
<output>
<row>
<data>1</data>
<data>2</data>
</row>
<row>
<data>4</data>
<data>5</data>
</row>
<row>
<data>7</data>
<data></data>
</row>
</output>
and for $type=b this as output:
<output>
<row>
<data>3</data>
<data>6</data>
</row>
</output>
my xsl sofar:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0">
<xslaram name="type"/>
<xsl:template match="/data">
<xsl:for-each select="item[xc:type=$type][(position() mod 2)=1]">
<row>
<xsl:apply-templates select="."/>
<xsl:apply-templates select="following-sibling::*[position() < 2]"/>
</row>
</xsl:for-each>
</xsl:template>
<xsl:template match="xc:medewerker">
<data>
<xsl:value-of select="."/>
</data>
</xsl:template>
<xsl:stylesheet>
But this does not work, because some times items of type b
are chosen when $type equals a.
please help
<data>
<item type="a">
1
</item>
<item type="a">
2
</item>
<item type="b">
3
</item>
<item type="a">
4
</item>
<item type="a">
5
</item>
<item type="b">
6
</item>
<item type="a">
7
</item>
</data>
i want some xsl toget this for $type=a:
<output>
<row>
<data>1</data>
<data>2</data>
</row>
<row>
<data>4</data>
<data>5</data>
</row>
<row>
<data>7</data>
<data></data>
</row>
</output>
and for $type=b this as output:
<output>
<row>
<data>3</data>
<data>6</data>
</row>
</output>
my xsl sofar:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0">
<xslaram name="type"/>
<xsl:template match="/data">
<xsl:for-each select="item[xc:type=$type][(position() mod 2)=1]">
<row>
<xsl:apply-templates select="."/>
<xsl:apply-templates select="following-sibling::*[position() < 2]"/>
</row>
</xsl:for-each>
</xsl:template>
<xsl:template match="xc:medewerker">
<data>
<xsl:value-of select="."/>
</data>
</xsl:template>
<xsl:stylesheet>
But this does not work, because some times items of type b
are chosen when $type equals a.
please help