[xsde-users] Q: Issue found with xml_schema::base64_binary

Boris Kolpackov boris at codesynthesis.com
Tue Sep 30 06:04:36 EDT 2014


Hi Ravi,

Rangarajan, Ravi_Sowmian <raviraja at qti.qualcomm.com> writes:

> When base64 encoding an MD5 of a file, following steps are followed.  I have
> attached the FDT.xsd schema that is used to generate the reference
> code. Buffer md5 is a 16-byte buffer that contains MD5 of a file as binary
> and it needs to be sent as base64-encoded. I have verified computed MD5 is
> correct (as against reference info for that file) - however, base64md5 is
> showing up as "CXvk0ap1opO5qLQUh+hLAg==&#xA" in the final output, where
> first 24 chars of this string are correct while last four, i.e. &#xA are
> extra (MD5 should end with == in above example).

Brian Tuite has already asked this question (off-list):

> 2.            XSD/e appends "&#xA;" to type base64_binary
>
> XSDE library is appending line feed in hex format (&#xA;) while doing
> base64 encoding of data with data type xs:base64Binary.
>
> For example, for the following schema
>
> <xs:attribute name="Content-MD5" type="xs:base64Binary"
> use="optional"/>
>
> And for the input string ce4981fba69b1b6d7419c42fc5f53aca, the output
> should be generated as zkmB+6abG210GcQvxfU6yg==
>
> But it comes out to be zkmB+6abG210GcQvxfU6yg==&#xA;

And my reply was:

XSD/e outputs what is called a canonical representation of base64Binary 
which requires a trailing newline. See this email for details, especially
towards the end:

http://lists.w3.org/Archives/Public/xml-dist-app/2001Jul/0323.html

So we cannot change it in the default XSD/e implementation. The options
that I see are:

1. Again, customize the serializer to write it in the form you expect.

2. Customize the XSD/e source code and remove the lines that add the
   trailing newline. We could also add an #ifdef to disable this final
   newline to the XSD/e runtime for the next release.

To which Brian replied that he is already using a custom serialize
for base64_binary. Could you check with him if you can use the same
solution?

Boris



More information about the xsde-users mailing list