Multiple Documents

A stylesheet can load additional documents with the document() function. In the following example, we recast the sorted table example using several features we have learned:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:import href="element.xsl"/>

<xsl:variable name="tabledoc">sorttable.xml</xsl:variable>

<xsl:template match="insert-table">
  <xsl:if test="@id"><a name="{@id}"/></xsl:if>
  <xsl:apply-templates select="document($tabledoc)"/>
</xsl:template>

<xsl:template match="table">
  <table>
    <xsl:apply-templates select="row">
      <xsl:sort data-type="number" select="./cell[1]"/>
    </xsl:apply-templates>
  </table>
</xsl:template>

</xsl:stylesheet>