Re: [xsl] import, xslt 2.1

Subject: Re: [xsl] import, xslt 2.1
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Mon, 15 Mar 2010 08:44:51 +0000
On 15/03/10 08:07, Dave Pawson wrote:
On 15/03/10 04:52, Max Toro wrote:
You can use a custom URIResolver to load xsl imports/includes.
--
Max

I used an Oasis catalog in the end. Same effect, less work :-)


On the conditional import, Andrew gave me the following solution,
may be of use to others and explain how use-when works.

I'm on Linux, so my shell is bash. OS environmental
variables are set using
set varname=value

to use this idea, I want to set an OS environmental variable,
copy that to a Java System Property (sort of an environmental
variable where the environment is Java?) then pass that into
the stylesheet.

My shell script looks like this.

cp=.:/myjava/saxon9he.jar:/myjava/xercesImpl.jar:/myjava/resolver.jar

f=false

    java -cp $cp:.  -Df=$f  net.sf.saxon.Transform \
-x  org.apache.xml.resolver.tools.ResolvingXMLReader \
-y org.apache.xml.resolver.tools.ResolvingXMLReader \
-r org.apache.xml.resolver.tools.CatalogResolver   -o $3  $1 $2



Note the continuation lines ending in \

f is the OS env var
passed into the java executable using -Df=$f, which assigns
the system property 'f' to the env var f
then in the stylesheet I use

<xsl:import href="/sgml/test/junit.xsl"
use-when="system-property('f')='true'"
/>

which only works when the OS env variable is set to 'true'









regards

--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

Current Thread