I am creating an XML input file as a string in Java and then send it to fop
as a StreamSource. I convert '<' to '<' when I am creating the XML. If I
don't, the XSLT engine chokes.
If I look at the .fo that is created when I run my stylesheet I find:
<fo:block font-size="7pt"></= 1.5%</fo:block>
Which expect FOP To render as '</= 1.5%', but it doesn't. The '<' does
not get converted to '<'.
Here's my code that operates FOP:
public class PDFGenerator {
public PDFGenerator() {
super();
}
public static byte[] toPDF(String xmlIn, byte[] xsltIn)
throws TableEngineException {
ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
Driver driver = new Driver();
Logger logger = new
org.apache.avalon.framework.logger.ConsoleLogger();
driver.setLogger(logger);
MessageHandler.setScreenLogger(logger);
driver.setRenderer(Driver.RENDER_PDF);
OutputStream out = pdfStream;
try {
driver.setOutputStream(out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new
StreamSource(
new ByteArrayInputStream(xsltIn)));
Source src = new StreamSource(new java.io.StringReader(xmlIn));
Result res = new SAXResult(driver.getContentHandler());
transformer.transform(src, res);
} catch (Exception e) {
throw new TableEngineException("FOP Error");
}
return pdfStream.toByteArray();
}
}
-----Original Message-----
From: J.Pietschmann [mailto:[EMAIL PROTECTED]
Sent: Friday, September 12, 2003 2:55 PM
To: [EMAIL PROTECTED]
Subject: Re: problem with entity characters - <
Holk, David A wrote:
> I would expect this:
> <fo:block font-size="7pt"></= 1.5%</fo:block>
> to be rendered as:
> </= 1.5%
> in my pdf. But instead I am getting this:
> </= 1.5%
> How can I get my expected output?
You are probably confusing XML documents and XML APIs. In a
XML document you'll have to encode a less sign as <. If
you put text in a DOM tree, you just use '<'. You don't have
markup in DOM tree text nodes, therefore no escaping of
special characters is necesary. Same for SAX character
events.
Another possiblity is that you've some doubel escaping
somewhere. It's hard to say without knowing how you feed
input to the FO processor and how your data is generated.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be
privileged. It is intended for the addressee(s) only. Access to this E-mail by
anyone else is unauthorized. If you are not an addressee, any disclosure or
copying of the contents of this E-mail or any action taken (or not taken) in
reliance on it is unauthorized and may be unlawful. If you are not an
addressee, please inform the sender immediately.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]