EXSLT error : XPath exception - Extension function not found: parse-date

I was trying to use date:parse-date function from EXSLT inside 3 parameter lookup like this:

AS:LookupValue('842f2dee-da09-4259-8d76-1acf332fe257', 'parameter1', /ROOT/DataId, 'parameter2', /ROOT/OtherId, 'parameter3', date:parse-date(/ROOT/datetime, 'yyyyMMddHHmmss'))

I was expecting It will work in Xpath update context task as it works in xslt transformation.

Instead I’ve got an error:

Origam.OrigamException: Extension function not found: parse-date
 ---> System.Xml.XPath.XPathException: Extension function not found: parse-date
   at Mvp.Xml.Exslt.ExsltContext.GetExtensionFunctionImplementation(Object obj, String name, XPathResultType[] argTypes)
   at Mvp.Xml.Exslt.ExsltContext.ResolveFunction(String prefix, String name, XPathResultType[] argTypes)
   at Origam.Rule.Xslt.OrigamXsltContext.ResolveFunction(String prefix, String name, XPathResultType[] ArgTypes) in D:\a\1\s\backend\Origam.Rule\Xslt\OrigamXsltContext.cs:line 104
   at MS.Internal.Xml.XPath.FunctionQuery.SetXsltContext(XsltContext context)
   at MS.Internal.Xml.XPath.FunctionQuery.SetXsltContext(XsltContext context)
   at MS.Internal.Xml.XPath.StringFunctions.SetXsltContext(XsltContext context)
   at MS.Internal.Xml.XPath.CompiledXpathExpr.SetContext(IXmlNamespaceResolver nsResolver)
   at MS.Internal.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager nsManager)
   at Origam.Rule.RuleEngine.EvaluateContext(String xpath, Object context, OrigamDataType dataType, AbstractDataStructure targetStructure) in D:\a\1\s\backend\Origam.Rule\RuleEngine.cs:line 436
   at Origam.Workflow.Tasks.UpdateContextEngineTask.OnExecute() in D:\a\1\s\backend\Origam.Workflow\Tasks\UpdateContextEngineTask.cs:line 45
   at Origam.Workflow.ProfilingTools.<>c__DisplayClass4_0.<ExecuteAndLogDuration>g__FuncToExecute|0() in D:\a\1\s\backend\Origam.Workflow\ProfilingTools.cs:line 63
   at Origam.Workflow.ProfilingTools.ExecuteAndLogDuration(Func`1 funcToExecute, String logEntryType, String path, String id, Func`1 logOnlyIf) in D:\a\1\s\backend\Origam.Workflow\ProfilingTools.cs:line 97
   at Origam.Workflow.ProfilingTools.ExecuteAndLogDuration(Action action, String logEntryType, String path, String id, Func`1 logOnlyIf) in D:\a\1\s\backend\Origam.Workflow\ProfilingTools.cs:line 66
   at Origam.Workflow.Tasks.AbstractWorkflowEngineTask.MeasuredExecution() in D:\a\1\s\backend\Origam.Workflow\Tasks\AbstractWorkflowEngineTask.cs:line 99
   at Origam.Workflow.Tasks.AbstractWorkflowEngineTask.Execute() in D:\a\1\s\backend\Origam.Workflow\Tasks\AbstractWorkflowEngineTask.cs:line 110
   --- End of inner exception stack trace ---

When I replace the date:date-parse function with different EXSLT function like date:date-time(), the lookup works well. Are all the EXSLT namespaces implemented as it was discussed here ?

We are using a library and it seems that the date-parse function is implemented with one argument only – date. So it does not support a custom mask.

Are you sure it is not implemented as 2 parameter function? Because when I try to use it in XSLT transformation, it work as expected. For test you can use any transformation - see attached picture with output windows as result.
image

@tvavrda there is a 2 parameter definition :

I can’t repreduce the problem. Can you provide sample? Data and transformation which fails.

Try to use such a lookup with date:parse-date function in UpdateContextTask step as ValueXPath. It throw me the error. The same lookup works well in xslt transformation.

Data:

<ROOT>
  <type>LL</type>
  <loaderId>78e41e83-9a40-471b-baad-3f5e30dce863</loaderId>
  <dumpId>ee775014-e406-4c48-abd4-09c07290ce7a</dumpId>
  <timeStart>20240924141005</timeStart>
</ROOT>

and Lookup with this parameters:

AS:LookupValue('8f623352-bfaf-4e7a-bf56-1e9be280ca96', 'OnWay_par_DumpId', /ROOT/dumpId, 'OnWay_parFleetVehicleIdId', /ROOT/loaderId, 'OnWay_parLoadTimeStart', date:parse-date(/ROOT/timeStart, 'yyyyMMddHHmmss'))

date:parse-date definition:

string date:parse-date(string, string)

XPath you’re requesting when compiled ends up by searching for following function

string date:parse-date(nodeSet, string)

and thus can’t be found.

The solution is to force the first argument of the function to string as well. This can be done with AS:NodeToString.

AS:LookupValue(
    '8f623352-bfaf-4e7a-bf56-1e9be280ca96', 
    'OnWay_par_DumpId', 
    /ROOT/dumpId,
    'OnWay_parFleetVehicleIdId',
    /ROOT/loaderId,
    'OnWay_parLoadTimeStart',
    date:parse-date(AS:NodeToString(/ROOT/timeStart), 'yyyyMMddHHmmss'))

There are no plans to adjust this behaviour.

Thank you! This works well. This solution led me to the idea of trying to use the string function and it works in this case as well.

.... date:parse-date(string(/ROOT/timeStart), 'yyyyMMddHHmmss')
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.