Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2005, 05:13 AM
Authorized User
 
Join Date: Sep 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing byte[]

Hi,
i am calling from a XSLT Stylesheet, a Java function that returns a byte[] and i want to use that, and output it to the destiny file, i have this line

<xsl:value-of select="rbt:Utils.returnFile(@src)"/>

I get an error, saying it couldn't convert a byte to String, if i change the function return to a String it works, but then i don't have the correct bytes, and i don't have the propper result.
Is there anyway to output bytes?
Thanks

 
Old October 10th, 2005, 05:43 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The rules for extension functions depend on the XSLT processor you are using, no-one can answer this question without having that information.

I'm not sure how you would expect an XSLT processor to translate bytes to characters. What encoding should it assume: UTF-8, UTF-16, ASCII, the platform default?



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 10th, 2005, 05:48 AM
Authorized User
 
Join Date: Sep 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was hoping there was another command (instead of <xsl:value-of>) that could receive a byte[]
The problem is i have an Image, and i want to write it's bytes to the response (because i'm creating a Multipart Response), and if i translate those bytes to a String (new String(byte[])) it doesn't work

Is there anyway i can get this to work
thanks

 
Old October 10th, 2005, 07:12 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT can't produce binary output. Using 2.0 you can however produce base64 or hexBinary encoded output.

In Saxon 8.x, if an extension function returns byte[], Saxon translates this into an XPath 2.0 xs:integer*, that is, a sequence of integers. You can then convert this to a base64binary value using the extension function saxon:octetsToBase64Binary(), or to a hexBinary value using saxon:octetsToHexBinary(). You could then output these values to a result document and use some non-XSLT process to convert the result document into real binary.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting int to byte yukijocelyn C# 2005 1 May 30th, 2008 03:44 AM
convert byte[] to hex value gunjan.sh C# 2005 4 January 24th, 2008 05:15 AM
Byte alignment or byte padding subodh_chettri C++ Programming 0 June 23rd, 2006 10:35 AM
sending byte to comport Puffeltje VB How-To 0 January 20th, 2006 06:07 PM
convert byte to bitmap jlzmut C# 2 December 18th, 2005 05:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.