Hi ESB Team,

Please find the summary of issues encountered while testing the XPath 2.0
functions at [1] ( referred [2] & [3] for syntax) and really appreciate
your input on this


*1. "Invalid XPath Syntax" occurs when saving the synapse configuration in
management console*

This error occurs for below functions:

   - avg- fn:avg((1,2,3,4,5))
   - codepoints-to-string - fn:codepoints-to-string((97, 32, 98, 32, 99)))
   - distinct-values - fn:distinct-values( ('a', 'b', 'a') ) -This is
   supported when passing the value as an xml payload
   - id - //book/section/secRef/fn:id(@refs)
   - idref - //book/idref('language')/string(.)
   - index-of - fn:index-of( (4, 5, 6, 4), 4)
   - max- fn:max((2,3,5))
   - min - fn:min((2,3,5))
   - remove - fn:remove( ('a', 'b', 'c'), 2)
   - reverse - fn:reverse((1, 2, 3, 4, 5))  -This is supported when passing
   the value as an xml payload
   - string-join - string-join( ('a', 'b', 'c'), '')
   - subsequence - fn:subsequence(('a', 'b', 'c', 'd', 'e'), 3)


*2. Issues in using error() function*

According to https://www.w3.org/TR/xpath-functions-30/#ERRFOER0000 ,
calling the function with empty parameters should give an unidentified
error. But when invoking the service it gives below exception

Is this accepted?

ERROR - SynapseXPath Evaluation of the XPath expression fn:error() resulted
in an error
; Line#: 1; Column#: -1
net.sf.saxon.trans.XPathException: Error signalled by application call on
error()
at net.sf.saxon.functions.Error.error(Error.java:98)
at net.sf.saxon.functions.Error.evaluateItem(Error.java:55)
at net.sf.saxon.expr.Expression.iterate(Expression.java:429)
at
net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:326)
at
net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:389)
at
org.apache.synapse.util.xpath.SynapseXPath.evaluateDOMXPath(SynapseXPath.java:533)
at
org.apache.synapse.util.xpath.SynapseXPath.stringValueOf(SynapseXPath.java:367)
at
org.apache.synapse.mediators.MediatorProperty.getEvaluatedExpression(MediatorProperty.java:138)
at
org.apache.synapse.mediators.builtin.LogMediator.setCustomProperties(LogMediator.java:223)
at
org.apache.synapse.mediators.builtin.LogMediator.getCustomLogMessage(LogMediator.java:146)
at
org.apache.synapse.mediators.builtin.LogMediator.getLogMessage(LogMediator.java:132)
at
org.apache.synapse.mediators.builtin.LogMediator.mediate(LogMediator.java:101)
at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:54)
at
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at
org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:210)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at
org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:398)
at
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:145)
at
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)


*3. "System function is not available with this host language/version"
occurs when invoking the service*

According to <https://mail.google.com/mail/u/0/goog_627243550>
https://sourceforge.net/p/saxon/mailman/saxon-help/thread/50f7f8b9.4090...@falutin.net/
, it seems this is an XSLT function, is that the reason for getting the
below error?  but at [1] this function is declared as an XPath function


