Validate XPath on variable

Here should go questions about transforming XML with XSLT and FOP.
Posts: 32
Joined: Wed Jan 25, 2006 5:43 pm

Validate XPath on variable

Post by alk » Mon Aug 04, 2008 12:27 pm


can anybody tell me if something like the following is possible? I'm reading the content of an XML-file into a variable and would like to validate if an XPath expression which is defined in the context actually matches a node within the variable's temporary tree.

Code: Select all

<xsl:template name="ValidateXPath">
<xsl:param name="root"/>
<xsl:for-each select="$root/msg:Entry">
<xsl:variable name="SrcFile" select="concat( '../xml/' , msg:InputFile)"/>
<xsl:variable name="SrcContent">
<xsl:copy-of select="document($SrcFile)/child::*[1]"/>
<xsl:for-each select="msg:Values/msg:Value">
<xsl:if test="not($SrcContent[msg:XPathExpr])">
<xsl:message >No Match: </xsl:message>
<xsl:message select="msg:XPathExpr"/>
$srcContent contains the expected data und XPathExpr contains an XPath that, if applied to the document, would find a match. Nevertheless if combined as above it's just not working.

Any help is truly appreciated.