Re: [xsl] How to concatenate/merge two independent XSLT stylesheets into ONE stylesheet?

Subject: Re: [xsl] How to concatenate/merge two independent XSLT stylesheets into ONE stylesheet?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 4 Nov 2009 13:21:14 +0000
2009/11/4 Ben Stover <bxstover@xxxxxxxxxxx>:
> I have two independent XSLT style sheets which work fine when they are executed
> in two steps:
>
> mydoc1.xml-->mysheet1.xsl-->mydoc2.xml-->mysheet2.xsl-->mydoc3.xml
>
> However I would like to avoid the intermediate step (and the creation of mydoc2.xml).
> Is there a way to concatenate the two XSLT stylesheets resp. use the output of
> the first stylesheet templates as input of second stylesheet templates?
>
> Due to other requirements a piping with the well known pipe symbol (|) on the console
> is NOT allowed. The two stylesheets MUST be merged together somehow into ONE physical
> stylesheet file.
>
> How can I do this?

In the simplest scenario its just case of creating a "mysheet3.xsl"
that imports the other 2 :

<xsl:import href="mysheet1.xsl"/>
<xsl:import href="mysheet2.xsl"/>

<xsl:variable name="pass1">
  <xsl:for-each select="doc('mydoc1.xml')">
    <xsl:apply-templates/>
  </xsl:for-each>
<xsl:variable>

<xsl:template match="/">
  <xsl:apply-templates select="$pass1/*"/>
</xsl:template>

However this will only go smoothly if the elements in mydoc1.xml and
the intermediate "mydoc2" are different... if some are the same to
avoid the first pass templates confictling with the second pass (and
vice versa) then you'll need to use modes.


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread