Displaying Base64Binary Problem

Here should go questions about transforming XML with XSLT and FOP.
Posts: 8
Joined: Wed Nov 09, 2005 12:31 pm

Displaying Base64Binary Problem

Post by ivan603 » Tue Feb 07, 2006 8:44 am

Hi all, i encountered a problem on displaying node value which is in Base64Binary data type when send it to XSL page. The node value is showing belows:

Code: Select all

<MessageTest xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">VABlAHMAdABpAG4AZwA=</MessageTest> 
The original value before convert to binary type is "Testing".

In XSL, when i select the node value:

Code: Select all

<xsl:value-of select=".//MessageTest">
the XSL returned the binary value, "VABlAHMAdABpAG4AZwA=" not "Testing".
Actually my expected output is "Testing".

Does anyone know how to convert the binary data to string in XSL, please help me to solve the problem.

Site Admin
Posts: 2102
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Tue Feb 07, 2006 11:04 am

Hi Ivan,

Note that base64 encoding encodes a binary value as text. So VABlAHMAdABpAG4AZwA= is not the binary value, is the text and the bytes representing Testing are forming the binary value. Now XSLT does not work at bytes level so you cannot output bytes from XSLT. The only way you can handle this from XSLT is to use some extension function that given a base64 encoded value will decode that to the encoded bytes and then will use the encoding you know was used to extract a text from those bytes and return that text.

Best Regards,

Post Reply