Kinda the point of XSL is simply transforming XML as input into
something (html, xml, or other) as output.
The "right" way to do this, if you have any control over what's
generating the XML that is "input" to your XSL, is to have relevant (or
all) environmental variables included in the XML that's input the XSL in
the first place.
There maybe other ways that aren't as elegant, as everyone else has
said, it will depend on your particular environment. Because that's not
really what XSL is designed to do.
Jon Gorman wrote:
> Hi Michael,
>
> Only have time for a quick response. Like Jonathan Rochkind said,
> there's not really a built in way into XSL to refer to these things
> like some other languages. The reason is typically the XSL processor
> is used by some other language/system to transform a stylesheet, not
> connected directly to the web server. The cgi example works because
> you have mod_perl or something similar to set the variables. In this
> case tomcat and the underlying java programs are going to be a layer
> between the web server and the actual XSL sheets. (There's another
> model where you send both the xml and the xsl to the client and the
> client transforms it, but that's been problematic iin the past).
>
> That being said, XSL does support parameters that can be passed into
> the stylesheet. I know I've used java-type environments that used XSL
> that made sure to pass on any "environmental" and http-based variables
> in the stylesheet. At this point perhaps tomcat and saxon (I'd guess
> it's using saxon, maybe xalan) might be more tightly intergrated.
>
> Given the application I would suspect you're using though, I wouldn't
> count on those types of variables being passed in. If they are, they
> might not be documentted. If you poke around the xsl files and they
> are, you might see something like xsl:param name="myils:server" or
> something.. The trick I've seen with a lot of these that you'll have
> to explicitly state the parameter at the top in order to use it.
> Various parsers might have a way to have the processor dump out what
> parameters were passed into it, but I can't think of any off hand.
> Many processors have system-properties, and in fact I think they all
> are supposed to implement ...system-property('xsl:vendor'). I seem to
> remember some processor extending this function to include some other
> properties.
>
> You might also want to look at
> http://www.mulberrytech.com/xsl/xsl-list/processor-version.xsl (view
> source) for some ideas on how to get a better grip on what XSLT
> processor is being used.
>
> (The XSL FAQ is long and a little confusing, but has gret nuggets of
> information).
> http://www.dpawson.co.uk/xsl/sect2/sect21.html
>
>
> Sorry I can't be of more help.
>
> Jon Gorman
>
>
|