xsl-list
[Top] [All Lists]

[xsl] Finding Non-Matching Text

2007-04-18 06:54:03
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*


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>