I have a bunch of reports which are individually edited and transformed (xml -> xsl-fo) to create pdf files. In addition I would like to combine all the reports into a book to be created using a single transformation. I thought I could use the **document()** function for this:

(Individual reports look like this):

```
<?xml version="1.0"?>
<!DOCTYPE blue_book SYSTEM "../DTD/blue_book.dtd">
<blue_book>

  ~~stuff~~

</blue_book>

```

I create a placeholder file called, say, reports.xml:

```
<?xml version="1.0"?>
<reports>
  <report filename="title.xml"/>
  <report filename="preface.xml"/>
  <report filename="report1.xml"/>
  <report filename="report2.xml"/>
  <report filename="report3.xml"/>
  <report filename="report4.xml"/>
</reports>

```

and then use something like this in my stylesheet to crank through them:

```
<xsl:for-each select="/reports/report">
  <xsl:apply-templates select="document(@filename)/blue_book"/>
</xsl:for-each>

```

This sort of works, but all the code I've created to start page-numbering and autogenerate id's based on location in the document for linking purposes falls apart. For example, I want page numbering to start on the 3rd report. If I just cat all the xml files together into a single file, the following works fine.

```
<xsl:template match="blue_book">
  <xsl:choose>
    <xsl:when test="count(preceding-sibling::blue_book) &lt; 2">
      <fo:page-sequence master-reference="front-matter">
        <fo:flow flow-name="xsl-region-body">
          <xsl:apply-templates/>
        </fo:flow>
      </fo:page-sequence>
    </xsl:when>

    <xsl:when test="count(preceding-sibling::blue_book) = 2">
      <fo:page-sequence master-reference="report">
        <xsl:attribute name="initial-page-number">1</xsl:attribute>

        <fo:static-content flow-name="first-xsl-region-before">
            <xsl:if test="lead_para">
              <fo:block font-variant="small-caps" text-align="center">
                <xsl:value-of select="lead_para"/></fo:block>
            </xsl:if>
          <fo:block>&#x00A0;</fo:block>
        </fo:static-content>
(etc. -- lots of xsl-fo)

```

but when loading files using the **document()** function, it appears that the preceding-sibling count is always 0; i.e. it's only looking at that particular report and not considering the ones loaded previously.

This makes sense, but doesn't solve my problem. Is there a standard way to do this? In particular, I'd like to process all the reports *as if they were in the same XML document* but without having to actually physically concatenate them together.\*

\*If anyone is wondering why, it's because the editors want to maintain and edit the reports individually but still be able to run something through AH Formatter which gives them the complete book. Concatenation of files is outside their skill set.