xsl-list
[Top] [All Lists]

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

2008-02-27 08:45:59
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


--~------------------------------------------------------------------
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>
--~--