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

Subject: [xsl] Conditional Import of stylesheet depending on passed Param possible?
From: "William Reilly" <wreilly@xxxxxxxxxxx>
Date: Tue, 27 Aug 2002 06:08:32 -0400
Greetings.
 
I'm looking to confirm my understanding that I *cannot* do what I'd like here.  Thx.
------------------------------------------------------------------------------------
 
My "CT10" stylesheet (like my CT20, CT30 etc.) imports a "core" CT00 stylesheet.  (see snippets below)
That's working fine. (Xalan command-line)
 
The problem (not a big one, but...) is that I am developing in two environments (Windows, local, IDE) + (Unix, server, CMS), and thus have two paths to certain assets, including stylesheets.
 
In both environments, I am successfully using the (optional, essentially) passed Parameter ['environment=WINDOWS'] to use <xsl:choose> to accomplish some path logic (see inside CT00_core snippet below), but I believe that I CANNOT get that Parameter and <xsl:choose> logic ahead of the <xsl:import> statement itself (that must come first) (see "NICE TO HAVE" snippet further below).
 
And so I am hand-editing (commenting out) the path to Windows or to Unix as appropriate, between environments.  Ah well.
 
> So, just looking to confirm I can't improve on this. (And of course wondering if some other approach can help...)
.......Also, getting past developing in two environments (eventually) will help :>)
 
> Note: 
I have seen some recent posts indicating that instead of specific XSLTs importing the general, to reverse that and have the general call the specific -- that was based on XSLT processor version issues.
That looks temptingly like the/an answer here, but even with that I still have the little conundrum of needing to know--immediately, first line--if I'm passed the "I'm on Windows this time" Parameter or not.  I think I can't.
 
Thanks v. much,
William Reilly
wreilly@xxxxxxxxxxx
Boston, Massachusetts U.S.A.
 
== CT00_core.xslt (snippet) ===
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:param name="environment"/>
 
 <xsl:variable name="path">
  <xsl:choose>
   <xsl:when test="$environment='WINDOWS'">
      <xsl:text>../misc/</xsl:text> 
   </xsl:when>
   <xsl:otherwise>
      <xsl:text>/var/FutureTense/export/mlnm/misc/</xsl:text>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
===============
 
 
CURRENTLY DO HAVE:
== CT10_core.xslt (snippet) === ON WINDOWS
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<!-- <xsl:import href="/var/FutureTense/export/mlnm/xsl/ct00_core.xslt"/> -->
 <xsl:import href="ct00_core.xslt"/> 

========================
 
CURRENTLY DO HAVE:
== CT10_core.xslt (snippet) === ON UNIX SYSTEM
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:import href="/var/FutureTense/export/mlnm/xsl/ct00_core.xslt"/> 
<!-- <xsl:import href="ct00_core.xslt"/> -->

========================
 
 
 
*** NICE TO HAVE.... **** (but, I expect I can't...)
== CT10_core.xslt (snippet) === ON BOTH (!?)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:param name="environment"/>
 
  <xsl:choose>
   <xsl:when test="$environment='WINDOWS'">
        <xsl:import href="ct00_core.xslt"/>
   </xsl:when>
   <xsl:otherwise>
          <xsl:import href="/var/FutureTense/export/mlnm/xsl/ct00_core.xslt"/> 
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
======================
 
 
 
ALL ON ONE LINE (pasteable):
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

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
 
 ***************************************************** 
 

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


Current Thread