Text search using parameter

J

jose.jeria

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
 
M

Martin Honnen

<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?
 
J

jose.jeria

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.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top