xsl-list
[Top] [All Lists]

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

2009-11-04 08:21:44
2009/11/4 Ben Stover <bxstover(_at_)yahoo(_dot_)co(_dot_)uk>:
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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--