Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2007, 05:57 AM
Registered User
 
Join Date: May 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default xslt searching data

lets say i got this xml code

<movie>
    <name> abc</name>
    <actor> james bond</actor>
    <speech>xslt and xml is cool technology </speech>
</movie>


Now i have writen a xslt style sheet. in the xslt,is it possible to search the xml's data content?
That is ,i want to search in the xml if a phrase "xml is cool" exists/part of the speech element.

If someone can share it woudl be great..thanx a lot

 
Old May 16th, 2007, 07:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Doing an "exact match" search is quite easy. A more fuzzy search, for example one in which multiple spaces or newlines are considered equivalent to a single space, on in which the text can span element boundaries, requires rather more care.

You don't say what output you want from your search. If it's a simple yes/no answer, then contains(/, "xml is cool") does the job. If you want to return the element(s) in which the text is contained, try //*[contains(., 'xml is cool')



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching Multiple Sheets for Data? Bill_L Excel VBA 2 June 20th, 2007 09:14 AM
xslt:fill data with dots blitzer XSLT 1 May 18th, 2007 03:04 AM
XSLT of an HTML data NEO1976 XSLT 3 July 5th, 2006 08:28 AM
searching match data in the worksheet ct Excel VBA 0 April 15th, 2006 12:00 AM
Need to format data in xslt emils XSLT 1 November 3rd, 2005 02:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.