[
https://issues.apache.org/jira/browse/XERCESJ-1608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13595473#comment-13595473
]
Mukul Gandhi commented on XERCESJ-1608:
---------------------------------------
committed a fix for this issue (jira revision 1453664).
I think, correct way to write such an assertion would be,
<assert test="xsd:dayTimeDuration('PT24H') = sum(tst:d)"/> (this was
not working earlier, which has now been committed)
Following are other workable variants,
<assert test="xsd:dayTimeDuration('PT24H') = sum(for $d in element(tst:d)
return xsd:dayTimeDuration(string($d)))"/>
<assert test="xsd:dayTimeDuration('PT24H') = sum(for $d in element(tst:d)
return $d)"/>
I feel, the assertion <assert test="xsd:dayTimeDuration('PT24H') = sum(for $d
in element(tst:d) return xsd:dayTimeDuration($d))"/>
cannot work as per the XPath 2.0 spec, since xsd:dayTimeDuration($d) is wrong
(a constructor function here cannot accept an element node, but only an atomic
value). Therefore, this fix was not attempted.
> Error when validating sum duration
> ----------------------------------
>
> Key: XERCESJ-1608
> URL: https://issues.apache.org/jira/browse/XERCESJ-1608
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Affects Versions: 2.11.0
> Reporter: Jorge L. Williams
>
> Tried the following in latest XSD 1.1 branch:
> Schema:
> <schema
> elementFormDefault="qualified"
> attributeFormDefault="unqualified"
> xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:tst="http://www.rackspace.com/test/duration"
> targetNamespace="http://www.rackspace.com/test/duration">
> <element name="test" type="tst:SumDuration24H"/>
> <complexType name="SumDuration24H">
> <sequence>
> <element name="d" type="xsd:dayTimeDuration"
> maxOccurs="unbounded"/>
> </sequence>
> <assert test="xsd:dayTimeDuration('PT24H') = sum(for $d in
> element(tst:d) return xsd:dayTimeDuration($d))"/>
> </complexType>
> </schema>
> good.xml
> <test xmlns="http://www.rackspace.com/test/duration">
> <d>PT22H</d>
> <d>PT1H</d>
> <d>PT1H</d>
> </test>
> bad.xml
> <test xmlns="http://www.rackspace.com/test/duration">
> <d>PT24H</d>
> <d>PT1H</d>
> <d>PT1H</d>
> </test>
> I expect good.xml to validate correctly and bad.xml to fail validation.
> However, both of these fail validation with the message:
> cvc-assertion: Assertion evaluation ('xsd:dayTimeDuration('PT24H') = sum(for
> $d in element(tst:d) return xsd:dayTimeDuration($d))') for element 'test' on
> schema type 'SumDuration24H' did not succeed.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]