AW: [Xml-compile] Automatic (unobtrusive) handling of Base64

Michael Ludwig m.ludwig at epages.com
Wed Jan 25 10:12:55 GMT 2012


> -----Ursprüngliche Nachricht-----
> Von: Mark Overmeer [mailto:mark at overmeer.net]
> * Michael Ludwig (m.ludwig at epages.com) [120124 17:57]:
> > I just discovered the Base64 data type, when specified in
> > a schema, is handled by the library automatically.
> >
> > This comes in handy when you know about it.
> > It is when you don't know about it that it can cause grief.
> 
> When you put 3.6 on an integer field, you get 4.  With various kinds
> of string types, you get tricks with blanks. Digits formatting in
> floats. Into utf8 encoding of text, etc... All auto-formatting of the
> data to suit the type. The base64Binary type is a binary which gets
> represented in base64, just as hexBinary will represent the binary in
> hex.
> 
> The concept is that "transport" formatting into XML is performed
> automatically.  It would be inconsequent not to base64 automagically.

I'm not arguing against this behaviour. It is handy when you know about it.
Why have client code do what the library can do?

> The currect text with XML::Compile::Schema::BuiltInTypes::base64Binary()
> is
> 
>     In the hash, it will be kept as binary data.  In XML, it will be
>     base64 encoded.
> 
> How can I make this clearer?

This text is clear. The problem was me not reading it. It is in a reference
section that you wouldn't necessarily work through when starting to use the
library. (Because, after all, you know how to do Base64, you've done it many
times before; unlike, say, configuring the library to meet the specificities
of the service you're interfacing with.)

Which is why I thought a more prominently exposed mention of the type
handling feature might be beneficient. (See doc URLs in my last mail.)
Something along the lines of:

  XML::Compile will automatically handle XML Schema types for you.
  For instance, a float supplied to a field defined as xsd:integer
  will be converted to an integer; and data supplied to a field
  defined as xsd::base64Binary will be encoded as Base64, so don't
  do the conversion yourself, you'll get double encoding! :)

Consider that looking at double-encoded Base64, unlike double-encoded UTF-8,
it won't necessarily occur to you that it's double-encoded. It does look
correct.

Michael



More information about the Xml-compile mailing list