Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Multiple source documents (2/4) >

Addressing in external documents

Parts of the external documents can be addressed using XPath expressions. The call of document() returns an XML tree which can be in the standard way.
XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xxx>
                        <xsl:value-of  select="document('ext1.xml')/rrr/ccc/@y"/>
                  </xxx>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>

ext2.xml

      <rrr>
            <ccc  y="222"/>
      </rrr>
Output

      <xxx>222</xxx>


Previous chapter: Groups
Next chapter: Multiple stylesheets
Previous page: Reading external document with document function.
Next page: Reading external document using doc function