[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Noob: how to use "for each" in this context?

Subject: RE: Noob: how to use "for each" in this context?
From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Sep 2003 09:46:20 +0100
black jim null
no need for xsl:for-each try nesting your templates

<xsl:template match="Row">
     <fo:table-cell border="solid black 1 px" border-collapse="collapse">
         <fo:block>
		<xsl:apply-templates select="."/>
         </fo:block> 
     </fo:table-cell>
</xsl:template>

then supply other matching templates

<xsl:template match="NodeA">
</xsl:template>

<xsl:template match="Node1">
</xsl:template>

though I suspect that you may want to take a look at restructering your xml data.....be descriptive with your element names... is your data really data-centric instead of document centric or have you just got into the habit of thinking of data in tables and rows ?

try the following sites for more information

www.dpawson.co.uk
http://www.w3.org/Style/XSL/
www.topxml.com

gl, jim fuller


-----Original Message-----
From: Barry van Weldam [mailto:barry@xxxxxxx]
Sent: 17 September 2003 09:29
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Noob: how to use "for each" in this context?


Hi,

I realised i am repeating this code in my .xsl:
------------------------------------------
     <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='($node="null")'></xsl:when>
        <!--or the value-->
         <xsl:otherwise><xsl:value-of select="$node"/></xsl:otherwise>
          </xsl:choose>
         </fo:block> 
     </fo:table-cell>
------------------------------------
Now i want to use a for each, how do i do that?



BTW:
My .xml
--------------------------------------------------------
<Root>
<Table>
<Row>
<nodeA>Total</nodeA>
<node1>null</node1>
<node2>777</node2>
etc

and this is the part of the .xsl i want to streamline


------------------------------------------------------------------------------
 <xsl:template match="//Row">
    <fo:table-row>
     <fo:table-cell border="solid black 1 px" border-collapse="collapse">
         <fo:block>
            <xsl:value-of select="nodeA"/></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='(node1="null")'></xsl:when>
          <xsl:otherwise><xsl:value-of select="node1"/></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='(node2="null")'></xsl:when>
        <xsl:otherwise> <xsl:value-of select="node2"/></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='(node3="null")'></xsl:when>
        <xsl:otherwise> <xsl:value-of select="node3"/></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='(node4="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node4"/></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='(node5="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node5"/></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='(node6="null")'></xsl:when>
        <xsl:otherwise> <xsl:value-of select="node6"/></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='(node7="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node7"/></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='(node8="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node8"/></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='(node9="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node9"/></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='(node10="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node10"/></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='(node11="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node11"/></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='(node12="null")'></xsl:when>
         <xsl:otherwise><xsl:value-of select="node12"/></xsl:otherwise>
          </xsl:choose>
         </fo:block> 
     </fo:table-cell>
    </fo:table-row>

------------------------------------------------


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


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.