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 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Joe TailorSubject: Please help!! XML AND XSL Transform with Embedded Image
Author: Joe Tailor
Date: 26 Jul 2007 04:19 PM
Originally Posted: 26 Jul 2007 09:37 AM
I have an embedded image in my xml document, I created an xsl, but for some reason when I render it the Image will not show. I have tried everything I have read but have had no luck any ideas what i am doing wrong?

Thanks.
I have attached my file so you can see what I mean


DocumentSummary.xml
xml file

DocumentUntitled1(1).xsl
the xsl

Postnext
(Deleted User) Subject: Please help!! XML AND XSL Transform with Embedded Image
Author: (Deleted User)
Date: 27 Jul 2007 08:13 AM
Hi Joe,
what is the format of the image? I tried decoding it using base64, but the resulting binary doesn't look any of the usual image format.

Alberto

Postnext
Joe TailorSubject: Please help!! XML AND XSL Transform with Embedded Image
Author: Joe Tailor
Date: 27 Jul 2007 09:40 AM
It is in .jpg format what give?

Postnext
(Deleted User) Subject: Please help!! XML AND XSL Transform with Embedded Image
Author: (Deleted User)
Date: 27 Jul 2007 10:40 AM
Hi Joe,
if it were JPEG, the decoded stream should contain the "JFIF" string in the first few bytes; but if you take the beginning of the content of the <image> tag (e.g. 89504E470D0A1A0A0000000D494844520000016D000001900806000000650D31) and paste in the form at http://www.opinionatedgeek.com/dotnet/tools/Base64Decode/Default.aspx you will get back something that has several M4 strings, but nothing that resembles an image format.
Unless the format is not even base64....
Got it: the format is simply the hex dump of the image, and the image is really a PNG (the 49484452 sequence found in the first few letters is the string IHDR, used by the PNG format).
So you should convert the stylesheet to be XSLT 2.0 and use the new datatypes it provides to convert the hexdump into base64, then you could use the 'data:' URL scheme to tell your (Firefox, IE doesn't support it) browser to load the image form the URL itslef.

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.stylusstudio.com/xquery"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
[....]
<IMG src="data:image/png;base64,{xs:base64Binary(xs:hexBinary(/Summary/New_Record/image))}"/>

If you need to be compatible with IE, you will have to save the use a Java extension function to save the data to a temp file, and reference that file in the IMG tag.

Hope this helps,
Alberto

Postnext
Joe TailorSubject: Please help!! XML AND XSL Transform with Embedded Image
Author: Joe Tailor
Date: 27 Jul 2007 10:50 AM
WOW, I was told they were jpegs I was pulling from the data base. Boy that was a really helpfull reply, Thank you so much!

At least now I know I can not do it through encoding because its gotta be IE compatible.
Ok so <Img> tags ,I have been trying to do it through an image tag but I have had no luck. for some reason my dynamic variable will not show, I actually posted this in a new topic called "Why is this variable not showing?"

Thanks again for taking the time with a frusterated and pressed for time xml newbie =)

Posttop
Joe TailorSubject: Please help!! XML AND XSL Transform with Embedded Image
Author: Joe Tailor
Date: 27 Jul 2007 10:51 AM
Originally Posted: 27 Jul 2007 10:18 AM

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.