XSD datatype
xs:base64Binary and xs:hexBinary
The two ways to carry bytes in XML. base64Binary tolerates whitespace; hexBinary does not.
xs:base64Binary holds standard Base64, and whitespace within it is ignored — which is what makes it usable for the long values that get wrapped across lines. xs:hexBinary holds an even number of hex digits and allows no whitespace at all.
hexBinary is about twice the size on the wire for the same payload, so base64Binary is the usual choice for anything large.
- Lexical space
- Base64 characters with optional whitespace, or an even count of hex digits.
- Derives from
- Primitive type
- Category
- Other types
- Facets
- length, minLength, maxLength, pattern, enumeration, whiteSpace
What validates
Every literal below is put through the schema validator on each test run, against the schema at the foot of this page.
SGVsbG8=SGVs bG8=(the empty string)
What does not
SGVsbG8Base64 must be correctly padded to a multiple of four.
Hello!'!' is not a Base64 character.
0F1E2DValid xs:hexBinary, but not valid Base64 — the two are not interchangeable.
The schema used
This is the exact schema the literals above are validated against. Paste it into the validator with one of them to see the result yourself.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="v" type="xs:base64Binary"/>
</xs:schema>Related
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.