XML Schema. Base64binary type vs String type

后端 未结 2 2019
半阙折子戏
半阙折子戏 2020-12-09 16:35

I need to decode a Base64 string from some XML element. Is there any difference between an element defined by type=\"xs:base64binary\" and an element defined by

相关标签:
2条回答
  • 2020-12-09 17:12

    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.

    0 讨论(0)
  • 2020-12-09 17:27

    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. Its lexical space is limited to a-z, A-Z, 0-9, +, /, =, plus whitespace.
    • string represents character data. Its value space is the set of finite-length sequences of characters. Its lexical space is unconstrained beyond having to consist of XML characters.
    0 讨论(0)
提交回复
热议问题