[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Dynamically determine which XSLT files to include and import?


Subject: Re: [xsl] Dynamically determine which XSLT files to include and import?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Jul 2013 12:08:16 -0400

Have you considered massaging your XSLT before running it? Since an XSLT file is an XML file, it can be the input to another XSLT.

Step 1 - XSLT-A.xsl:
 - read input XML into a tree
 - process XSLT-B-RAW.xsl based on value X to synthesize <xsl:include>
   instructions when writing out stylesheet XSLT-B.xsl

Step 2 - XSLT-B.xsl:
 - read input XML into a tree
 - use massaged stylesheet

This may satisfy your requirement.

. . . . . . Ken

At 2013-07-29 11:36 -0400, I wrote:
At 2013-07-29 15:34 +0000, Costello, Roger L. wrote:
Is there a way for an XSLT program to, at runtime, decide which XSLT files to include and import?

Only based on environment issues at runtime by using use-when=, not by any data information.


I imagine something like this at the top of the XSLT program:

    if the input file has value X set then
        include A.xsl, B.xsl
    else
        include C.xsl, D.xsl

Any way to do this?

No, the source tree is not even built until the entire stylesheet has been interpreted because there are stylesheet instructions that impact on the building of the tree.


So by the time you have any input data in your tree, all stylesheet building has been completed.

I hope this helps understand the situation.

. . . . . . . . . . Ken


--
Public XSLT, XSL-FO, and UBL classes in the Netherlands     Oct 2013 |
Public XSLT, XSL-FO, UBL and code list classes in Australia Oct 2013 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


Current Thread
Keywords