xsl-list
[Top] [All Lists]

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

2009-11-04 08:52:26

There are much more efficient ways of creating a pipeline than using "|" on
the command line, but presumably they are ruled out too.

There's no foolproof way of doing this without manually checking for
conflicting names of templates, global variables, keys etc. If you've been
very disciplined then these will all be in namespaces, and it will all be
much easier, but unless you are a very faithful disciple of Ken Holman then
this is unlikely to be the case.

You should change one of the stylesheets (or preferably both) to use named
modes on all template rules and calls of apply-templates.

Then finally you can stitch them together with

<xsl:template match="/">
  <xsl:variable name="temp">
    <xsl:apply-templates select="." mode="phase1"/>
  </xsl:variable>
  <xsl:apply-templates select="$temp" mode="phase2"/>
</xsl:template>

Alternatively, if you don't mind a product-specific solution, use
saxon:next-in-chain on the xsl:output element.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  


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?

Ben






--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--