[2016-08-02 12:47:27,875] ERROR - SynapseXPath Evaluation of the XPath
expression fn:format-date(fn:current-date(), '[Y01]/[M01]/[D01]') resulted
in an error
net.sf.saxon.trans.XPathException: System function format-date#2 is not
available with this host language/version
at
net.sf.saxon.expr.parser.ExpressionParser.grumble(ExpressionParser.java:263)
at
net.sf.saxon.expr.parser.ExpressionParser.parseFunctionCall(ExpressionParser.java:2375)
at
net.sf.saxon.expr.parser.ExpressionParser.parseBasicStep(ExpressionParser.java:1731)
at
net.sf.saxon.expr.parser.ExpressionParser.parseStepExpression(ExpressionParser.java:1654)
at
net.sf.saxon.expr.parser.ExpressionParser.parseRelativePath(ExpressionParser.java:1573)
at
net.sf.saxon.expr.parser.ExpressionParser.parsePathExpression(ExpressionParser.java:1557)
at
net.sf.saxon.expr.parser.ExpressionParser.parseUnaryExpression(ExpressionParser.java:1447)
at
net.sf.saxon.expr.parser.ExpressionParser.parseExprSingle(ExpressionParser.java:517)
at
net.sf.saxon.expr.parser.ExpressionParser.parseExpression(ExpressionParser.java:455)
at
net.sf.saxon.expr.parser.ExpressionParser.parse(ExpressionParser.java:391)
at net.sf.saxon.expr.parser.ExpressionTool.make(ExpressionTool.java:94)
at
net.sf.saxon.xpath.XPathEvaluator.createExpressionInternal(XPathEvaluator.java:235)
at net.sf.saxon.xpath.XPathEvaluator.compile(XPathEvaluator.java:376)
at
org.apache.synapse.util.xpath.SynapseXPath.evaluateDOMXPath(SynapseXPath.java:532)
at
org.apache.synapse.util.xpath.SynapseXPath.stringValueOf(SynapseXPath.java:367)
at
org.apache.synapse.mediators.MediatorProperty.getEvaluatedExpression(MediatorProperty.java:138)
at
org.apache.synapse.mediators.builtin.LogMediator.setCustomProperties(LogMediator.java:223)
at
org.apache.synapse.mediators.builtin.LogMediator.getCustomLogMessage(LogMediator.java:146)
at
org.apache.synapse.mediators.builtin.LogMediator.getLogMessage(LogMediator.java:132)
at
org.apache.synapse.mediators.builtin.LogMediator.mediate(LogMediator.java:101)
at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:54)
at
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at
org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:210)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at
org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:398)
at
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:145)
at
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

*4. Error in using insert-before() function*


According to https://docs.marklogic.com/fn:insert-before if the function
written as
fn:insert-before('a', 0, 'x'), then it gives the below error when invoking
the service

If the position casts to xs:integer as fn:insert-before('a', xs:integer(0),
'x') and invoke the service then the result only has 'x' but the expected
result should be 'x,a'


[2016-08-02 14:39:23,625] ERROR - SynapseXPath Evaluation of the XPath
expression fn:insert-before('a', 1, 'x') resulted in an error
; Line#: 1; Column#: -1
net.sf.saxon.trans.XPathException: Required item type of second argument of
fn:insert-before() is xs:integer; supplied value has item type xs:decimal
        at
net.sf.saxon.expr.parser.TypeChecker.staticTypeCheck(TypeChecker.java:404)
        at
net.sf.saxon.functions.SystemFunction.checkArgument(SystemFunction.java:117)
        at
net.sf.saxon.functions.SystemFunction.checkArguments(SystemFunction.java:100)
        at net.sf.saxon.expr.FunctionCall.typeCheck(FunctionCall.java:134)
        at
net.sf.saxon.expr.parser.ExpressionVisitor.typeCheck(ExpressionVisitor.java:206)
        at
net.sf.saxon.xpath.XPathEvaluator.createExpressionInternal(XPathEvaluator.java:239)
        at
net.sf.saxon.xpath.XPathEvaluator.compile(XPathEvaluator.java:376)
        at
org.apache.synapse.util.xpath.SynapseXPath.evaluateDOMXPath(SynapseXPath.java:532)
        at
org.apache.synapse.util.xpath.SynapseXPath.stringValueOf(SynapseXPath.java:367)
        at
org.apache.synapse.mediators.MediatorProperty.getEvaluatedExpression(MediatorProperty.java:138)
        at
org.apache.synapse.mediators.builtin.LogMediator.setCustomProperties(LogMediator.java:223)
        at
org.apache.synapse.mediators.builtin.LogMediator.getCustomLogMessage(LogMediator.java:146)
        at
org.apache.synapse.mediators.builtin.LogMediator.getLogMessage(LogMediator.java:132)
        at
org.apache.synapse.mediators.builtin.LogMediator.mediate(LogMediator.java:101)
        at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
        at
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:54)
        at
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
        at
org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:210)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at
org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:398)
        at
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:145)
        at
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)



*5. nilled() function always gives the result as false*

ref: http://www.xqueryfunctions.com/xq/fn_nilled.html

payload:

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<child>12</child> <child xsi:nil="true"></child> <child></child> <child/>
<child xsi:nil="false"></child> </root>

