3

I've been trying to implement dynamic evaluation of an expression using Exslt extension dyn:evaluate($expression) in XSLT1.0, but I'm getting the below error.

BW-XML-100006 Job-261000 Error in [Transform_MCIN_XML/Dyn.process/Transform XML]
The [net.sf.saxon.trans.XPathException] occurred during XSLT transformation:  
net.sf.saxon.trans.XPathException: 
Cannot find a matching 1-argument function named {http://exslt.org/dynamic}evaluate()
caused by: ; SystemID: tibcr://; Line#: 6; Column#: -1
net.sf.saxon.trans.XPathException: 
Cannot find a matching 1-argument function named {http://exslt.org/dynamic}evaluate()

I'm able to do the same using saxon:evaluate($expr) in Saxon-B XSLT 2.0 engine. However I need to do this in XSLT 1.0.

How to resolve this error and implement the same in XSLT 1.0 in Tibco BW?

Any suggestions would be highly appreciated.

Thank you.

Sample XSLT:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
 xmlns:dyn="http://exslt.org/dynamic"
 extension-element-prefixes="dyn">
    <xsl:variable name="expr" select="not(1=1)"/>
  <xsl:template match="/">
   <eval>
     <xsl:value-of select="dyn:evaluate($expr)"/>
   </eval>
  </xsl:template>
</xsl:stylesheet>
Guru
  • 37
  • 6
  • 1
    I don't understand why you want to restrict yourself to using XSLT 1.0 with EXSLT extension as the error message citing `net.sf.saxon.trans` clearly indicates you use some version of Saxon 8 or 9 that should support XSLT 2.0 and Saxon specific extensions. – Martin Honnen Nov 12 '13 at 13:59
  • I'm trying to achieve this in xslt 1.0 because the date validation is simple in here(tib:validate-dateTime()). Is there any single line date validation function available in XSLT2.0? – Guru Nov 13 '13 at 07:07
  • I am not familiar with tibco and its functions. With XSLT/XPath 2.0 to check whether a string can be parsed as an `xs:dateTime` value you can check `foo castable as xs:dateTime`. That tries to parse according to the W3C schema `xs:dateTime` syntax `yyyy-mm-ddThh:mm:ss` plus optional time zone information, see http://www.w3.org/TR/xmlschema-2/#dateTime for details. For other formats you would need to write a regular expression and/or extract components and check them respectively try to construct a `dateTime`. – Martin Honnen Nov 13 '13 at 10:16

1 Answers1

1

Use tib:evaluate instead of dyn:evaluate.

Depending on what else your BW process contains, you may need to add the namespace below to the process in order to use the tib:evaluate() function:

namespace=http://www.tibco.com/bw/xslt/custom-functions
prefix=tib

To do that you would select the process, click the "namespace registry" button, and add the namespace above.

Tom Howard
  • 6,516
  • 35
  • 58
  • Thanks Tom. Although this works for static conditions something like "1=1" but the same isn't working for dynamic conditions like a field value taken from the input xml. Something like checking a particular field for a specific value. Is there any solution for this? – Guru Nov 13 '13 at 07:12
  • Please update the question with the actual problem you are trying to solve, rather than the solution that isn't working. – Tom Howard Nov 13 '13 at 11:27
  • The dynamic evaluation using tib:evaluate is working. There was some issue with my bw. Resolved it now. Thanks for your suggestion. – Guru Nov 14 '13 at 08:18
  • Can you please look into the bellow link and suggest me how do implements this. http://stackoverflow.com/questions/21187495/iterating-over-xmls-and-dynamically-evaluating-conditions-using-xslt?noredirect=1#comment31902793_21187495 – Guru Jan 20 '14 at 09:40