问题描述
我需要从某些XML元素中解码Base64字符串. type="xs:base64binary"
定义的元素和type="xs:string"
定义的元素之间有什么区别吗?一些XSD开发人员拒绝将编码的字符串标记为base64binary.如果没有区别,type="xs:base64binary"
的用途是什么?
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 type="xs:string"
? Some XSD developers refuse to mark encoded strings as a base64binary. If there is no difference, what is the use of type="xs:base64binary"
?
推荐答案
如果我理解规范正确,但在语义上有所不同.
If I understand the specs correctly, there is a semantic difference.
base64Binary
元素包含已编码为base64的任意二进制数据,这使得它基本上是一个字符串(或至少与字符串兼容).
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.
您可以使用base64Binary
表示解码后的数据不适合人类消费,因为string
是可读/可打印的.
You can use base64Binary
to indicate that the decoded data is not suitable for human consumption, where as string
is readable/printable.
这篇关于XML模式. Base64binary类型vs字符串类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!