possible to use an environmental variable to address the XSL file path?

K

Kourosh

I'm just wondering, is there a way I could use an environmental
variable in an XML file to specify the path of its XSL file? something
like

<?xml-stylesheet type="text/xsl" href="%test%\test.xsl" ?>
 
J

Joe Kesselman

Kourosh said:
I'm just wondering, is there a way I could use an environmental
variable in an XML file to specify the path of its XSL file?

XSLT itself can't access the system's environmental variables.

The usual solution is to use your XSLT processor's command-line options
(or API, if you're invoking it from another program) to pass the value
of the environment variable in as a stylesheet parameter. The exact
syntax varies depending on the processor.

Alternatively, you could write an extension function that retrieves
environment variable values. But that might have to be recoded if you
ever want to run on another processor.
 
J

Joe Kesselman

.... Oh. I misread. You want to use the variable in the path to find the
stylesheet in the first place.

The simple answer to that one is "no, or at least you can't count on
it". The more complicated answer is that this is a question of how the
specific tool (browser or whatever) interprets that processing
instruction. Some may let a user/developer plug in code that can help
them process URIs (a "URI Resolver"); others may have other ways of
handling this; others will simply not handle it.

But this inability to implicitly/automatically retrieve environment
variables is probably a Good Thing. I don't _want_ downloaded files
accessing anything else on my system unless I explicitly give them
permission to do so; that would be a security/privacy issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top