Bug #3525
closed
Reflexive extension function returning byte[]
Category:
Saxon extensions
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Description
When a reflexive extension function has a return type of byte[], the values are converted to XPath xs:integer instances in the range 0-255: that is, the bytes are treated as unsigned. This is not the case if the return type is simply byte or Byte. Moreover, the return values are annotated as instances of xs:byte, which is incorrect in the case of values such as 255, because these are outside the range of an xs:byte.
The problem is exposed by the extension functions saxon:hexBinary-to-octets and saxon:base64Binary-to-octets, which are implemented as reflexive extension functions with a declared return type of byte[], yet are documented to return a sequence of integers in the range 0-255. These integers are incorrectly annotated as xs:byte instances; moreover it seems the static type inferencing assumes a static type of xs:byte*.
Note there is a danger that changing the behaviour here could break existing applications.
- Status changed from New to In Progress
I think that in the interests of avoiding disruption to existing applications, we should make the rule that a value of byte[] returned from Java maps to a sequence of xs:unsignedByte in XPath, that is, a sequence of integers in the range 0-255 labelled as instances of xs:unsignedByte. For a return type of byte or Byte we retain the mapping to a singleton (signed) xs:byte.
- Applies to branch 9.8, trunk added
- Fix Committed on Branch 9.8, trunk added
I have fixed JPConverter.FromByteArray() on the 9.8 and trunk branches to annotate the result items as xs:unsignedByte rather than xs:byte.
Changes to the documentation remain to be made.
- Status changed from In Progress to Resolved
I have committed changes to the 9.8 and trunk documentation to describe how results of type byte[] are handled.
I have added test cases for hexBinaryToOctets to the xslt30extra test suite.
Documentation updated online (XML and HTML versions).
- % Done changed from 0 to 100
Bug fix applied in the Saxon 9.8.0.7 maintenance release.
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 9.8.0.7 added
- Related to Bug #3818: Reflexive java functions vs byte arrays added
Please register to edit this issue
Also available in: Atom
PDF