[xsl] Matching on text after embedded elements

Subject: [xsl] Matching on text after embedded elements
From: "Bruce Dailey" <bruce@xxxxxxxxxxxx>
Date: Tue, 3 Dec 2002 12:42:47 +0900
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


Current Thread