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

First node processed repeatedly

Subject: First node processed repeatedly
From: Imrran Wahid <devguy2003@xxxxxxxxx>
Date: Fri, 7 Mar 2003 08:58:04 -0800 (PST)
xsl first node
I am populating a table dynamically using xml data.
The elements in the xml may be present or absent. So I
set up all the possible fields in a lookup table
(TableStruct). I need to cater for an element which
may exist in one row but absent in another. So for
each element in the lookup table, if a count of the
row elements reveal that the named element exist in
one or more row, I do a td entry and populate it
accordingly.

I have the following template which works ok for what
I am doing:

<xsl:template match="Rows/Row" mode="celldata">
   <xsl:variable name="thisitem" select="."/>
     <tr>
       <xsl:for-each select="$TableStruct/Row/*">
       <xsl:variable name="ItemName"
select="string(name(.))"/>
       <xsl:if
test="count($thisitem/..//*[name(.)=$ItemName]) &gt;
0">
         <td nowrap="true">
           <xsl:value-of
select="$thisitem/*[name()=name(current())]"/>
         </td>
       </xsl:if>
       </xsl:for-each>
   </tr>
</xsl:template>

I am now trying to make this template a named template
(so I can reuse with different node-sets) as follows:

<xsl:template name="OptionalFldsTblCellData">
  <xsl:param name="row-node" select="/.."/>
  <xsl:param name="lookup-node" select="/.."/>
  <!--xsl:variable name="thisitem" select="."/-->
  <xsl:for-each select="$row-node">
    <tr>
      <xsl:for-each select="$lookup-node/*">
        <xsl:variable name="ItemName"
select="string(name(.))"/>
        <!--xsl:if
test="count($thisitem/..//*[name(.)=$ItemName]) &gt;
0"-->
        <xsl:if
test="count($row-node/..//*[name(.)=$ItemName]) &gt;
0">
          <td nowrap="true">
            <xsl:value-of
select="$row-node/*[name()=name(current())]"/>
          </td>
        </xsl:if>
      </xsl:for-each>
    </tr>
  </xsl:for-each>
</xsl:template>


I call the named template as follows:

<xsl:call-template name="OptionalFldsTblCellData">
  <xsl:with-param name="row-node" select="//Row"/>
  <xsl:with-param name="lookup-node"
select="$TableStruct/Row"/>
</xsl:call-template>


However my table gets populated with repeated entries
of the first row. So if i have 3 rows in the xml, I
get 3 rows in the table showing the first row's data.

Can you help spot the error?

Thanks

Imrran


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

 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.