Validate XPath on variable

Here should go questions about transforming XML with XSLT and FOP.
alk
Posts: 31

Validate XPath on variable

Mon Aug 04, 2008 12:27 pm

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

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 2 guests