Re: [xsl] Using values from one node tree to iterate/recurse over another set of nodes. (Newbie Question)

Subject: Re: [xsl] Using values from one node tree to iterate/recurse over another set of nodes. (Newbie Question)
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Wed, 27 Feb 2008 16:45:25 +0100 (CET)
Richard Dyce wrote:

  Hi

> <xsl:template match="record">
>   <xsl:param name="structure"/>

>   <!-- newbie problem !!!! -->
>   <xsl:value-of select="$structure" />
>   <xsl:value-of select="." />

> </xsl:template>

  I would apply templates on the structure's fields:

    <xsl:template match="record">
       <xsl:param name="s" as="element(structure)"/>
       <xsl:apply-templates select="$s/*">
          <xsl:with-param name="record" select="."/>
       </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="field">
       <xsl:param name="r" as="element(record)"/>
       <dt>
          <xsl:value-of select="@label"/>
       </dt>
       <dd>
          <xsl:value-of select="my:record-field($r, .)"/>
       </dd>
    </xsl:template>

    <xsl:function name="my:record-field" as="element()">
       <xsl:param name="r" as="element(record)"/>
       <xsl:param name="f" as="element(field)"/>
       <xsl:sequence select="$r/*[local-name() eq $f/@name]"/>
    </xsl:function>

  You will maybe want to change the expression in
my:record-field, in particular regarding namespaces.

  Regards,

--drkm




















      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr

Current Thread