Text search using parameter

Discussion in 'XML' started by jose.jeria@gmail.com, Jul 8, 2005.

  1. Guest

    I just started looking at XSLT, so bare with me if I totally
    misunderstood this.

    I am passing a value to the xslt that i want to use to search in some
    nodes. I have the following code for this (note the query parameter):

    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput
    media-type="text/xml"
    method="html"
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"
    encoding="UTF-8"/>

    <xsl:param name="query"/>

    <xsl:template match="/">
    <html>
    <head>
    <title>Search results</title>
    </head>

    <body>
    <h1>Found <xsl:value-of
    select="count(/airports/airport/country_name[starts-with(.,$query)])"/>
    countries</h1>
    </body>
    </html>
    </xsl:template>

    </xsl:stylesheet>

    Issue is that this doesn't work. If i "hardcode" a string it works. Do
    I need to convert it to a string first?

    Thank you for your help
    , Jul 8, 2005
    #1
    1. Advertising

  2. wrote:


    > <xsl:param name="query"/>


    > <h1>Found <xsl:value-of
    > select="count(/airports/airport/country_name[starts-with(.,$query)])"/>
    > countries</h1>


    > Issue is that this doesn't work. If i "hardcode" a string it works. Do
    > I need to convert it to a string first?


    How an external parameter value is passed to an XSLT processor is highly
    processor dependent so your "it doesn't work" experience can have many
    reasons, you will need to tell us which processor you use, how you use
    it (e.g. command line or perhaps from a certain programming language),
    how you try to set the parameter. Of course if it is processor specific
    it might be easier to find someone with experience on that topic on a
    processor specific mailing list.
    And what "doesn't work" mean exactly, does the stylesheet show "Found 0
    countries", does the processor give an error?

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jul 8, 2005
    #2
    1. Advertising

  3. Guest

    Yes, i got 0 hits. And I just realized why. I was not thinking about
    the case-sensivity in my search query...

    Sorry for have wasted your time, but thanks for taking the time to
    answer me.
    , Jul 8, 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.

Share This Page