本文介绍了XML 架构.Base64binary 类型 vs String 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一些 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 String 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 22:51