[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Noob: hmm using nested templates, how do i get the nodes within


Subject: [xsl] Noob: hmm using nested templates, how do i get the nodes within
From: "Barry van Weldam" <barry@xxxxxxx>
Date: Thu, 18 Sep 2003 10:38:14 +0200

Hi there,

I think i know the general idea but i can't get it working.

Sorry for the long post

Part of the xml-file (i didn't format it and i replaced the node names)
-------------------------------------
<Table>
<Row>
<aaa>Total</aaa>
<TdD>null</TdD>
<NA>45678</NA>
<FR>45644</FR>
</Row>
<Row>
etc

And my workig .xsl that isn't effecient enough
=--------------------------------------------
<xsl:template match="//Row">
<fo:table-row>
<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:value-of select="TT"/></fo:block> 
</fo:table-cell>

<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:choose>
<!--Here we put nothing if nodevalue=null -->
<xsl:when test='(aaa="null")'></xsl:when>
<xsl:otherwise><xsl:value-of select="aaa"/></xsl:otherwise>
</xsl:choose>
</fo:block> 
</fo:table-cell>
<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:choose>
<!--Here we put nothing if nodevalue=null -->
<xsl:when test='(TdD="null")'></xsl:when>
<xsl:otherwise> <xsl:value-of select="TdD"/></xsl:otherwise>
</xsl:choose>
</fo:block> 
</fo:table-cell>
<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:choose>
<!--Here we put nothing if nodevalue=null -->
<xsl:when test='(NA="null")'></xsl:when>
<xsl:otherwise><xsl:value-of select="NA"/></xsl:otherwise>
</xsl:choose>
</fo:block> 
</fo:table-cell>
<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:choose>
<!--Here we put nothing if nodevalue=null -->
<xsl:when test='(FR="null")'></xsl:when>
<xsl:otherwise> <xsl:value-of select="FR"/></xsl:otherwise>
</xsl:choose>
</fo:block> 
</fo:table-cell>
etc.

so now i heard i could use nested template, like
-------------------------------------------------
<xsl:template match="//Row">
<fo:table-row>
<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:value-of select="TT"/>
</fo:block>
</fo:table-cell>
<xsl:call-template name="cell"/>
</fo:table-row>
</xsl:template>

<xsl:template name="cell">
<fo:table-cell border="solid black 1 px" border-collapse="collapse">
<fo:block>
<xsl:variable name="cell" select="//Row/[*]"/> <---------------Here's where i think i go wrong, how do i select the nodes
<xsl:choose>
<xsl:when test="not($cell = 'null')">
<xsl:value-of select="$cell"/>
</xsl:when>
</xsl:choose>
</fo:block>
</fo:table-cell>

</xsl:template>


Any more suggestions.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread