[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE:

Subject: RE:
From: Stuart Brown <sbrown@xxxxxxxxxxxxx>
Date: Mon, 16 Sep 2002 16:48:33 +0100
 RE:
Hi Brian,

> I have an XML file with this structure:
> 
> <elemA>
>     <elemB>
>         <elemC></elemC>
>         <elemC></elemC>
>         etc...
>    </elemB>
>    <elemB> 
>         <elemC></elemC>
>         <elemC></elemC>
>         etc...
>    </elemB>
>    etc...
> </elemA>
> 
> I am writing an XSL file to search it. I want to be able to 
> search all of
> the <elemC> nodes for the occurrence of a searchstring - and, 
> if an <elemC>
> node matches the searchstring, to output the value of the 
> first <elemC> node
> of the <elemB> node that contains the matching <elemC> node. 
> I hope that
> makes sense! I haven't been able yet to get the XSL to 
> process each of the
> <elemC> nodes of each of the <elemB> nodes systematically.

To rephrase what you want a bit, you want to match/select all the <elemB>
nodes which contain an <elemC> which itself contains the searchstring, and
output the first <elemC> of that element. Try:

<xsl:param name="string" select="'foo'"/>

<xsl:for-each select="elemA/elemB[contains(elemC,$string)]">
  <xsl:value-of select="elemC[1]"/>
</xsl:for-each>

Or similar.

Cheers,

Stuart

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.