Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Node hierarchy does not prevent cycles

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: John Cowan <jcowan AT reutershealth.com>
  • To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Node hierarchy does not prevent cycles
  • Date: Fri, 12 Sep 2003 16:43:11 -0400

Elliotte Rusty Harold scripsit:

> Is there any way to do this without appending the node itself? Hmm,
> seems like there might be:
>
> a.appendChild(b);
> b.appendChild(c);
> c.appendChild(a);
>
> This is a problem. It seems like it could require insertChild descend
> the entire subtree to verify the insertion is OK. Ugly. Does anyone
> see a simple, fast way to fix this?

"Piffle. A trifle."
--the incredibly arrogant Eastern Empire wizard from Mercedes Lackey
books

Ascend the "this" object's parent chain for the proposed child object.
If it's there, throw. If you reach the Document object safely, all is well.
The first two calls above will be fine because b is not an ancestor of a
and c is not an ancestor of b. But since a *is* an ancestor of c,
sproinggg....

--
"But the next day there came no dawn, John Cowan
and the Grey Company passed on into the jcowan AT reutershealth.com
darkness of the Storm of Mordor and were http://www.ccil.org/~cowan
lost to mortal sight; but the Dead http://reutershealth.com
followed them. --"The Passing of the Grey Company"




Archive powered by MHonArc 2.6.24.

Top of Page