saxon:hexBinary serialization method
The serialization method saxon:hexBinary
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
hexBinary 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
.
In the following example, the image 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 EXPath binary library is however geared towards creating base64Binary values, so that will usually be a better option.
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 parameter.
See also the saxon:base64Binary serialization method.