xsl-list
[Top] [All Lists]

RE: mixed content nodes question

2005-01-07 12:48:53

Or to one who doesn't like if's

<xsl:template match="dictionary[lookup = '3']>Foo<xsl:/template>
<xsl:template match="dictionary[lookup = '4']>Foo<xsl:/template>


My preferred way to do lookups is to make it table driven:

<xsl:variable name="table">
  <entry code="3" value="foo"/>
  <entry code="4" value="bar"/>
</xsl:variable>

<xsl:template match="dictionary">
  <xsl:value-of select="$table/entry[(_at_)code=current()/@lookup]/@value"/>
</xsl:template>

Needs the xx:node-set() extension or the document("") cheat if using XSLT
1.0.

Michael Kay
http://www.saxonica.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>
--~--