Hi Yitzhak, Thanks for the test case. I did run your test cases. The reason why the following, <xs:assert test="if (abs(price - 10) le subsequence((0.05, 100.00, 0.05, 0.05, 0.05, 0.05, 0.05), index-of(('BO','CO','GT','HN','PY','SV','TZ'), country), 1)) then true() else false()"> <xs:annotation> <xs:documentation>Rule #2</xs:documentation> <xs:documentation>string from country element value, fails</xs:documentation> </xs:annotation> </xs:assert>
gives an error, is because in the implementation of fn:index-of function in Xerces's XPath 2.0 processor, the 2nd argument is not atomized internally. I would say, that the mentioned atomization would be good to have, to be consistent with implementations of various other XPath 2.0 functions in Xerces's XPath 2.0 processor. But I won't call the failure of one of your test cases as mentioned in this thread, a bug in our XSD 1.1 processor, since I can't find anywhere in XPath 2.0 and XPath 2.0 F&O specs that the missing atomization (in the fn:index-of function) is mandatory. As a workaround, I'd suggest that, following XPath expression index-of(('BO','CO','GT','HN','PY','SV','TZ'), country) should be written as, index-of(('BO','CO','GT','HN','PY','SV','TZ'), string(country)) [this would also make your XSD 1.1 document portable] I prefer, string(country) over xs:string(country). As an additional note, I admit we're not in the position as of now, to fix any further bugs in Xerces's XPath 2.0 processor, since none of our team members has commit rights on the Eclipse WTP Source Editing project ( https://www.eclipse.org/webtools/sse/); earlier we used to have commit rights on the WTP Source Editing project; this project is the owner of our XPath 2.0 processor. You might like to request the WTP project to fix the issue which you've discovered. Their mailing list is wtp-...@eclipse.org. If the WTP Project fixes this issue on their source repos (the branch R3_2_maintenance on their XPath 2.0 repos), we can then build new XPath 2.0 jar from their new source code and provide to our users. On Fri, Jul 6, 2018 at 2:08 AM, Yitzhak Khabinsky < yitzhak.khabin...@millicom.com> wrote: > Hi Mukul, > > > > Here is a small XML/XSD test case. > > You can find it in the attachment. > > > > I created 3 rules, all around how the *country* element passed as a > parameter: > > 1. string literal, passed > 2. *country element string value, fails* > 3. country element value cast as string, passed > > > > Just the Rule #2 emits the error, though the schema knows that the > *country* element has a string data type and it fails for no obvious > reason. > > > > [Error] test1.xml:5:8: cvc-assertion: Assertion evaluation ('if (abs(price > - 10) le subsequence((0.05, 100.00, 0.05, 0.05, 0.05, 0.05, 0.05), > index-of(('BO','CO','GT','HN','PY','SV','TZ'), country), 1)) then true() > else false()') for element 'root' on schema type '#AnonType_root' did not > succeed. XPTY0004 - Value does not match a required type. > > > > So it looks like that the problem is not related to the suggested reasons: > > - The fn:abs(..) return type is numeric? > - and fn:subsequence(..) return type is item()* > - subsequence is returning a sequence of cardinality/size greater than > one > > > > <?xml version="1.0" encoding="UTF-8"?> > <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="test Test1.xsd" xmlns="test"> > <country>CO</country> > <price>25.1234</price> > </root> > > > > <?xml version="1.0"?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault= > "qualified" targetNamespace="test" xpathDefaultNamespace="## > targetNamespace" xmlns="test"> > <xs:element name="root"> > <xs:complexType> > <xs:sequence> > <xs:element ref="country"/> > <xs:element ref="price"/> > </xs:sequence> > > <xs:assert test="if (abs(price - 10) le subsequence((0.05, > 100.00, 0.05, 0.05, 0.05, 0.05, 0.05), > index-of(('BO','CO','GT','HN','PY','SV','TZ'), > 'CO'), 1)) then true() else false()"> > <xs:annotation> > <xs:documentation>Rule #1</xs:documentation> > <xs:documentation>string literal, passed< > /xs:documentation> > </xs:annotation> > </xs:assert> > <xs:assert test="if (abs(price - 10) le subsequence((0.05, > 100.00, 0.05, 0.05, 0.05, 0.05, 0.05), > index-of(('BO','CO','GT','HN','PY','SV','TZ'), > country), 1)) then true() else false()"> > <xs:annotation> > <xs:documentation>Rule #2</xs:documentation> > <xs:documentation>string from country element value, > fails</xs:documentation> > </xs:annotation> > </xs:assert> > <xs:assert test="if (abs(price - 10) le subsequence((0.05, > 100.00, 0.05, 0.05, 0.05, 0.05, 0.05), > index-of(('BO','CO','GT','HN','PY','SV','TZ'), > xs:string(country)), 1)) then true() else false()"> > <xs:annotation> > <xs:documentation>Rule #3</xs:documentation> > <xs:documentation>cast as string from country element > value, passed</xs:documentation> > </xs:annotation> > </xs:assert> > </xs:complexType> > </xs:element> > > <xs:element name="country" type="xs:string"/> > <xs:element name="price" type="xs:decimal"/> > </xs:schema> > -- Regards, Mukul Gandhi