Prabhat Kumar (IT) wrote:

I am having to escape special characters such as apostrophes (replace with
&apos) to get them to display correctly on PDFs. Is this really necessary?

Basically What I do is,

1. Read Database.
> 2. Generate XML for this data.
> 2a. During this generation, replace characters such as apostrophes, quotes,
> ampersands with ' " & respectively.
> 3. Apply XSL-FO transormations to this XML 4. Write the
generated PDF's bytes to a the ServletOutputStream.

Step 2a seems wasteful to me. Has anyone had to do this before? Is there a
better way?

It depends. It seems you generate the XML as string. In this case you have always to escape the ampersand. The apostrophe and quote characters need only to be escaped in attribute values (and even then not always), there is no need to replace them in text content.

You can look at generating a DOM, or SAX events. In this case you must
not escape special XML characters, but this also means you can't store
XML snippets with markup in your database.

J.Pietschmann


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to