Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Binary data - base64 encoded strings - need help please....  RSS feed

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking for some help with binary data. I have a string, in my input, which I think is base64 encoded. While I can write elaborate code to spit it out as a ascii string, I was wondering if there is a way to interpret (de-code) the base64 string using any existing XSL functions.
Thanks.
- madhav
ps:
For example:
If I have an element, in my input, like this:
<Base64EncodedString>
JFHBDSLKJ3398JBKJSDAHBLKF0237-83IF7DM20
</Base64EncodedString>
I am curious if there is a way to decode it in my Style Sheet and output an equivalent ascii string.
As always, Thanks for your help.
- madhav
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I just read the other Binary decode post and am using the search at the top and I will try to read the 18 posts but incase anyone of you already solved similar issues, please please please.....
- madhav
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call Java code within XSLT thereby using the JDK's decoder class to decode it.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you provide an example or a link to get more info on this please....
I din't know we could call Java code from XSL...forgive my ignorance... :roll:
Thanks.
- madhav
 
Christophe Lee
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article is good:
http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-xslt.html
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Madhav,
The library you need to decode the base64 string is the Java Mail API. You may download it from the following page:
http://java.sun.com/products/javamail/
Inside the javax.net package, you will find the MimeUtility that serves the purpose of encoding/decoding text based on mime types.
IMHO, it's better to write a generic class that fits what you need to do in your XSLT, rather than cluttering your XSLT code with lots of java calls.
For instance, you could write a class similar to this:

Assuming you're using Xalan as your XSLT processor:

This should work, though I have not tried it ;-)
Best luck
[ November 18, 2002: Message edited by: Beno�t d'Oncieu ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Christophe Beno�t, awesome article.
- madhav
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!