Subject: [xsl] RE: From: Stuart Brown <sbrown@xxxxxxxxxxxxx> Date: Mon, 16 Sep 2002 16:48:33 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] select distinct, Trevor Nash | Thread | [xsl] Re:, Vasu Chakkera |
[xsl] select distinct, Noel Golding | Date | [xsl] Re:, Vasu Chakkera |
Month |