View Single Post
  #2 (permalink)  
Old May 5th, 2010, 09:30 AM
Martin Honnen Martin Honnen is offline
Friend of Wrox
Points: 6,673, Level: 34
Points: 6,673, Level: 34 Points: 6,673, Level: 34 Points: 6,673, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,242
Thanks: 0
Thanked 244 Times in 243 Posts
Default

With XSLT 2.0 and 1.0 you can use the document function http://www.w3.org/TR/xslt#document to pull in XML documents.
With XSLT 2.0 you can also use the doc function.
Here is an XSLT 2.0 stylesheet that uses the document function but makes use of the third parameter of the key function that is only available in XSLT 2.0:
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xpath-default-namespace="http://test.com"
  version="2.0">
  
  <xsl:output method="xml" indent="yes"/>
  
  <xsl:param name="f2" select="'test2010050503.xml'"/>
  <xsl:param name="f3" select="'test2010050504.xml'"/>
  
  <xsl:variable name="doc2" select="document($f2)"/>
  <xsl:variable name="doc3" select="document($f3)"/>
  
  <xsl:key name="k1" match="Response/Result/info" use="id"/>
  
  <xsl:template match="Response/Result/List">
    <Row>
      <xsl:apply-templates select="key('k1', typeid, $doc2)/rfs, key('k1', typeid, $doc3)/code"/>
      <xsl:apply-templates select="agentname, Addess1"/>
    </Row>
  </xsl:template>
  
  <xsl:template match="Response/Result/info/* | Response/Result/List/*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote