XML technologies / XML Schema / Data type reference / xs:hexBinary

(Excerpt from “XML Schema” by Eric van der Vlist)

Hexadecimal-encoded binary content

Derived from: xs:anySimpleType

Primitive type: xs:hexBinary

Known subtypes: none

Facets: xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Definition

<xs:simpleType name="hexBinary" id="hexBinary">
    <xs:restriction base="xs:anySimpleType">
        <xs:whiteSpace value="collapse" fixed="true"/>
    </xs:restriction>
</xs:simpleType>

Description

The value space of xs:hexBinary consists of all binary content; its lexical space simply encodes each octet as its hexadecimal value.

Restrictions

Do not confuse this data type with BinHex encoding, which W3C XML Schema does not support. W3C XML Schema also does not support other popular binary-to-text encodings such as uuXXcode, Quoted Printable, aencode or base85.

The expansion factor is high because each binary octet becomes two characters, four octets if the document is encoded in UTF-16.

Example

A UTF-8 XML header such as

<?xml version="1.0" encoding="UTF-8"?>

would be encoded as:

3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d22223f3e

   

 

 

 

back to top