Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Serialize parentless Text nodes

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Serialize parentless Text nodes
  • Date: Sun, 24 Jul 2005 22:47:36 -0700

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.






Archive powered by MHonArc 2.6.24.

Top of Page