Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Recursion

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: jcowan AT reutershealth.com
  • To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Recursion
  • Date: Tue, 9 Mar 2004 16:32:16 -0500

Elliotte Rusty Harold scripsit:

> 3. The Element copy constructor, and by extension Element's copy
> method. This is the one I'm on the fence about. It's not that much
> harder to make it non-recursive. The problem is that if I do so, then
> descendant elements can lose their subclasses since the copies will
> be created with the Element constructor and copy() method rather than
> the Element subclass copy constructor and copy method. This could be
> fixed but only by adding an additional protected method to the
> Element API that creates an empty element of the right subclass which
> copy could then call.

Unfortunately, I think this is the important one, because it's not
replaceable. If you foresee a problem with serializing, you can use a
different serializer, but Element.copy and Element(anElement) are critical
parts of the API. And if you are running a server that is meant to handle
arbitrary incoming documents (and assuming you have some check for gross
size), then blowing up on nesting depth is really not acceptable.

A way to avoid the API wart would be to check if the element to be copied
is an actual Element or a subclass, and in the latter case, using
sourceElement.getClass().newInstance() to call the argless constructor.

--
Do NOT stray from the path! John Cowan <jcowan AT reutershealth.com>
--Gandalf http://www.ccil.org/~cowan




Archive powered by MHonArc 2.6.24.

Top of Page