Wendell Piez wrote:
Felix,
The cleanest way to do this (IMO) would be to separate your processing
into two steps: do the merge first, then style the resulting composite
document. There may be other ways, but my guess they'd be ugly and hackish.
As it happens I just had to do this for a current project. I find it
works well to do a "transclusion" pass, saving the result in a variable
and then just do "apply templates" on that variable.
Here's the basic technique I use:
<xsl:template match="/">
<xsl:choose>
<xsl:when test="//include"><!-- Any inclusions in top-level doc? -->
<xsl:variable name="transcluded-doc">
<xsl:call-template name="do-transclusion"/>
</xsl:variable>
<xsl:apply-templates select="$transcluded-doc" mode="normal"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="/" mode="normal"/>
</xsl:otherwise>
</xsl:when>
</xsl:template>
<xsl:template match="/" mode="normal">
<xsl:apply-templates/>
</xsl:template>
The "do-transclusion" template is just an identity transform plus
handling for the inclusions. If you want to be really sophisticated you
can do id and reference rewriting (for example, to implement XInclude in
a way that allows component documents to have the same ID values).
Cheers,
Eliot
--
W. Eliot Kimber, eliot(_at_)isogen(_dot_)com
Consultant, ISOGEN International
1016 La Posada Dr., Suite 240
Austin, TX 78752 Phone: 512.656.4139
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list