• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

Convention for Deserializing Empty Base64Binary encoded elements

Is there a convention for deserializing empty xml elements which are base64Binary encoded?

For example    '<tst:Base64Test  xmlns:tst="Test"></tst:Base64Test>', where Base64Test is defined in the following schema:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
&#9;<xs:element name="Base64Test" type="xs:base64Binary"  />

An empty string is what I am finding in discussions on internet forums.  Is Null also considered appropriate?
  • 2
2 Solutions
mccarlIT Business Systems Analyst / Software DeveloperCommented:
In XML Schema - Datatypes (3.2.16 base64Binary), the datatype is defined as...
The ·value space· of base64Binary is the set of finite-length sequences of binary octets
therefore the empty element would represent the "zero-length sequence of binary octets".

I am assuming from one of the topic areas that you have posted this question under, you are talking about .NET (although the same applies to Java or many other language). So, I think what we are talking about here is a byte array of zero length.
An empty string is what I am finding in discussions on internet forums.  Is Null also considered appropriate?
This would be different to an empty string because we are talking about binary octets aka bytes here and not strings. Also, a null is different to an empty byte array.

For example, it should deserialise into the equivalent of this...
byte[] Base64Test = new byte[0];

Open in new window

Ray PaseurCommented:
In a loosely typed language like PHP, the "falsy" values would apply to this data.  Examples include FALSE, zero, NULL, an empty array or a string of zero length.
vas85Author Commented:
Thanks for your input.  I think we will proceed with an implementation which returns a ByteArray of zero length.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Your welcome!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now