error parsing dynamic link query using Microsoft Json Rules engine - dynamic-linq

Using Microsoft Json Rules engine.
The following rule expressions parse without an issue:
"Names[0].PersonName.FirstName=="Paul""
Names.Any()
but 3. throws the following parse exception
"Names.Any(n=>n.PersonName.FirstName=="Paul")"
Exception while parsing expression Names.Any( n => n.PersonName.FirstName=="Paul") - Unable to cast object of type 'System.Linq.Expressions.InstanceMethodCallExpression1' to type 'System.Linq.Expressions.ParameterExpression'.
Dr. Google is not very helpful on this one.
Any feedback, directions, pointers etc. greatly appreciated.
I was expecting the expression to parse and when evaluated return, true, given 1. above is true.

Dynamic Linq using a operator called "it" to refer to the current instance.a
Changing the expression to the following:
"Names.Any(it.PersonName.FirstName=="Paul")" solved the problem for me.

Related

string-join() function throws invalid expression

XPathError
message: "Invalid expression.
(string-join(/form/Data/MProcess/Process/Id/string(), ','))
I thought the problem was Process Id was not returning string so I tried string() and text() but they did not work. I can't find the solution.
Here is an example process id: aee865d1-7253-489c-8d53-2a0d580639d0
string-join() is an XPath 2.0 function, and many early XPath processors were never upgraded to 2.0. Check what XPath processor you are using and what language level it supports, and upgrade if you can.

OData : Operands of logical operator 'AND' are not valid

I am trying to call an OData report with the following URL :
https://myXXXXX.sapbydesign.com/sap/byd/odata/crm_customerinvoicing_analytics.svc/RPCRMCIVIB_Q0001QueryResults?&$filter=PARA_CAL_DAY%20gt%20datetime%272017-01-01T00:00:00.000%27%20and%20PARA_CAL_DAY%20lt%20datetime%272017-01-02T00:00:00.000%27&$skip=0
As you can see I am trying to use the and operator inside a filter property but I received the error in the title of this post.
I tried :
$filter=(MyFilter1) and (MyFilter2)
$filter=(MyFilter1 and MyFilter2)
$filter=(MyFilter1 AND MyFilter2)
But I still have an error. Any ideas ?
Just in case someone stumbles upon this thread first, this is error occurs when the same field is used to filter the dataset twice (greater than+less than, greater than+less than or equal to, etc)
SAP issue report

SoapUI XPath assertion - wildcard string with Excel dataSource

