Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > search an XML node for a string

Reply
Thread Tools

search an XML node for a string

 
 
Thomas Patton
Guest
Posts: n/a
 
      08-11-2004
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="html"/>

<xslaram 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


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 16/07/2004


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Reading XML Node-by-Node Martin Honnen ASP .Net 0 11-12-2008 06:29 PM
Search a string inside an xml node lejason@gmail.com ASP General 0 03-20-2007 05:12 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
how to creating new node inside a xml node Geagleeye ASP General 2 08-03-2006 12:09 PM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM



Advertisments