[xsl] Finding Non-Matching Text

Subject: [xsl] Finding Non-Matching Text
From: Jeff Sese <jsese@xxxxxxxxxxxx>
Date: Wed, 18 Apr 2007 21:54:13 +0800
Hi,

I have a reference file like this:

<root>
   <entry>text 1</entry>
   <entry>text 2</entry>
</root>

the entry elements may reach up to more than a thousand. I need to generate a list of entry elements that does not have a match in my source xml.

my source xml looks like:

<source>
   <head>some text 1 some text some text some text</head>
</source>

what i do in my xslt is to iterate each of the entry elements and try to look for a match if there is none then i report it.

<xsl:template match="/">
<xsl:for-each select="$refence.file/entry">
<xsl:if test="not(exists(//text()[ancestor::head][matches(., concat('(^|\W)(',current(),')($|\W)'))]))">
<xsl:message>
<xsl:value-of select="."/>
</xsl:message>
</xsl:if>
</xsl:for-each>
</xsl:template>


but this method tends to be rather slow when i have a reference file that has many entries. Is there another way to go around this, by keys maybe?

Thanks,
--
*Jeff*

Current Thread