XML Schema. Base64binary type vs String Type

I need to decode a Base64 string from some XML element. Is there a difference between an element defined by type="xs:base64binary" and an element defined by type="xs:string" ? Some XSD developers refuse to mark encoded strings as base64binary. If it type="xs:base64binary" no difference, what is the use of type="xs:base64binary" ?

+6
source share
2 answers

If I understand the specifications correctly, there is a semantic difference.

Element

A base64Binary contains arbitrary binary data that has been encoded as base64, which makes it basically a string (or at least compatible with a string).

On the other hand, strings contain printed characters that (as a rule) comprise words and sentences (natural language). They cannot contain arbitrary (binary) data, because some characters are not allowed.

You can use base64Binary to indicate that the decoded data is not suitable for human consumption, where string is read / printed.

+8
source

In XSD, there is a definite difference between base64Binary and string :

  • base64Binary represents binary data encoded in Base64. Its value space is a set of binary octets of fixed length. this lexical space is limited to az , az , 0-9 , + , / , = , plus whitespace .
  • string represents character data. Its value space is a set of sequences of finite length of characters. Its lexical space is unlimited, except that it consists of XML characters .
+14
source

All Articles