On Oct 31, 2005, at 22:18, Andreas L Delmelle wrote:

On Oct 27, 2005, at 06:29, Manuel Mall wrote:
Actually something like:
<fo:block background-color="yellow">word1<fo:character
character="&#10;"/><fo:character character=
" "/>word2<fo:character character=" "/>word3<fo:character
character="&#10;"/></fo:block>
currently causes an exception!



The problem can be solved by a slight modification to OneCharIterator:
* add a constructor with Character parameter (and member)
* add a remove() implementation which makes Character's parent remove it from its list of child nodes

Tested locally (very quickly), and seems to work nicely. If I get the chance to commit it in the next few days, I'll do so myself, but if you want to have a go, it's a pretty easy fix (adds up to about 10-15 LOC incl. javadocs :-))

Oops, been too quick. From an UnsupportedOperationException to a ConcurrentModificationException... The trick seems to be to introduce a small boolean 'discard' switch to the Character object, flip this upon calling OCIter.remove(), and have the Block/Inline later remove any of its characters marked as discardable, but do this (of course) only after the RecursiveCharIterator has finished --to avoid the childNodes list from being altered while it's being iterated over...

Other option: store a list of the discardable space fo:characters at Block or Inline level, instead of marking the Character itself as such...

A bit more than 15 LOC, but still quite doable.

Cheers,

Andreas

Reply via email to