[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: stylesheet expansion
Geert Bormans wrote:
Considering Colin's remarks, about xsl:next-match etc, it is an exercise which may be next to impossible (at least far from trivial), but I maybe wrong... Can you change the URIResolver? Because if you can, you can place all stylesheets into one stylesheet, id them (with xml:id), use use-when on them so they won't be called prematurely, and let the URIResolver resolve to parts of the same stylesheet (the id'ed parts). Probably the easiest to do (if this is an option at all) to use your own scheme so any existing schemes are not messed with. If XSLT 2.0 weren't too strict, you would have an easy solution as follows (which illustrates my idea, hopefully the indentation isn't messed with by my Thunderbird...): <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="multiple-stylesheets-in-one.xslt#include-me" /> <xsl:template match="/"> <xsl:text>text-main</xsl:text> </xsl:template> <include:stylesheet use-when="0"> <xsl:stylesheet xml:id="include-me" version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:text>text-include</xsl:text> </xsl:template> </xsl:stylesheet> </include:stylesheet> </xsl:stylesheet> Saxon will throw an "A stylesheet cannot import itself" error, even though you aren't really importing oneself. Which is why you will have to come up with your own scheme, or a location of your stylesheet which is not recognized by the processor as being the same: <xsl:import href="http://otherhost-to-same-location/multiple-stylesheets-in-one.xslt#include-me" /> but I don't know (not tested), if the #-syntax is supported this way (I remember a few W3C notes on the subject, but I can't recall whether it is legal and whether only the node with "include-me" will get selected). I'd be curious if this is a feasible path for you, if so, we can elaborate a bit on it. Cheers, -- Abel Braaksma PS: without the xsl:import the use of xsl:stylesheet inside the extension element is legal (at any other place it wouldn't), it is ignored by the XSLT processor.
|
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
|