xsl-list
[Top] [All Lists]

Re: [xsl] Multiple Template Matchingm, Attributes & Complex XML

2011-02-25 11:51:53
Jeffry Proctor wrote:

2. Is there a way to have another xml file as a lookup list for attributes like
gender typeCode tc or state typeCode tc so that the one XSL is easier to manage?

Yes, you can load other documents with the XSLT 'document' function and then access nodes e.g.

  <xsl:template match="foo">
<xsl:value-of select="document('lookup.xml')/root/bar[. = current()]/code"/>
  <xsl:template>

Using a key might make such a lookup more efficient (but is a bit akward to code with XSLT 1.0:

  <xsl:key name="k1" match="bar" use="."/>

  <xsl:template match="foo">
    <xsl:variable name="this" select="."/>
    <xsl:for-each select="document('lookup.xml')">
      <xsl:value-of select="key('k1', $this)/code"/>
    </xsl:for-each>
  </xsl:template>

--

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

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