xsl-list
[Top] [All Lists]

Re: [xsl] Using outer context node inside for-each

2009-07-08 13:41:09
Richard Lewis wrote:

Here is an abstraction of my problem template:

 <xsl:template match="record">
   <xsl:param name="show-fields" />
   <xsl:variable name="this" select="." />

   <xsl:for-each select="str:tokenize($show-fields)">
     <xsl:message><xsl:value-of select="$this/field[(_at_)name=(_dot_)]" 
/></xsl:message>
   </xsl:for-each>
 </xsl:template>

So <record> elements have child elements called <field> which each
have a @name attribute.

The given template should accept a parameter which is a list of field
names, and emit an <xsl:message> of each <field> element whose @name
is in that list.

Your textual description sounds as if you want
  <xsl:for-each select="field[(_at_)name = str:tokenize($show-fields)]">
    <xsl:message>
      <xsl:value-of select="."/>
    </xsl:message>
  </xsl:for-each>


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

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