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

RE: Matching on text after embedded elements

Subject: RE: Matching on text after embedded elements
From: "Robert Koberg" <rob@xxxxxxxxxx>
Date: Mon, 2 Dec 2002 20:15:59 -0800
xsl if embedded
Hi,

I am not really following you, but how about something like this (a little
variation of off a Jeni T. answer):

<xsl:key name="text" match="text()" use="'text'"/>

<xsl:template match="/">
  <xsl:for-each select="key('text', 'text')">
    <xsl:if test="contains(., 'YYY')">
    boo
    </xsl:if>
  </xsl:for-each>

</xsl:template>

pretty slick, huh :)

best,
-Rob



> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Bruce Dailey
> Sent: Monday, December 02, 2002 7:43 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Matching on text after embedded elements
>
>
> I am writing a search engine for a XML file. I am having a problem
> figuring out the correct XSL to get the "contains" to find text after a
> child element. This is the example XML file (TMX format).
>
> <tmx><body>
>
> <tu>
> <tuv lang="JA"><seg></seg></tuv>
> <tuv lang="EN-US"><seg>XXX<ut>eeee</ut>YYY</seg></tuv>
> </tu>
>
> </body></tmx>
>
> In this case if I search for "XXX", my search algorithm works. But if I
> enter "YYY" it fails. I have determined that my algorithm fails if it
> tries to find something after the first child element ("<ut>") occurs.
> Here is the XSL code:
>
> <xsl:template match="tu">
> 	<xsl:if test="tuv/seg[contains (text(), $SearchText)] or
> $SearchText=''">
> 		<xsl:copy><!--copy node being visited-->
> 			<xsl:copy-of select="@*"/><!--copy of all
> attributes-->
> 			<xsl:apply-templates/><!--process the
> children-->
> 		</xsl:copy>
> 	</xsl:if>
> </xsl:template>
>
> <xsl:template match="tuv | seg">
> 	<xsl:copy><!--copy node being visited-->
> 		<xsl:copy-of select="@*"/><!--copy of all attributes-->
> 		<xsl:apply-templates/><!--process the children-->
> 	</xsl:copy>
> </xsl:template>
>
> <xsl:template match="ut" />
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>



 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.