Hi Geert,
Just in case someone's reading the archives, this is the result of my
little trials (mentioned earlier on in this thread). If you want:
a) to include all stylesheets into one stylesheet
b) to keep all the complex rules of apply-imports and next-match
c) to make sure you do not have to alter the included stylesheets
d) to even keep the root instructions and xsl:stylesheet instructions
intact
then the following approach might be of interest to you:
1) use an extension element prefix, i.e. "include"
2) place the complete stylesheets that need to be included inside this
extension element, on the root level
3) add an xml:id to the xsl:stylesheet element of the included stylesheet
4) place an xsl:import at the root and reference the current filename
with #xmlid-name (xpointer syntax)
5) create a junction point (windows) or a hard link (linux/unix)
pointing to the current directory and add this junction point to the
xsl:import href.
6) you can now run your concatenated stylesheet
I am under the impression that step nr (5) should not be necessary, as
you technically do not include the (whole) same stylesheet (giving you
error XTSE0210: "A stylesheet cannot import itself"), but well, it's
what the specs say I guess. To fool the processor we need a trick: the
junction point/hard link. Alternatives are: using a http location
(different FQDN name) or a local machine name named differently (i.e.,
through the hosts file).
The result could look something like the following (tried and tested). I
pointed the junction point "c:\xslt" to my workspace xslt test directory
to get it working (using "junction c:\xslt d:\workspaces\test_xslt").
Note the xsl:next-match, the place of xsl:output etc. They all work as
if these were ordinarily imported xsl files. The output should be:
text-main
text-included-2
text-included-1
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:include="http://include"
extension-element-prefixes="include">
<xsl:import
href="file:///c:/xslt/self-inclusion/multiple-stylesheets-in-one.xslt#include-me1"
/>
<xsl:import
href="file:///c:/xslt/self-inclusion/multiple-stylesheets-in-one.xslt#include-me2"
/>
<xsl:template match="/">
<xsl:text>text-main
</xsl:text>
<xsl:apply-imports />
</xsl:template>
<include:stylesheet use-when="0">
<xsl:stylesheet
xml:id="include-me1"
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:text>text-included-1
</xsl:text>
</xsl:template>
</xsl:stylesheet>
</include:stylesheet>
<include:stylesheet use-when="0">
<xsl:stylesheet
xml:id="include-me2"
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:text>text-included-2
</xsl:text>
<xsl:next-match />
</xsl:template>
</xsl:stylesheet>
</include:stylesheet>
</xsl:stylesheet>
Cheers & Merry Christmas and a happy New Year to all of you!
-- Abel Braaksma
Geert Bormans wrote:
Hi all,
I want to thank everybody for their valuable contributions to this
thread.
Compiled stylesheet modules were indeed a bit of topic.
My requirement was a single stylesheet file that was the result of
expanding all xsl:import statements
I ended up developing a stylesheet that looped over all the import
statements repeatedly,
in order to carefully group keys, parameters, functions and templates,
dropping the template match="/" from every stylesheet but the main
driver stylesheet
Since each of the imported files already had its functionality in
separate modes,
I could do this without much trouble
Thanks again for all suggestions
Geert
On 11/12/2007, Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com>
wrote:
> > It may be ideal for you, but it won't solve the OP's problem at all.
> > He will be in exactly the same situation as now.
>
> The OP said:
>
> "I have a stylesheet with a pipeline in it
> and a large set of imported stylesheets...
>
> I would like to deliver one expanded stylesheet."
>
> So the requirement is to be able to combine multiple stylesheets into
> a single deliverable...which "compiled stylesheet modules" would fit
> perfectly.
No it wouldn't. He wants one file, not several modules.
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--