xsl-list
[Top] [All Lists]

[xsl] [XSLT 3.0] A more efficient way to xsl:evaluate a bunch of XPath expressions against an XML document?

2012-11-11 07:02:11
Hi Folks,

I have a bunch of xpath expressions stored in a file, xpaths.xml

I want to evaluate each of them against an XML document.

Here's how I implemented it:

    <xsl:variable name="xpaths" select="doc('xpaths.xml')" />
    
    <xsl:template match="Document">
        <xsl:variable name="here" select="." />
        <xsl:for-each select="$xpaths//xpath">
            <xsl:variable name="xpath" select="." />
            <xsl:for-each select="$here">
                <xsl:evaluate xpath="$xpath" as="xs:boolean" />
            </xsl:for-each>
        </xsl:for-each>
    </xsl:template>

I don't like that solution. Notice that I have a for-loop that spins through 
each xpath expression. Then, in that for-loop I have an inner for-loop that 
resets the context to the XML document. And in there is the xsl:evaluate 
statement. This seems like an awful way to implement it. 

Is there a better (simpler, more efficient) way to implement this?

/Roger

--~------------------------------------------------------------------
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>
--~--