xsl-list
[Top] [All Lists]

Re: [xsl] Processing Nested Lists

2007-02-27 02:22:01
Adam Retter wrote:

  Hi

<xsl:template name="processNode">
      <xsl:parameter name="node"/>
      <tr>
              <td><xsl:value-of select="{node-name($node)}"/></td>
      </tr>
      <xsl:for-each select="$node/child::node">
              <xsl:call-template name="processNode">
                      <xsl:with-parameter name="node" select="."/>
              </xsl:call-template>
      </xsl:for-each>
</xsl:template>

<xsl:for-each select="/TopTag/TaxonomyEntries/TaxonomyNode">
      <xsl:call-template name="processNode">
              <xsl:with-parameter name="node" select="."/>
      </xsl:call-template>
</xsl:for-each>

  This is exactly the kind of stuff template rules are for.  In other
words, to apply code to some sequence of nodes: apply template rules to
nodes instead of calling named template passing nodes by parameters and
using xsl:for-each.

  For example, the code above can be written (the intention above is
not precisely clear, but you'll got the idea):

    <xsl:template match="*">
      <tr>
        <td>
          <xsl:value-of select="name(.)"/>
        </td>
      </tr>
      <xsl:apply-templates select="*"/>
    </xsl:template>

    ...

    <xsl:apply-templates
        select="/TopTag/TaxonomyEntries/TaxonomyNode">


  Regards,

--drkm






















        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses 
http://fr.answers.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>