[XOM-interest] Serialize parentless Text nodes
Wolfgang Hoschek
whoschek at lbl.gov
Mon Jul 25 01:47:36 EDT 2005
On Jul 24, 2005, at 10:50 AM, Elliotte Harold wrote:
> Wolfgang Hoschek wrote:
>
>
>
>> private boolean isBoundaryWhitespace(Text text) {
>> // if (getIndent() <= 0) return false; // WH moved to write
>> (Text) (better inlining)
>> // XXX check this without getValue
>> // if (!"".equals(text.getValue().trim())) return false;
>> if (text.getValue().trim().length() > 0) return false; // WH
>> ParentNode parent = text.getParent();
>> if (parent == null) return false; // WH allow parentless
>> text
>> ... and so on
>> }
>>
>>
>
> I'm looking at this now. It's simple enough to implement, but I'm
> not sure I know yet what ti should. Specifically, in the case when
> the parent node is null, what should and should not be boundary
> whitespace? The solution you propose would assert that parentless
> text nodes are never boundary whitespace. The alternative would be
> to assert that all white space only parentless text nodes are
> boundary whitespace.
>
> This only matters when indenting, but then the problem only comes
> up in the first place when indenting. I'm not sure which way to go
> here. Anyone want to argue this one way or the other?
>
>
I have since worked in other ways around the particular case for
which I brought up the issue, so I don't really care much anymore
either way. FWIW, when in doubt choose the safe route. Thus, my
XQuery Serializer subclass is treating parentless Text nodes as never
being boundary whitespace for indentation decisions, no matter what.
I'll leave it to others to argue whichever way XOM should lean.
More information about the XOM-interest
mailing list