XML Schema. Base64binary type vs String type
There definitely is a difference between base64Binary
and string
in XSD:
- base64Binary represents binary data encoded in Base64. Its value space is the set of fixed length binary octets. Itslexical space is limited to
a-z
,A-Z
,0-9
,+
,/
,=
, pluswhitespace. - string represents character data. Its value space is the set of finite-length sequences of characters. Its lexicalspace is unconstrained beyond having to consist of XMLcharacters.
If I understand the specs correctly, there is a semantic difference.
A base64Binary
element contains arbitrary, binary data that has been encoded as base64, which makes it basically a string (or at least string-compatible).
On the other hand, strings contain printable characters, which (usually) make up words and sentences (natural language). They cannot contain arbitrary (binary) data, because certain characters aren't allowed.
You can use base64Binary
to indicate that the decoded data is not suitable for human consumption, where as string
is readable/printable.