URL param to XSL - request for a confirmation

Discussion in 'XML' started by Emanuele D'Arrigo, Nov 28, 2004.

  1. 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
    Emanuele D'Arrigo, Nov 28, 2004
    #1
    1. Advertising

  2. 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.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 28, 2004
    #2
    1. Advertising

  3. Martin Honnen <> wrote in message
    > 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
    Emanuele D'Arrigo, Nov 29, 2004
    #3
  4. 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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 29, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geathaa
    Replies:
    2
    Views:
    683
    Geathaa
    Jul 30, 2003
  2. Karsten Weinert
    Replies:
    3
    Views:
    989
    Karsten Weinert
    Jul 5, 2004
  3. Replies:
    1
    Views:
    3,587
    A. Bolmarcich
    May 27, 2005
  4. ectoplasm
    Replies:
    12
    Views:
    625
    Zorro
    Jul 28, 2005
  5. Dave
    Replies:
    5
    Views:
    620
    John Bokma
    Apr 26, 2011
Loading...

Share This Page