[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: stylesheet expansion
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,
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|