Re: [xsl] use-when in the xsl:inlcude

Subject: Re: [xsl] use-when in the xsl:inlcude
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 30 Aug 2008 07:39:39 -0400
At 2008-08-30 12:49 +0300, Vladimir Nesterovsky wrote:
Is there something I can pass to xslt for it to evaluate that something in the use-when attribute in the xsl:inlcude, and xsl:import?
In particular I'm using saxon in java.

I think I have found a clean way to achieve the desired effect.
I'll define an uri resolver that among others will resolve uri like "configuration:data".


Thus I can write:

<xsl:include href="..." use-when="document('configuration:data')/data/xs:boolean(@xxx)"/>

I guess, this approach has a virtue to be almost processor independent.

Except that it won't work. Your use-when= above relies on *some* document context in order to determine the argument values for the document() function, but as I mentioned earlier all use-when= processing *must* happen before any input source tree is loaded. After all, there may be some top-level instructions in the imported stylesheet tree that impact on the source node tree.


So, in summary, the document() function cannot be used because it is *not* independent of the source node tree ... it needs to be executed in *some* source node tree context and there is no source node tree when the processor acts on use-when=.

I'm quite confident your proposed approach will not work ... you say you found it, but have you tried it?

I hope this helps.

. . . . . . . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread