Page 1 of 1

Validate XPath on variable

Posted: Mon Aug 04, 2008 12:27 pm
by alk
Hi,

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:variable>
<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"/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
$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.

Cheers,
Alex