Passing parameters to XSLT from the URL

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Passing parameters to XSLT from the URL

JJ Merelo
Hi,
I'm trying to do this: I have an XML document with a XSLT stylesheet
attached,
--
<?xml version="1.0" encoding='ISO-8859-1'?>
<?xml-stylesheet href="tiendecilla-html.xsl" type="text/xsl"?>

<tienda>
--
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name='seccion' />

<xsl:template match='/'>
  <html>
        <xsl:apply-templates />
  </html>
</xsl:template>

<xsl:template match='tienda'>
     <head><title><xsl:value-of select='nombre' /> (Generado por
tiendecilla-html-1.xsl)</title></head>
     <body>
        <h1><xsl:value-of select='nombre' /> Sección : <xsl:value-of
select='$seccion' />
</h1>
...
--
Which I call with this url:
file:///home/jmerelo/public_html/tutoriales/XSLT/tiendecilla.xml?seccion=Muebles

But it does not work; the param seccion does not get instantiated.
What's the problem? Does the XSLT processor in Mozilla handle params
only if they're sent by the server (I didn't try that, but, in any
case, I'd like to use it stand-alone) Should parameters be sent any
other way?

Thanks!

JJ

_______________________________________________
dev-tech-xslt mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xslt
Reply | Threaded
Open this post in threaded view
|

Re: Passing parameters to XSLT from the URL

Martin Honnen-3
JJ Merelo wrote:


> <xsl:param name='seccion' />


> Which I call with this url:
> file:///home/jmerelo/public_html/tutoriales/XSLT/tiendecilla.xml?seccion=Muebles
>
> But it does not work; the param seccion does not get instantiated.
> What's the problem? Does the XSLT processor in Mozilla handle params
> only if they're sent by the server (I didn't try that, but, in any
> case, I'd like to use it stand-alone) Should parameters be sent any
> other way?


Parameters have be set with the API the XSLT processor exposes, so in
case of Mozilla you can instantiate new XSLTProcessor(), load a
stylesheet, set parameters, run the transformation, see
<http://developer.mozilla.org/en/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations>

There is nothing in the XSLT specification suggesting that global
parameters should be set from the query string of the URL of an XML
document to which a transformation is applied.


--

        Martin Honnen
        http://JavaScript.FAQTs.com/
_______________________________________________
dev-tech-xslt mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xslt
Reply | Threaded
Open this post in threaded view
|

Re: Passing parameters to XSLT from the URL

Jonas Sicking
Additionally, in FF2 and on you can pass parameters using a new
processing instructions, <?xslt-param?>. You can read all the docs here:

http://wiki.mozilla.org/XSLT_PI_Parameters

Using this you could use CGI to set parameters through your xml file.

/ Jonas

Martin Honnen wrote:

> JJ Merelo wrote:
>
>
>> <xsl:param name='seccion' />
>
>
>> Which I call with this url:
>> file:///home/jmerelo/public_html/tutoriales/XSLT/tiendecilla.xml?seccion=Muebles
>>
>>
>> But it does not work; the param seccion does not get instantiated.
>> What's the problem? Does the XSLT processor in Mozilla handle params
>> only if they're sent by the server (I didn't try that, but, in any
>> case, I'd like to use it stand-alone) Should parameters be sent any
>> other way?
>
>
> Parameters have be set with the API the XSLT processor exposes, so in
> case of Mozilla you can instantiate new XSLTProcessor(), load a
> stylesheet, set parameters, run the transformation, see
> <http://developer.mozilla.org/en/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations>
>
>
> There is nothing in the XSLT specification suggesting that global
> parameters should be set from the query string of the URL of an XML
> document to which a transformation is applied.
>
>
_______________________________________________
dev-tech-xslt mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xslt
Reply | Threaded
Open this post in threaded view
|

Re: Passing parameters to XSLT from the URL

Mikee2185
Hi,
I've created a xsl that passes the parameters to the target trasnform using javascript.
Short doc about it is at
http://maplus.xf.cz/xslt/

Enjoy@

Jonas Sicking wrote
Additionally, in FF2 and on you can pass parameters using a new
processing instructions, <?xslt-param?>. You can read all the docs here:

http://wiki.mozilla.org/XSLT_PI_Parameters

Using this you could use CGI to set parameters through your xml file.

/ Jonas

Martin Honnen wrote:
> JJ Merelo wrote:
>
>
>> <xsl:param name='seccion' />
>
>
>> Which I call with this url:
>> file:///home/jmerelo/public_html/tutoriales/XSLT/tiendecilla.xml?seccion=Muebles
>>
>>
>> But it does not work; the param seccion does not get instantiated.
>> What's the problem? Does the XSLT processor in Mozilla handle params
>> only if they're sent by the server (I didn't try that, but, in any
>> case, I'd like to use it stand-alone) Should parameters be sent any
>> other way?
>
>
> Parameters have be set with the API the XSLT processor exposes, so in
> case of Mozilla you can instantiate new XSLTProcessor(), load a
> stylesheet, set parameters, run the transformation, see
> <http://developer.mozilla.org/en/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations
>
>
> There is nothing in the XSLT specification suggesting that global
> parameters should be set from the query string of the URL of an XML
> document to which a transformation is applied.
>
>
_______________________________________________
dev-tech-xslt mailing list
dev-tech-xslt@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-xslt