RE: [xsl] Getting an image from base64-encoded data

Subject: RE: [xsl] Getting an image from base64-encoded data
From: "Joshua Allen" <joshuaa@xxxxxxxxxxxxx>
Date: Fri, 19 Oct 2001 14:47:34 -0700
Right, XSD now has the base64 and binhex binary data types, which would
probably be preferable to the Microsoft-specific type names now.
However, the issue is the same -- both binary types in XSD are just text
encodings which have to be decoded.  There are some free libraries
available written for COM, Java, Perl, etc. that will do Base64
decoding, but like you point out, that code is not intrinsic to XSLT,
XPath or the XML DOM.  So everyone ends up having to do it their own
way.  The MS.NET Frameworks has a non-standard additional method on the
DOM to let you read Base64 as a binary stream (and presumably then write
to a file).  But since there is no standard, other vendor APIs will
vary.  And I have found that reading the text stream and passing it to
some custom function like decodeBase64() is not too much of a burden.
The thing I have found most annoying about this is that, while you can
still get the binary stream, you have no idea what the file name or
mime-type is.  So if your program has to set response mime-types or
filenames, you have to also embed that information in attributes on the
XML, and since there is again no standard way to do this, you always
worry about interop..


> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
> Sent: Friday, October 19, 2001 2:20 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Cc: ZHihui Li
> Subject: [xsl] Getting an image from base64-encoded data
> Hi,
> I've been asked off list what the best approach is in the following
> situation:
> You have an XML document that contains an element that contains a
> base64-encoded image, something like:
> <Document_Type>
>   <IMAGE xmlns:dt="urn:schemas-microsoft-com:datatypes"
>          dt:dt="bin.base64">SUkqAAgAAAAPAP4ABAABAAAAAA...</IMAGE>
> </Document_Type>
> You need to get a .tif file that contains the binary data encoded
> within the XML.
> I suggested writing the content of the IMAGE file out into a text file
> with XSLT and then converting from base64 to binary through an
> external process. I wondered if anyone else had other suggestions
> about how to deal with it? For example, using extensions?
> And thinking further than that... XML Schema has a couple of binary
> data types - is this (decoding and writing out binary) going to be a
> requirement that we encounter in future versions of XPath/XSLT? Is it
> ever going to be XSLT's job?
> Thanks in advance for your thoughts,
> Jeni
> ---
> Jeni Tennison
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread