[Newbie question] XSL select with parameter isn't working w/ fullXPATH expression

Discussion in 'XML' started by Werner Rudolf, Apr 14, 2005.

  1. Hello,
    this simple example below is working w/ Cocoon:
    URL: http://localhost:8888/c2/systems.html?xpa=Active
    XSL: <xsl:for-each select="/systems/system[status=$xpa]">

    For a simple application, it would be very usefull, if I could pass full
    XPATH expressions with the URL to gain better flexibility for queries.
    Something like:
    URL:
    http://localhost:8888/c2/systems.html?xpa=/systems/system[status=Active]
    XSL: <xsl:for-each select="$xpa">
    I just couldn't get this running.

    Passing parameters is not standard XSL, I know, but it seems to be
    rather a XSL issue than an Cocoon issue, isn't it?


    Many thanks and best regards,
    Werner
    Werner Rudolf, Apr 14, 2005
    #1
    1. Advertising

  2. Re: [Newbie question] XSL select with parameter isn't working w/ full XPATH expression

    Werner Rudolf <> writes:

    > Hello,
    > this simple example below is working w/ Cocoon:
    > URL: http://localhost:8888/c2/systems.html?xpa=Active
    > XSL: <xsl:for-each select="/systems/system[status=$xpa]">
    >
    > For a simple application, it would be very usefull, if I could pass full
    > XPATH expressions with the URL to gain better flexibility for queries.
    > Something like:
    > URL:
    > http://localhost:8888/c2/systems.html?xpa=/systems/system[status=Active]
    > XSL: <xsl:for-each select="$xpa">
    > I just couldn't get this running.
    >
    > Passing parameters is not standard XSL, I know, but it seems to be
    > rather a XSL issue than an Cocoon issue, isn't it?


    at least on the xsl side, you'll need to make sure that $xpa is a node
    set and not a string. If you pass in the string
    '/systems/system[status=Active]'
    then
    <xsl:for-each select="$xpa">
    is
    <xsl:for-each select="'/systems/system[status=Active]'">
    which is a fatal error.

    Most API's to XSLT engines (other than the command line) allow you to
    pass in a node set, that is you need to execute the XPath outside XSLT
    and then pass in the resulting node set as the parameter xpa of the
    stylesheet. Not sure how one would set that up in cocoon though

    alternatively you can pass in a string (which cocoon will do for you)
    see use-request-parametersin
    http://cocoon.apache.org/2.1/userdocs/transformers/xslt-transformer.html
    and then use an extension function in the stylesheet to evaluate that
    string as an xpath.
    saxon has saxon:evaluate() I think xalan has something similar.

    David
    David Carlisle, Apr 14, 2005
    #2
    1. Advertising

  3. Re: [Newbie question] XSL select with parameter isn't working w/full XPATH expression

    Hello David,
    wow, that has been a very fast answer!
    Many thanks for the hint with the evaluate function, I couldn't load it
    so far, got "No resolution for Xalan prefix" (or something like that),
    but I'll try again!

    Many thanks and best regards,
    Werner

    David Carlisle wrote:
    > Werner Rudolf <> writes:
    >
    >
    >>Hello,
    >>this simple example below is working w/ Cocoon:
    >>URL: http://localhost:8888/c2/systems.html?xpa=Active
    >>XSL: <xsl:for-each select="/systems/system[status=$xpa]">
    >>
    >>For a simple application, it would be very usefull, if I could pass full
    >>XPATH expressions with the URL to gain better flexibility for queries.
    >>Something like:
    >>URL:
    >>http://localhost:8888/c2/systems.html?xpa=/systems/system[status=Active]
    >>XSL: <xsl:for-each select="$xpa">
    >>I just couldn't get this running.
    >>
    >>Passing parameters is not standard XSL, I know, but it seems to be
    >>rather a XSL issue than an Cocoon issue, isn't it?

    >
    >
    > at least on the xsl side, you'll need to make sure that $xpa is a node
    > set and not a string. If you pass in the string
    > '/systems/system[status=Active]'
    > then
    > <xsl:for-each select="$xpa">
    > is
    > <xsl:for-each select="'/systems/system[status=Active]'">
    > which is a fatal error.
    >
    > Most API's to XSLT engines (other than the command line) allow you to
    > pass in a node set, that is you need to execute the XPath outside XSLT
    > and then pass in the resulting node set as the parameter xpa of the
    > stylesheet. Not sure how one would set that up in cocoon though
    >
    > alternatively you can pass in a string (which cocoon will do for you)
    > see use-request-parametersin
    > http://cocoon.apache.org/2.1/userdocs/transformers/xslt-transformer.html
    > and then use an extension function in the stylesheet to evaluate that
    > string as an xpath.
    > saxon has saxon:evaluate() I think xalan has something similar.
    >
    > David
    Werner Rudolf, Apr 15, 2005
    #3
    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. Replies:
    1
    Views:
    3,595
    A. Bolmarcich
    May 27, 2005
  2. Rob Smegma
    Replies:
    1
    Views:
    1,808
    shaun
    Sep 26, 2005
  3. mark4asp
    Replies:
    2
    Views:
    1,883
    mark4asp
    Dec 4, 2007
  4. palmiere
    Replies:
    1
    Views:
    396
    Erwin Moller
    Feb 9, 2004
  5. Mary Kline

    javascript parameter isn't passing

    Mary Kline, May 31, 2009, in forum: Javascript
    Replies:
    4
    Views:
    125
    Garrett Smith
    Jun 1, 2009
Loading...

Share This Page