function: fn:nilled(//child[1])

For all child elements it gives false ( even for the elements which has
xsi:nil)


*6. root() function does not give the root element*

ref:http://www.xqueryfunctions.com/xq/fn_root.html

payload:

<a>
  <x>123</x>
</a>

function: fn:root(//x)

result : 123

expected result :
<a>
  <x>123</x>
</a>


*7. Using the function static-base-uri()*

ref: http://www.xqueryfunctions.com/xq/fn_static-base-uri.html

Can someone please mention how to define the function and the usage?



*8. Using the function unordered()*

ref: https://docs.marklogic.com/fn.unordered

payload :

<a>
  <x>1</x>
 <x>2</x>
 <x>3</x>
</a>

function: fn:unordered(//x)

result : 1

Can someone please explain the usage of this function? it seems the
expected result should be a sequence of items




-more information on the testing results can be found at [4]

-Further, when going through the functions at [1] it seems below functions
are only supported for XSLT ( I guess we don't need to support those
functions when considering the XPath 2.0 functions, please correct me if
I'm wrong)

ref: https://docs.marklogic.com/fn

functions:

   - current
   - current-group
   - current-grouping-key
   - document
   - element-available
   - function-available
   - generate-id(http://www.xsltfunctions.com/xsl/fn_generate-id.html)
   - regex-group
   - system-property
   - type-available
   - unparsed-entity-public-id
   - unparsed-entity-uri
   - unparsed-text
   - unparsed-text-available


- XPath 3.0 functions listed at [1]

acos ,analyze-string,asin,atan,ata2,available-environment-variables,cos,
element-with-id,environment-variable,exp,exp10,filter,fold-left,fold-right,
format-integer,function-arity,function-lookup,function-name,has-children,
head,innermost,log,log10,map,map-pairs,outermost,parse-json,parse-xml ,path,
pi,pow,round,serialize,serialize-json,sin,sqrt,tail,tan,unparsed-text-lines,
uri-collection



[1] http://www.saxonica.com/html/documentation9.4/functions/
[2] http://www.xqueryfunctions.com/
[3] https://docs.marklogic.com/js/fn
[4]
https://docs.google.com/a/wso2.com/spreadsheets/d/1LLVSTAGrqpouQIkt1p3dRx5_wqjuUa58QnKd7gbgQTU/edit?usp=sharing

Thanks,
Sohani

Sohani Weerasinghe
Senior Software Engineer
WSO2, Inc: http://wso2.com

Mobile  : +94 716439774
Blog     :http://christinetechtips.blogspot.com/
Twitter  : https://twitter.com/sohanichristine

On Mon, Aug 1, 2016 at 4:28 PM, Sohani Weerasinghe <soh...@wso2.com> wrote:

> According to [1] if I test the distinct-values function,it behaves as
> explained below:
>
>
> 1. If I use a rest mock service to get the response and then get the
> distinct values :
>
> Rest mock service response:
>
> <catalog xml:base="http://example.org/ACC/";> <product dept="WMN"> 
> *<number>557</number>
> <number>44</number>*
> *<number>44</number>* </product> </catalog>
>
> Rest API:
>
> <api xmlns="http://ws.apache.org/ns/synapse"; name="sample123"
> context="/test123"> <resource methods="POST GET"> <inSequence> <send>
> <endpoint> <address uri="http://localhost:8080/getResult"/> </endpoint>
> </send> </inSequence> <outSequence> <log level="custom"> <property
> xmlns:fn="http://www.w3.org/2005/xpath-functions"; xmlns:ns="
> http://org.apache.synapse/xsd"; xmlns:base="http://test"; name="testValue"
> *expression="fn:**distinct-values**(//product/*)"/*>
> </log> </outSequence> </resource> </api>
>
>
> Then expected result is : *557, 44*
>
> But I am getting only *557*
>
> Am I missing something here?
>
> 2. If I directly use this function as below
>
> <proxy xmlns="http://ws.apache.org/ns/synapse";
>        name="testProxy"
>        transports="http https"
>        startOnLoad="true">
>    <description/>
>    <target>
>       <inSequence>
>          <log level="custom">
>             <property xmlns:fn="http://www.w3.org/2005/xpath-functions";
>                       xmlns:xs="http://www.w3.org/2001/XMLSchema";
>                       xmlns:ns="http://org.apache.synapse/xsd";
>                       name="testValue"
>                       expression="*fn:**distinct-values**(('a', 'b',
> 'a'))*"/>
>          </log>
>       </inSequence>
>       <outSequence/>
>    </target>
> </proxy>
>
> Then I'm getting the exception "invalid XPapth expression" in saving the
> proxy
>
> But according to [1] it seems both ways are correct
>
>
> [1] http://www.xqueryfunctions.com/xq/fn_distinct-values.html
>
> Thanks,
> Sohani
>
> Sohani Weerasinghe
> Senior Software Engineer
> WSO2, Inc: http://wso2.com
>
> Mobile  : +94 716439774
> Blog     :http://christinetechtips.blogspot.com/
> Twitter  : https://twitter.com/sohanichristine
>
> On Mon, Aug 1, 2016 at 3:54 PM, Sohani Weerasinghe <soh...@wso2.com>
> wrote:
>
>>
>>
>>
>> Sohani Weerasinghe
>> Senior Software Engineer
>> WSO2, Inc: http://wso2.com
>>
>> Mobile  : +94 716439774
>> Blog     :http://christinetechtips.blogspot.com/
>> Twitter  : https://twitter.com/sohanichristine
>>
>> On Mon, Aug 1, 2016 at 1:28 PM, Sohani Weerasinghe <soh...@wso2.com>
>> wrote:
>>
>>> Hi All,
>>>
>>> It seems, the " Invalid XPapth expression" comes when we use two
>>> brackets in the function as below
>>>
>>
>>
>> While I was testing further I found that below function works perfectly
>> even it has two brackets, so that means the syntax of the above mentioned
>> functions are correct.
>>
>> So, are these functions not supported in ESB? Appreciate your input on
>> this
>>
>> fn:dateTime(xs:date('2006-08-15'), xs:time('12:30:45-05:00'))
>>
>>
>>> fn:codepoints-to-string(*(*2309, 2358, 2378, 2325*)*)
>>> fn:string-join(('a', 'c'), 'bbb')
>>>
>>>
>>>
>>>
>>>
>>>
>>> Sohani Weerasinghe
>>> Senior Software Engineer
>>> WSO2, Inc: http://wso2.com
>>>
>>> Mobile  : +94 716439774
>>> Blog     :http://christinetechtips.blogspot.com/
>>> Twitter  : https://twitter.com/sohanichristine
>>>
>>> On Mon, Aug 1, 2016 at 12:06 PM, Sohani Weerasinghe <soh...@wso2.com>
>>> wrote:
>>>
>>>> Hi All,
>>>>
>>>> I am validating the Xpath 2.0 functions support in ESB ( please refer
>>>> [1]) and I am using below configuration in defining 'avg' function
>>>> (Referred [2]), but it seems I am using the wrong syntax.
>>>>
>>>>   <property xmlns:fn="http://www.w3.org/2005/xpath-functions";
>>>>                       xmlns:test="http://test";
>>>>                       xmlns:ns="http://org.apache.synapse/xsd";
>>>>                       name="testValue"
>>>>                     *  expression="fn:avg((3,4,5))"/>*
>>>>
>>>> Can someone please point the correct syntax?
>>>>
>>>> Since avg function requires a single parameter, is there a way to
>>>> define the integer values externally ( may be using a property mediator )
>>>> and use it inside the function ?
>>>>
>>>> If this syntax is correct, is this function not supported in ESB?
>>>>
>>>> Really appreciate your input on this
>>>>
>>>> FYI: When saving the proxy, I'm getting below exception:
>>>>
>>>> [2016-08-01 11:41:11,718] ERROR - ProxyServiceAdmin Unable to save
>>>> changes made for the proxy service : testProxy. Restored the existing
>>>> proxy... :: Invalid XPapth expression : fn:avg((3,4,5))
>>>> org.apache.synapse.SynapseException: Invalid XPapth expression :
>>>> fn:avg((3,4,5))
>>>> at
>>>> org.apache.synapse.config.xml.MediatorPropertyFactory.getMediatorProperties(MediatorPropertyFactory.java:106)
>>>> at
>>>> org.apache.synapse.config.xml.LogMediatorFactory.createSpecificMediator(LogMediatorFactory.java:111)
>>>> .......
>>>>
>>>>
>>>>
>>>> [1] Xpath 2.0.0 functions supported by ESB
>>>> [2] https://www.w3.org/TR/xpath-functions/#func-avg
>>>> Sohani Weerasinghe
>>>> Senior Software Engineer
>>>> WSO2, Inc: http://wso2.com
>>>>
>>>> Mobile  : +94 716439774
>>>> Blog     :http://christinetechtips.blogspot.com/
>>>> Twitter  : https://twitter.com/sohanichristine
>>>>
>>>
>>>
>>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to