[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: stylesheet expansion

Subject: Re: stylesheet expansion
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 10 Dec 2007 01:28:22 +0100
Re:  stylesheet expansion
Geert Bormans wrote:

Correct, I will maintain them separately of course,
but my customer has to fit the chain in, in an application that is not to be touched.
I will deliver in seperate stylesheets, but I would like to have some backup if the importing should fail, caused by path issues eg.
(I have no control over the execution environment)

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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.