xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas L Delmelle <a_l.delme...@pandora.be>
Subject Re: embedding output escaping
Date Fri, 29 Jul 2005 00:47:58 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jul 28, 2005, at 18:42, Fabrizio Caldas wrote:

> But in my case I have hrefs mixed with plain text.
<snip />
> I don't know exactly what that string is, but I know it might have 
> hrefs.
> So my XML, if I was creating one, would look like this:
> <title>some text <a href="http://sample.com">click</a> more 
> text</title>
<snip />
> In that case I would have to parse the string I'm getting from a 
> properties file.

Yep, but there are a number of ways to go about that. Maybe only the 
generateFor() method needs to be altered. (other options include: 
modifying the type of the title member variable from a simple String to 
a composite object or a collection of Strings, but then the setTitle() 
method needs to be changed as well...)

If you know how to use java.util.regex (or any other regexp library) 
then it should be pretty straightforward to match character data and 
sub-elements, and emit the proper SAX events based on the results...


> I was trying to avoid that.

Yes, that was obvious, but: Sorry, no can do :-)

The explanation is that if you use the default generateFor() 
implementation, the title string will be entirely read into a character 
array --including any markup characters. Then a characters() event is 
emitted by the ContentHandler, and the parser implementation will 
gladly take care of generating entity references for any &, <, >, " and 
'.

Short of rewriting the parser to emit element events whenever it 
receives markup characters through a characters() event, your only 
option is indeed to parse the string yourself. If it's any consolation: 
rewriting the parser would definitely be more complicated than this. 
:-)


Greetz,

AD
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFC6XzMyHTbFO9b8aARAv7oAKCtT59yYXpudwuAyBOIRYb2qFb1hwCg22va
Mm5ioWcnboCiHB7q/jIsq/w=
=zqTB
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message