xml - "Too many items" with XPath eq operator for assertion -


i having problem when validating following xml file against xml schema. error "too many items expected '1', '3' supplied. in assert want express following: whenever oid value equals boid value a_membership_degree should greater or equal b_membership_degree

sample xml

<document xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="gen.xsd"> <a oid="aa" a_membership_degree="0.7" d_membership_degree="0.5"  >   <a1>x1</a1>   <a2>d1</a2>  </a>   <b boid="aa" b_membership_degree="0.2">   <b1>g1</b1>   <b2>f1</b2>  </b>   <c  coid="aa" c_membership_degree="0.3" >   <c1>g2</c1>   <c2>f2</c2>  </c> <a oid="aaa" a_membership_degree="0.8" d_membership_degree="0.5"  >   <a1>x2</a1>   <a2>d2</a2>  </a>   <b boid="aaa" b_membership_degree="0.5"  >   <b1>g3</b1>   <b2>f3</b2>  </b>  <c  coid="aaa" c_membership_degree="0.4" >   <c1>g4</c1>   <c2>f4</c2>  </c>  <a oid="hhh" a_membership_degree="0.8" d_membership_degree="0.5"  >   <a1>x11</a1>   <a2>d11</a2>  </a>  </document> 

current schema

<xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"             xmlns:vc="http://www.w3.org/2007/xmlschema-versioning"             elementformdefault="qualified"             attributeformdefault="unqualified"             vc:minversion="1.1">   <xs:element name="document">     <xs:complextype>       <xs:sequence maxoccurs="unbounded">         <xs:element ref="a" minoccurs="0" maxoccurs="unbounded"/>         <xs:element ref="b" minoccurs="0" maxoccurs="unbounded"/>         <xs:element ref="c" minoccurs="0" maxoccurs="unbounded"/>       </xs:sequence>       <xs:assert          test="if(.//@oid eq  .//@boid)                ./a/@a_membership_degree                      ge ./b/@b_membership_degree else false()"/>     </xs:complextype>     <xs:key name="akey">       <xs:selector xpath="a"/>       <xs:field xpath="@oid"/>     </xs:key>     <xs:keyref name="akeyref" refer="akey">       <xs:selector xpath="./b"/>       <xs:field xpath="@boid"/>     </xs:keyref>     <xs:keyref name="akeyref1" refer="akey">       <xs:selector xpath="./c"/>       <xs:field xpath="@coid"/>     </xs:keyref>   </xs:element>   <xs:element name="a" type="atype"/>   <xs:complextype name="atype">     <xs:sequence minoccurs="0" maxoccurs="unbounded">       <xs:element name="a1" type="xs:string" minoccurs="1" maxoccurs="1"/>       <xs:element name="a2" type="xs:string" minoccurs="1" maxoccurs="1"/>     </xs:sequence>     <xs:attribute name="oid" type="xs:string" use="required"/>     <xs:attribute name="a_membership_degree" type="fuzzyvalue" use="optional"/>     <xs:attribute name="d_membership_degree" type="fuzzyvalue" use="optional"/>   </xs:complextype>   <xs:element name="b" type="btype"/>   <xs:complextype name="btype">     <xs:sequence>       <xs:element name="b1" type="xs:string" minoccurs="1" maxoccurs="1"/>       <xs:element name="b2" type="xs:string" minoccurs="1" maxoccurs="1"/>     </xs:sequence>     <xs:attribute name="boid" type="xs:string" use="required"/>     <xs:attribute name="b_membership_degree" type="fuzzyvalue" use="optional"/>   </xs:complextype>   <xs:element name="c" type="ctype"/>   <xs:complextype name="ctype">     <xs:sequence>       <xs:element name="c1" type="xs:string" minoccurs="1" maxoccurs="1"/>       <xs:element name="c2" type="xs:string" minoccurs="1" maxoccurs="1"/>     </xs:sequence>     <xs:attribute name="coid" type="xs:string" use="required"/>     <xs:attribute name="c_membership_degree" type="fuzzyvalue" use="required"/>   </xs:complextype>   <xs:simpletype name="fuzzyvalue">     <xs:restriction base="xs:decimal">       <xs:mininclusive value="0"/>       <xs:maxinclusive value="1"/>     </xs:restriction>   </xs:simpletype> </xs:schema> 

the reason specific error eq , ge operators expect arguments single values, you're providing them set of several nodes. instead of simple if need explicit quantified expression this

every $a in a, $b in b[@boid eq $a/@oid] satisfies     $a/@a_membership_degree ge $b/@b_membership_degree 

the pair of in clauses generates list of pairs of 1 , 1 b matching ids, , satisfies clause checks membership degree condition each pair.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -