xs:base64Binary

The primitive type xs:base64Binary represents binary data in base-64 encoding. The following rules apply to xs:base64Binary values:

  • The following characters are allowed: the letters A through Z (uppercase and lowercase), digits 0 through 9, the plus sign (+), the slash (/), the equals sign (=), and XML whitespace characters.

  • XML whitespace characters can appear anywhere in the value.

  • The number of nonwhitespace characters must be divisible by four.

  • Equals signs, which are used as padding, can only appear at the end of the value, and there can be zero, one, or two of them. If there are two equals signs, they must be preceded by one of the following characters: A, Q, g, w. If there is only one equals sign, it must be preceded by one of the following characters: A, E, I, M, Q, U, Y, c, g, k, o, s, w, 0, 4, 8.

Values of type xs:base64Binary can be cast to and from xs:hexBinary, xs:string, and xs:untypedAtomic. When cast to xs:string, an xs:base64Binary value is converted to its canonical representation, which contains no whitespace characters except for a line feed (#xA) character inserted after every 76 characters and at the end.

Note that these rules for acceptable base-64 values are rather strict, and processors are expected to enforce the rules strictly. This differs from practice elsewhere, and some software may generate "base 64" that doesn't meet these rules.

Table B-2 lists some values of the xs:base64Binary type. For more information on base-64 encoding, see RFC ...

Get XQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.