URL param to XSL - request for a confirmation

E

Emanuele D'Arrigo

Hi there!

I just spent the past couple of hours digging into the messages
of comp.text.xml trying to find a way to pass a parameter from
an URL to a XSL stylesheet.

I.e. having the url http://www.test.com/bla.xml?foo=1
I'd like to be able to create a variable in the xls file
named foo, whose content is 1.

From what I gather, this is not possible via xml/xsl alone.

Either something on the server provides the variable
or scripts (ie. javascript) have to be embedded in the files
loaded by the browser to retrieve that piece of information
from the url and somehow store it dynamically in the xml file
so that the xsl stylesheet can pick it up.

Do I stand correct? Did I miss something? Is there really no
easy way i.e. like PHP does, with $bla=$_GET['foo']? If that's
the case, I guess there's a good reason for having excluded
this important functionality, but it kind of defies me.
Anybody that could shed some light on this?

Any help would be appreciated.

Best regards,

Manu
 
M

Martin Honnen

Emanuele D'Arrigo wrote:

I just spent the past couple of hours digging into the messages
of comp.text.xml trying to find a way to pass a parameter from
an URL to a XSL stylesheet.

I.e. having the url http://www.test.com/bla.xml?foo=1
I'd like to be able to create a variable in the xls file
named foo, whose content is 1.

From what I gather, this is not possible via xml/xsl alone.

You can of course use your favourite server side scripting language to
read out any parameters passed in and then you can pass in parameters to
XSLT using the API of the XSLT processor you use.
Your stylesheet then needs to have
<xsl:param name="paramName" />
XSLT 1.0 has no means of reading url query strings, it is simply a
transformation language.
 
E

Emanuele D'Arrigo

Martin Honnen said:
You can of course use your favourite server side scripting language to
read out any parameters passed in and then you can pass in parameters to
XSLT using the API of the XSLT processor you use.

Thanks Martin for your quick reply.

I'm not sure if IE6.x and N7.xx can be
considered XSLT processors but that's what
I've been using so far.

I just begun dealing with xml and xslt
(like... this weekend) and altough I
did manage to reach my goals of translating
a previously html only page, I still need
to wrap hy head around the implication of
the ideas behind xsl and xslt, especially
in terms of what they can and cannot do
with an input xml file.

Coming from MySQL->PHP->HTML there are a few
things to be adjusted in the way I think
things work... =)


Again, thanks for your answer Martin.

Manu
 
M

Martin Honnen

Emanuele D'Arrigo wrote:

I'm not sure if IE6.x and N7.xx can be
considered XSLT processors but that's what
I've been using so far.

IE 6 uses MSXML 3 as the XSLT processor and that is indeed scriptable.
Netscape 7 also has an XSLT processor that is scriptable.
I just begun dealing with xml and xslt
(like... this weekend) and altough I
did manage to reach my goals of translating
a previously html only page, I still need
to wrap hy head around the implication of
the ideas behind xsl and xslt, especially
in terms of what they can and cannot do
with an input xml file.

Coming from MySQL->PHP->HTML there are a few
things to be adjusted in the way I think
things work... =)

There is an XSLT extension in PHP 4 using the Sablotron XSLT processor
and that is scriptable with PHP so there you could build a PHP page
reading the $_GET variables and passing them to the XSLT processor.
 

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

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top