∟"base64Binary" Datatype Values and Representations
This section describes the built-in primitive datatype, 'base64Binary' that represents binary data represented in Base64 encoding. Whitespaces are allowed and removed.
"base64Binary" is a built-in datatype that represents binary data encoded with Base64 algorithm
with these rules:
The value space of "base64Binary" is any binary data.
The lexical space of "base64Binary" is Base64 encoding output strings.
Whitespaces allowed and removed.
To verify these rules, I wrote this simple XSD document that uses "base64Binary" datatype to declare XML elements:
Here is a sample XML document that can be used to test these declarations:
<?xml version="1.1"?>
<!-- base64Binary_datatype_test.xml
- Copyright (c) 2013, HerongYang.com, All Rights Reserved.
-->
<Base64Binary_Datatype_Test>
<!-- 4 valid "Base64Binary" elements -->
<Base64Binary> QQ== </Base64Binary>
<Base64Binary> aGVyb25neWFuZy5jb20= </Base64Binary>
<Base64Binary> a G V y b 2 5neWFuZy5jb20= </Base64Binary>
<Base64Binary> 1234 </Base64Binary>
<!-- 4 invalid "Base64Binary" elements -->
<Base64Binary> 123 </Base64Binary>
<Base64Binary> herongyang.com== </Base64Binary>
<Base64Binary> QQ==QQ== </Base64Binary>
<Base64Binary> Q=== </Base64Binary>
</Base64Binary_Datatype_Test>
When validating this XML document with my XsdSchemaValidator.java program presented earlier in the book,
I get 4 groups of errors for 4 invalid XML elements:
c:\Progra~1\Java\jdk1.7.0_07\bin\java XsdSchemaValidator
base64Binary_datatype_test.xsd base64Binary_datatype_test.xml
Error:
Line number: 14
Column number: 42
Message: cvc-datatype-valid.1.2.1: ' 123 ' is not a valid
value for 'base64Binary'. (must be multiples of 4 characters)
Error:
Line number: 14
Column number: 42
Message: cvc-type.3.1.3: The value ' 123 ' of element
'Base64Binary' is not valid.
Error:
Line number: 15
Column number: 55
Message: cvc-datatype-valid.1.2.1: ' herongyang.com== ' is not
a valid value for 'base64Binary'. ("." not allowed)
Error:
Line number: 15
Column number: 55
Message: cvc-type.3.1.3: The value ' herongyang.com== ' of
element 'Base64Binary' is not valid.
Error:
Line number: 16
Column number: 47
Message: cvc-datatype-valid.1.2.1: ' QQ==QQ== ' is not a valid
value for 'base64Binary'. ("=" only allowed at the end)
Error:
Line number: 16
Column number: 47
Message: cvc-type.3.1.3: The value ' QQ==QQ== ' of element
'Base64Binary' is not valid.
Error:
Line number: 17
Column number: 43
Message: cvc-datatype-valid.1.2.1: ' Q=== ' is not a valid
value for 'base64Binary'. (maximum 2 "=" at the end)
Error:
Line number: 17
Column number: 43
Message: cvc-type.3.1.3: The value ' Q=== ' of element
'Base64Binary' is not valid.
Failed with errors: 8