Example 9-3: Looking up external information during a transformation

<!-- TranslateTripCode.xsl: Lookup Codes from external file -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- Import the identity transformation. -->
  <xsl:import href="Identity.xsl"/>
  <!-- Parameterize language for lookup code translation, default to "en" -->
  <xsl:param name="lang" select="'en'"/>
  <!-- Select root node of external document into "codes" variable -->
  <xsl:variable name="codes" select="document('TripReportLookup.xml')"/>
  <!--
   | Whenever you match a Purpose element, replace numeric value by
   | lookup up codes from external file.
   +-->
  <xsl:template match="Purpose">
    <xsl:copy>
      <xsl:value-of select="$codes/Lookup/Msg[@id=current()]/Text[@lang=$lang]"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>