Re: [xsl] Conditional Import of stylesheet depending on passed Param possible?

Subject: Re: [xsl] Conditional Import of stylesheet depending on passed Param possible?
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 27 Aug 2002 12:28:51 -0600 (MDT)
William Reilly wrote:
> COMMAND LINE (exploded for legibility)
>  C:\jakarta-tomcat-4.0.3\webapps\ROOT\mlnmdev>
>  java
>  org.apache.xalan.xslt.Process
>  -IN BusinessML\2002-07-16-0_summary.xml
>  -XSL xsl\ct11_press_release_summary.xslt
>  -OUT StructureML\2002-07-16-0_summary.xml
>  -PARAM environment WINDOWS
   
As others mentioned, you can't do conditional imports within XSLT. No one told
what you could do, though. Obviously you are relying on the user to know what
the underlying platform is, in order to set $environment. Well, instead of
setting $environment to 'WINDOWS', the user could just invoke a
Windows-specific stylesheet that sets $path to what it needs to be for
Windows, and then imports the generic stylesheet, which tries (but fails, due
to lower import precedence) to set $path to the Unix one. If they're not on
Windows, they can just invoke the generic stylesheet. It might be worth
writing a wrapper that invokes Xalan via JAXP; the wrapper can choose the
right stylesheet. If you need to do multiple transforms, you'll want the 
wrapper anyway, so you can recycle the compiled stylesheets and avoid JVM 
startup overhead.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread