Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 21st, 2009, 12:33 AM
Registered User
Join Date: Aug 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Question Convert ASCII (Byte[] Array) to Binary

How can I convert XML data in ASCII format, to a single element containing Base-64 data.

In other words, how can I convert a list of ASCII elements like the following:


To its base64 representation, something like this:


(the ASCII XML elements represent a small section of a word document)

Reply With Quote
  #2 (permalink)  
Old August 21st, 2009, 03:50 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts

First point: ASCII stops at 127. When you say ASCII, I assume you mean Unicode or perhaps iso-8859-1?

Base64 is an encoding of a byte stream. So I assume you want these codes treated as single bytes. In that case, it's actually immaterial whether they are ASCII codes or iso-8859-1 codes or anything else - they are just bytes.

There's no direct way of doing this in pure XSLT 1.0 or 2.0. Saxon however has an extension function that you could use:



<xsl:value-of select="saxon:octets-to-base64Binary(/Document/data/xs:integer(.))"/>
should do the trick.
Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert bytes to byte[] array d-mart Java Basics 4 April 24th, 2009 10:09 AM
Converting an ASCII character to binary? skyraider Visual Basic 2005 Basics 0 May 7th, 2006 08:20 PM
Binary Data OR Byte() OR BitArray... to Integer pgjuun2 VB How-To 0 March 13th, 2005 11:52 PM
Differences between ASCII and Binary Files kuba C# 1 October 17th, 2004 07:22 PM
URGENT byte associated with the ASCII code shine Javascript How-To 0 July 5th, 2004 09:41 AM

All times are GMT -4. The time now is 06:06 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.