xml - How to check out the sum of integers in a <xs:list itemType="xs:integer"/> in XSD 1.1 -
i have couple of attributes defined in way:
<xs:attribute name="actor" type="xs:string" use="required"/> <xs:attribute name="percentage" use="required"> <xs:simpletype> <xs:list itemtype="xs:integer"/> </xs:simpletype> </xs:attribute>
what need creating assertion checks out if sum of integers in list (taking care of blank spaces) equal 100 in case in "actor" attribute there string "me". thought doesn't work:
<xs:assert test="@actor != 'me' or sum (tokenize(normalize-space((@percentage)),'\s')) = '100'"/>
can me finding out problem is? thanks!
according xsd 1.1 specs , xpath 2.0 data model specs:
types derived list or union not atomic.
in case, important thing need know schema validator knows type of percentage
attribute list of ints, derived list (type not string). in case data associated @percentage
(for example) list (30, 30, 40)
, not string "30 30 40"
. means cannot call normalize-space(@percentage)
functions expects string. second error comparing result of sum string "100"
instead of number 100
.
so sum comparaison of assertion should simple this:
sum(data(@percentage)) = 100
edit: added data() expression validates using xerces.
Comments
Post a Comment