XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Steve NicolsonSubject: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 28 Jun 2007 05:17 AM
Originally Posted: 28 Jun 2007 01:07 AM
Hi everyone!

I have images that are encoded in XML, like..

<EmployeePicture content-encoding="base64" content-type="image/pjpeg" filename="pic.jpg">/9j/4AAQSkZJRgABAgEAlgCWAAD/ADWdwETDRSdcsadghASDWEdG
</EmployeePicture>

I have the node <EmployeePicture>, but how can i render the pic embedded in XML through XSL?

Postnext
Alberto MassariSubject: Rendering base64 images embedded in XML
Author: Alberto Massari
Date: 28 Jun 2007 07:34 AM
Hi Steve,
if your XSLT generates HTML, and the final browser supports it, you can try using the data: protocol (see http://developer.mozilla.org/en/docs/The_data_URL_scheme for more details). Or, if the file that is referenced in the XML already exists, you can create an <img> tag that points to it; otherwise you should be using XSLT 2.0 to write the data to a file and then use the <img> tag.

Hope this helps,
Alberto

Postnext
Steve NicolsonSubject: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 28 Jun 2007 08:11 AM
The file is not referenced but contained within the XML file as binary data. Acc to your suggestion I guess I'll have to use XSLT 2.0 to write the data to a file and then use the <img> tag. Please provide more suggestions on this technique.

On the other hand, i came up with another option after some R&D. i.e. i have a java function (public static byte[] b64DecString(String s)) which converts the string into a byte array. The problem with this is that how can i use this external function in my XSL? do i need to upload the xsl on my server to get the java function work?

Postnext
Alberto MassariSubject: Rendering base64 images embedded in XML
Author: Alberto Massari
Date: 28 Jun 2007 08:48 AM
Hi Steve,
supports for invoking Java extension functions depends on the processor used; to see an example of how this can be done, look at the IntDate.xsl example that you find in the examples that ship with Stylus Studio.

Hope this helps,
Alberto

Postnext
Steve NicolsonSubject: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 28 Jun 2007 09:41 AM
Thanks for the prompt reply, Alberto

If you could attach IntDate.xsl in your post as i dont have it here!

Thanks

Postnext
Tony LavinioSubject: Rendering base64 images embedded in XML
Author: Tony Lavinio
Date: 28 Jun 2007 09:53 AM
It is in the examples project of Stylus Studio.

(Since this is a support forum for Stylus Studio users,
it is assumed that you use our product when you post
here.)

Postnext
Steve NicolsonSubject: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 29 Jun 2007 02:03 AM
Originally Posted: 29 Jun 2007 01:45 AM
If the example is included in any of the trial versions of Stylus Studio, available for free in other words, then i don't think if there is any harm in sharing the file; also as the forum title suggests "XSLT Help and Discussion" :o)

Newyz i'll go download stylus in any case once i am done with this task. i have heard a bit about the goodness it can bring to developer's work ;)

Postnext
Steve NicolsonSubject: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 29 Jun 2007 08:58 AM
Ok i have the file. I have the java function. It intakes the string and returns a byte array.

Now the problem is that I am having exception in calling java function from my XSL (XalanXPathException: The function number 'http://xml.apache.org/xslt/java:com.utilities.ConversionUtils.base64DecodeString' is not available.)

Postnext
Alberto MassariSubject: Re: Rendering base64 images embedded in XML
Author: Alberto Massari
Date: 29 Jun 2007 09:23 AM
Hi Steve,
have you checked that the JAR file with the function is specified in
the CLASSPATH?
Once that is verified, I would also write a different function in
Java that receives the string with the base64 data and a string with
a filename, and internally does the conversion plus the writing;
otherwise you could have problems mapping the byte[] datatype into an
XSLT type.

Alberto

Postnext
Steve NicolsonSubject: Re: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 03 Jul 2007 09:28 AM
Originally Posted: 03 Jul 2007 09:27 AM
Thanks Alberto for the suggestion..

Also tried by adding the jar-files folder in my classpath. The problem persists :(

(The above error was from Macromedia Dreamweaver test mode)

The actual server side error:
Namespace 'http://mycomp.com/namespaces/wcm/apps/1.0' does not contain any functions.

Postnext
Alberto MassariSubject: Re: Rendering base64 images embedded in XML
Author: Alberto Massari
Date: 03 Jul 2007 03:50 PM
Hi Steve,
I'm sorry, but I don't know what to suggest; I don't know how DreamWeaver works, and your (unnamed) application server seems to have even more serious configuration problems....
The only suggestion left is to turn this question to the appropriate forum.

Alberto

Postnext
Steve NicolsonSubject: Re: Rendering base64 images embedded in XML
Author: Steve Nicolson
Date: 06 Jul 2007 06:11 AM
Thanks again Alberto

While exploring the stylus (javaExtension) example that you referenced earlier, I found this IntDate.xquery file.

[code]
declare namespace ext = "ddtekjava:IntDate";
declare function ext:getDate($year as xs:double, $month as xs:double, $day as xs:double, $format as xs:string) as xs:string external;

for $date in /doc/date
return ext:getDate($date/@year, $date/@month, $date/@day, $date/@format)[/code]

I just got the feeling that I had been missing on this file. Could you tell a bit about what is the purpose of this file, and how should i be using it if i am to call my external java function.

Posttop
Alberto MassariSubject: Re: Rendering base64 images embedded in XML
Author: Alberto Massari
Date: 06 Jul 2007 09:18 AM
Hi Steve,
the IntDate.xquery performs the same operation of the IntDate.xsl, the only difference being the language in which it is implemented (XQuery vs XSLT). You should check if your application server can process XQuery transformations before trying to use this sample.

Hope this helps,
Alberto

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.