Hi Martin,
Many
thanks for your help.
I tried your code but I got an parser error:
XML ERROR in Table
REASON: Too many tags
FILE: C:\Documents and Settings\pallonec\Local Settings\Temporary Internet Files\Content.IE5\4YBMJN9K\report[2].xls
GROUP: Cell
TAG: Data
VALUE: Color: Color Selected
I then realised that I cannot have two <Data> tags inside the same <Cell> tag so I removed the Data tag from the last template and placed it inside the previous one. I also added a check to print the title in bold and it is all working now.
<xsl:template match="Parameter[not(@col = 2 and @row = preceding-sibling::Parameter[1]/@row)]">
<Row>
<xsl:choose>
<xsl:when test ="@title = 'true'">
<Cell ss:StyleID="bd">
<Data ss:Type="String">
<xsl:apply-templates select="." mode="m1"/>
<xsl:apply-templates select="following-sibling::Parameter[1][@col = 2 and @row = current()/@row]"/>
</Data>
</Cell>
</xsl:when>
<xsl:otherwise>
<Cell>
<Data ss:Type="String">
<xsl:apply-templates select="." mode="m1"/>
<xsl:apply-templates select="following-sibling::Parameter[1][@col = 2 and @row = current()/@row]"/>
</Data>
</Cell>
</xsl:otherwise>
</xsl:choose>
</Row>
<xsl:apply-templates select="following-sibling::Parameter[not(@col = 2 and @row = current()/@row)][1]"/>
</xsl:template>
I have to confess that I am still finding difficult to get my head around the sibling recursion.
Could you please clarify the following points?
1 - If inside this template, I call a named template:
<xsl:template match="Parameter" mode="m1">
<xsl:choose>
<xsl:when test ="self::node()[@col = 2 and @row = following-sibling::Parameter[1]/@row]">
<xsl:call-template name ="noCellAdded">
<xsl:with-param name ="followingSib" select ="following-sibling::Parameter[1][@col = 2 and @row = current()/@row]"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
How do I get the values of of the $noCellAdded node set? Also how do I call templates from there. I have tried the code below but I cannot get the values from the node set.
<xsl:template name ="noCellAdded">
<xsl:param name ="followingSib"></xsl:param>
<xsl:choose>
<xsl:when test ="followingSib/@title = 'true'">
<Data ss:Type="String">
<xsl:value-of select="followingSib/@value"/>
</Data>
</xsl:when>
<xsl:otherwise>
<Data ss:Type="String">
<xsl:value-of select="followingSib/@value"/>
</Data>
</xsl:otherwise>
</xsl:choose>
<!--<xsl:apply-templates select=". | following-sibling::Parameter[1][@col = 2 and @row = current()/@row]" mode="m1"/>-->
<xsl:apply-templates select="following-sibling::followingSib[@col = 2 and @row = current()/@row]" mode="m1"/>
</xsl:template>
2 - I still cannot understand why you put the index [1] at the end of your expression!!!
<xsl:apply-templates select="following-sibling::Parameter[not(@col = 2 and @row = current()/@row)][1]"/>
Could the [1] be placed after the Parameter tag like this:
<xsl:apply-templates select="following-sibling::Parameter[1][not(@col = 2 and @row = current()/@row)]"/>
3 - why do you apply template with a unions? We are only interested in the following subling, arent we?
<xsl:apply-templates select=". | following-sibling::Parameter[1][@col = 2 and @row = current()/@row]" mode="m1"/>
Cheers
C