[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Invoking XALAN API with an in-memory XML/XSL strin

Subject: RE: Invoking XALAN API with an in-memory XML/XSL string
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 18 Apr 2002 09:58:38 +0100
streamsource inputstream bytearrayinputstream
>
> I have a (Java) program which has two String variables:
>  - xml, whose value is the XML, and
>  - xsl, whose value is the stylesheet
>
> I am trying to invoke the XALAN API using these in-memory
> strings, e.g.,
>
> -- convert the xsl (String) to a byte array and create an instance
> -- of an InputStream:
>
>    ByteArrayInputStream is = new ByteArrayInputStream(xsl.getBytes());
>
> -- create a StreamSource using the input stream:
>
>    StreamSource ss = new StreamSource(is);
>

String.getBytes() converts characters to bytes in the "platform's default
character encoding", according to the JDK spec. I'm never quite sure what
they mean by "platform", sometimes it seems to mean the computer, sometimes
the JVM. But either way, you end up with an array of bytes in some unknown
encoding, which the XML parser then has to decipher.

Just give the parser the character string to play with directly:

StringReader sr = new StringReader(xsl);
StreamSource ss = new StreamSource(ss);

(And by the way, it's not the Xalan API, it's the JAXP API).

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.