On 08 Apr 2009, at 04:27, Phạm Duy Hưng wrote:

Hi

Hi, please help me to resolve this debug, im using FOP to render Report using XML and XSL. But this's a problem when using XSLTInputHandler. I'd tried 2 way



1> With Syntax: XSLTInputHandler(File, File) -> its run ok
<snip />
2> With Synxtax: XSLTInputHandler(InputSource, InputSource) -> Error: 'Could not compile stylesheet'

Details:

[Fatal Error] :1:1: Premature end of file.
ERROR:  'Premature end of file.'
FATAL ERROR:  'Could not compile stylesheet'

<snip />

I'm suspecting an encoding issue. Is the XSLT file 'properly' encoded?
I mean:
a) Is there an encoding specified in the XML declaration?
b) If yes, then does this encoding correspond to the actual encoding of the file? If not, then is your XSLT file UTF-8 encoded?

It's a long shot, but as far as I remember:

InputStream inXSL = new FileInputStream("C:/ glossary.xsl");
<snip />

            try {
input = new XSLTInputHandler(new InputSource(inXML), new InputSource(inXSL));

A compliant XML parser will assume the 'inXSL' stream to return UTF-8 encoded bytes (unless you explicitly force the encoding of the InputSource via setEncoding()). If this does not match the actual encoding of the file (for example UTF-16), then you might get the effect of one character that is encoded as two bytes, but the two bytes are interpreted as two separate characters of which the first will be a null character (\u0000). That in turn will confuse the parser into thinking that it has reached EOF, while it has in fact only read the first byte...

Another cause of such confusion could be the presence of a Unicode Byte-order Mark.


HTH!

Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to