Return-Path: X-Original-To: apmail-xmlgraphics-fop-dev-archive@www.apache.org Delivered-To: apmail-xmlgraphics-fop-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E91577A50 for ; Tue, 6 Sep 2011 14:12:41 +0000 (UTC) Received: (qmail 57213 invoked by uid 500); 6 Sep 2011 14:12:41 -0000 Delivered-To: apmail-xmlgraphics-fop-dev-archive@xmlgraphics.apache.org Received: (qmail 57077 invoked by uid 500); 6 Sep 2011 14:12:41 -0000 Mailing-List: contact fop-dev-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: fop-dev@xmlgraphics.apache.org Delivered-To: mailing list fop-dev@xmlgraphics.apache.org Received: (qmail 57065 invoked by uid 99); 6 Sep 2011 14:12:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2011 14:12:40 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [74.43.0.115] (HELO mail.blockhouse.com) (74.43.0.115) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2011 14:12:35 +0000 X-Ninja-PIM: Scanned by Ninja X-Ninja-AttachmentFiltering: (no action) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.5 Subject: RE: How to translate characters? Date: Tue, 6 Sep 2011 10:12:09 -0400 Message-ID: In-Reply-To: <4E657804.60701@maden.org> Thread-Topic: How to translate characters? thread-index: AcxsNOOjPrIh6dWITVGVcgcOykMYFgAZRhKw References: <4E611898.7060508@maden.org> <4E6132FA.902@maden.org> <4E6137EC.1060404@maden.org> <4E657804.60701@maden.org> From: "Eric Douglas" To: Aha! Your code was almost right. Now, I can't put a square into the XML or I get this error. SystemId Unknown; Line #188; Column #5; An invalid XML character (Unicode: 0x0) was found in the element content of the document. So I stick with putting the string value "□" into my text object I'm using to create various outputs. For a PDF I get the text value, write it to XML, run it through the transform to get FO, run it through FOP to get a PDF, then load it into pdfbox to print. The XML file contains that string. The FO file contains the square character. I'm guessing the Transformer itself knows nothing about this but something in the SAX handler converts it. For a print preview just to display a single unicode value the simplest way is to hardcode it. Your String declaration was on the right track except you need a value container. drawText =3D displayText.getText(); String CHARCHECKBOX =3D new String("□"); String CHARSMILEY =3D new String("☺"); String UNICODECHARCHECKBOX =3D new String(new int[]{0x25a1}, 0, 1 ); String UNICODECHARSMILEY =3D new String(new int[]{0x263A}, 0, 1 ); drawText =3D drawText.replaceAll(CHARCHECKBOX, UNICODECHARCHECKBOX); drawText =3D drawText.replaceAll(CHARSMILEY, UNICODECHARSMILEY); I don't know an easy way to find and replace all possible such unicode strings aside from creating a custom SAX handler and wrapping the text in some default XML to recreate what the Transformer is doing. =20 -----Original Message----- From: Christopher R. Maden [mailto:crism@maden.org]=20 Sent: Monday, September 05, 2011 9:32 PM To: fop-dev@xmlgraphics.apache.org Subject: Re: How to translate characters? On 09/05/2011 06:31 PM, Eric Douglas wrote: > So, I'm confused. I put that exact string into an fo:inline. > I'm running embedded code and I separated the XML-FO transform step from the FOP step. > I'm just running a straight Oracle transform. > My input is an XML file containing the string □ My transformer=20 > is created using an XSL file. > My output is an FO file with that string converted to a square. > I put that string into a Java String and get the value. It comes out the same as it went in. > How do I get the value of the String as a square? Java is not XML. Java has no native facility for interpreting an XML numeric character reference, so you are getting exactly the expected results. I don't speak Java well, but try something like this: String square =3D new String( [ 0x25a1 ], 0, 1 ); Then pass that string, square, to FOP. If that doesn't help, I'm done; I can read Java, but don't really write it well. ~Chris -- Chris Maden, text nerd "The present tendency and drift towards the Police State gives all free Americans pause." - Alabama Supreme Court, 1955 (Pike v. Southern Bell Tel. & Telegraph, 81 So.2d 254)