This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]