You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Roger L. Costello" <co...@mitre.org> on 2002/04/17 20:21:38 UTC
Invoking XALAN API with an in-memory XML/XSL string
Hi Folks,
[NOTE: Please mail responses directly to me. Thanks!]
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);
-- create a Transformer using the stream source:
Transformer transformer = tFactory.newTransformer(ss);
When I execute the program I get an error message:
[Fatal Error] :1:1: Content is not allowed in prolog.
where the following is referenced as the offending instruction:
Transformer transformer = tFactory.newTransformer(ss);
Note: there is nothing wrong with my stylesheet. When I run it from the
command line everything works fine.
Any ideas on what causes this error message? Have you invoked the XALAN
API with in-memory strings? How did you do it? /Roger
RE: Invoking XALAN API with an in-memory XML/XSL string
Posted by Gary L Peskin <ga...@firstech.com>.
It sounds like there is a problem with the value of the xsl variable.
Can you print it out prior to the newTransformer call and see what it
looks like?
Gary
> -----Original Message-----
> From: Roger L. Costello [mailto:costello@mitre.org]
> Sent: Wednesday, April 17, 2002 11:22 AM
> To: xalan-dev@xml.apache.org; costello@mitre.org
> Subject: Invoking XALAN API with an in-memory XML/XSL string
>
>
> Hi Folks,
>
> [NOTE: Please mail responses directly to me. Thanks!]
>
> 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);
>
> -- create a Transformer using the stream source:
>
> Transformer transformer = tFactory.newTransformer(ss);
>
> When I execute the program I get an error message:
>
> [Fatal Error] :1:1: Content is not allowed in prolog.
>
> where the following is referenced as the offending instruction:
>
> Transformer transformer = tFactory.newTransformer(ss);
>
> Note: there is nothing wrong with my stylesheet. When I run
> it from the command line everything works fine.
>
> Any ideas on what causes this error message? Have you
> invoked the XALAN API with in-memory strings? How did you do
> it? /Roger
>