The saxon:hexBinary serialization method
Requires Saxon-PE
An additional serialization method saxon:hexBinary
is available. This is intended to be useful when
creating binary output files, for example images. All serialization properties other than method
are
ignored.
As with the text
output method, all nodes in the result tree other than text nodes are ignored. Each text node
must hold a string that is in the lexical space of the xs:hexBinary
data type. The sequence of octets
corresponding to this base64 value is written to the binary output file.
When invoking this method via an API, use the property value "{http://saxon.sf.net/}hexBinary".
When using this serialization method, the omit-xml-declaration
parameter is automatically
set to "yes".
The image here displays as a small red dot. Note that whitespace cannot appear in the middle of an xs:hexBinary
value,
but the string can be split into multiple text nodes so long as each contains an even number of characters.
It is of course possible to construct the hexBinary value programmatically. The extension function saxon:octets-to-hexBinary may be useful to achieve this.
When writing output that is not entirely binary, but contains mixed binary and text, it may be more convenient to use the text output method with the saxon:recognize-binary serialization property.
See also the saxon:base64Binary serialization method.