Hi, Sheen --
I haven't really tried this myself and I'm sort of short on time so I'll
just give you some ideas that might unravel this mystery.
Are you certain that xsltFilterBytes[] contains the same number of
elements and that corresponding elements have the same value in both the
freestanding class and jar'd class? Try writing a program that gets the
information both ways and then execute
boolean b = Array.equals(xsltFilterBytesFromClass,
xsltFilterBytesFromZip);
and see if b is true or false.
Since the above will require some restructuring of your program , you
might get similar insights by including the following statements in your
existing code and comparing the values:
System.err.println("inputStream class is " + inputStream.getClass());
System.err.println("total size is " + totalSize);
HTH,
Gary
> -----Original Message-----
> From: Sheen Brisals [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 24, 2002 9:47 AM
> To: [EMAIL PROTECTED]
> Subject: TransformerConfigurationException
>
>
> Hi there,
>
> I am facing a strange problem which I haven't anticipated.
>
> I have an xslt stylesheet as a text file in my java class file
> location. I read the file contents and create a transformer instance
> for repeated use within the program. Following is the sample code
> snippet I use.
>
> .....
> .....
> m_transformerFactory = (TransformerFactory)
> TransformerFactory.newInstance();
>
> InputStream inputStream =
> this.getClass().getResourceAsStream(
> fileName );
> int totalSize = inputStream.available();
> byte xsltFilterBytes[] = new byte[totalSize];
> inputStream.read( xsltFilterBytes);
>
> StreamSource xsltFilterSource = new StreamSource(
> new ByteArrayInputStream(
> xsltFilterBytes ));
>
> // Create the Transfomer instances for the stylesheet.
> m_xsltFilterTransformer =
> m_transformerFactory.newTransformer(
> xsltFilterSource );
> .....
> .....
>
> This code works fine when working with the class file
> locally. But when
> packaged as a jar file and reading from there it throws
> TransformerConfigurationException when tries to create the
> newTransfomer. The file is read correctly, the contents are
> the same in
> both cases. Following is the error I get.
>
> javax.xml.transform.TransformerConfigurationException:
> javax.xml.transform.TransformerException:
> org.xml.sax.SAXParseException: An invalid XML character
> (Unicode: 0x0) was found in the element content of the document.
>
> Instead of reading as byte stream I tried using the class loader with
> URL and still the TransformerFactory is not happy. Why would it
> complain about the Unicode character error? I'm running out of ideas.
>
> Please someone help me to resolve this problem. This has become a
> show-stopper in my case.
>
> Thanks,
> Sheen
>
>