I want to use an assertion "expected result" that uses both some form of "contains" function or wildcard AND gets the text to test against from an Excel dataSource. The SoapUI 'contains' function has no way to use a dataSource that I've found, and I cannot figure out how to use an XPath function like contains with a dataSource. Can someone please explain how that works?
--
I've been asked for more detail.
In SoapUI, if I add an assertion and choose the request/response as the source, I then have a choice of assertions. One of them is "XPath Match". I can use that to designate a specific field in the response, in this case, which value I want to test.
Having chosen the "XPath expression" in the top half of the "XPath Match Configuration", I can then choose my Excel dataSource as the content for the lower half "Expected Result". I have used this to test an error code against an error code from the Excel spreadsheet.
What I don't know how to do is determine, in this assertion, that the error message returned contains the value in Excel. I figure something special goes into "Expected Result" in the "XPath Match Configuration" box, but I don't know what.
The Expected Result of the XPath assertion is only a "dumb" string. The best that you can do in this field is property expansion ... which does not help your cause.
Instead you will need to use the top portion, where you can enter XPath Expression, that provides the logic you are looking for. Your XPath expression will need to look something like:
contains(//*:some/*:node, '${data_source#property}')
and your Expected Value will be simply:
true
Convenient reference, in case you need it.

Xpath Expression evaluation on attributes with any namespace prefix

Could you please help me on this xpath expression evaluation
I am working on fetching the proxy references. In the xml file the references will get stored as:
One way of XML file will have the reference as below:
con1:service ref="MyProject/ProxyServices/service1"
xsi:type="con2:PipelineRef" xmlns:ref="http://www.bea.com/wli/sb/reference"/
here in the xml file the name spaces are:
xmlns:con1="http://www.bea.com/wli/sb/stages/config"
xmlns:con2="http://www.bea.com/wli/sb/pipeline/config"
Another way of XML will have the reference as below.
con1:service ref="MyProject/ProxyServices/service2"
xsi:type="ref:ProxyRef" xmlns:ref="http://www.bea.com/wli/sb/reference"/
here in the xml file the name spaces are:
xmlns:con1="http://www.bea.com/wli/sb/stages/config"
xmlns:ref="http://www.bea.com/wli/sb/reference"
I have used this xpath expression, this is not fetching the reference service values, could you please help what is wrong in it.
"//service[#type= #*[local-name() ='ProxyRef' or #type=#*[local-name() ='PipelineRef']]/#ref"
when I used like this it is working but, name space prefix is keep on changes when there are multiple references in the xml file.
"//service[#type='ref:ProxyRef'or #type='con:PipelineRef' or #type='con1:PipelineRef' or #type='con2:PipelineRef' or #type='con3:PipelineRef' ...#type='con20:PipelineRef' ]/#ref";
Now here basically the type attribute PipelineRef is keep on changing the name space prefix from con to con(n). Now I am looking for something which supports some thing like #type='*:PipelineRef' or #type='con*:PipelineRef' or the best way to fetch the service element reference attribute value.
Thanks in advance.
Try using contains() like so :
//service[contains(#type,':ProxyRef') or contains(#type,':PipelineRef')]
Another alternative would be using ends-with() function which is more precise for this purpose compared to contains() function. However, ends-with() isn't available in xpath 1.0, so there is a chance that you need to implement it yourself (feasible, but the xpath result is less intuitive for me).

Using XPath functions in libxml

I am trying to evaluate certain XPath expressions with libxml 2.8.0 and am getting error messages with functions. It is not clear to me whether libxml implements the whole or a subset of the XPath specification. Is there any resource clearly identifying what is implemented and how to use it?
In my specific case, one expression I am trying to evaluate is:
/TemporalInformation/RecipeInformation[fn:exists(./ActionToActionRelation[fn:contains(./#actionA,'cook') and fn:exists(./IngredientA[fn:contains(./#classes,'onion')])])]
I am using libxml through the XML::LibXML Perl module, but I have also tried my expression with the xpath1.c example tool available from xmlsoft.org, and got the same error messages:
$ ./xpath-tester data/fk.xml "/TemporalInformation/RecipeInformation[fn:exists(.> /ActionToActionRelation[fn:contains(./#actionA,'cook') and fn:exists(./IngredientA[fn:contains(./#classes,'onion')])])]" "fn=http://www.w3.org/2005/xpath-functions"
xmlXPathCompOpEval: function contains not found
XPath error : Unregistered function
xmlXPathCompOpEval: function exists not found
XPath error : Unregistered function
XPath error : Invalid expression
XPath error : Stack usage errror
Error: unable to evaluate xpath expression "/TemporalInformation/RecipeInformation[fn:exists(./ActionToActionRelation[fn:contains(./#actionA,'cook') and fn:exists(./IngredientA[fn:contains(./#classes,'onion')])])]"
Usage: ./xpath-tester <xml-file> <xpath-expr> [<known-ns-list>]
where <known-ns-list> is a list of known namespaces
in "<prefix1>=<href1> <prefix2>=href2> ..." format
I have tried with and without the fn namespace, both with xpath.c and my Perl script, and got the same result.
The libxml XPath implementation is only XPath 1.0, so 2.0-only functions such as exists aren't available. In 1.0 you only have a few core functions - there's starts-with but not ends-with, no regular expression support, no date handling, etc. and there's no strong typing and none of the higher-level constructs like if and for.
So to answer your question, yes, it does support the whole of XPath, but only XPath 1.0.

Resources