The document() function returns a root node, and this root node will be processed using the match="/" template, so you will go into an infinite recursion, terminating with a stack overflow.
Two solutions: process the second document in a different mode; or apply templates not to its root node but to its outermost element. Specifically, either:
<xsl:apply-templates select="document($secondfile.xml)" mode="secondfile"/>
<xsl:apply-templates select="document($secondfile.xml)/*"/>
Mike Kay
-----Original Message-----
From: []On Behalf Of Gale Lee (EWU)
Sent: 06 September 2001 02:14
Subject: [saxon] processing multiple input files

I'm using Saxon6_4_3 on Solaris to process XSLT.  I have two XML files as input.  Both are based on the same DTD.  I need to treat them as if they are a single input file by the XSLT which then output its transformation into a single XML file. I read the document() function and tried invoking
<xsl:template match="/">
  <xsl:apply-templates select="document($secondfile.xml)"/>
Hoping that both the principal source firstfile.xml (supplied during com.icl.saxon.StyleSheet command line invocation) and the content of secondfile.xml will be merged creating a single node set for processing.  Saxon generates errors.  How can I process these two files?  thank you for your help.