search an XML node for a string

T

Thomas Patton

Hello

I was wandering if anyone could help me with this problem, I have the
following xsl file which searches the <description> node of my xml file.
This node can contain text with more than one word and white space e.g.

<catalog>
<product>
<item>shoes</item>
<description>white trainers</description>
</product>
</catalog>

At the moment, if I enter "white trainers" or "white trainers leather" in
the textfield on my html file, the desired results are output by the xsl
file.

I was wandering what code I could use instead of or along with <xsl:if
test="contains($text1, description)"> so that if I entered the following
queries, the results would also be output by the xsl file:-

white
White
trainers
TRAINERS
white green trainers

and "trainer" if possible, but this query is not really as important as the
others.

<?xml version="1.0"?>

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

<xsl:param name="text1" />

<xsl:template match="/">

<html>

<head>
<link rel="stylesheet" type="text/css" href="/web/files/mystyle.css" />
<title>Results</title>
</head>

<body>

<table width="600" border="1" align="center" cellpadding="0" cellspacing="0"
bordercolor="#FFFFFF">

<col width="100%" />

<tr>

<th class="fill">Item</th>

</tr>

<xsl:for-each select="catalog/product">
<xsl:if test="contains($text1, description)">

<tr>

<td align="center"><xsl:apply-templates select="./item" /></td>

</tr>

</xsl:if>

</xsl:for-each>

</table>

<div align="center">
<a href="/web/index.html">Click here to return to search page</a>
</div>

</body>

</html>

</xsl:template>

</xsl:stylesheet>



I would be very greatful for any help on this.

Thanks
Thomas
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top