Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Subclass of Element does not propagate to Document

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Steve Loughran" <steve.loughran AT gmail.com>
  • To: fbaube AT saunalahti.fi
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Subclass of Element does not propagate to Document
  • Date: Mon, 12 Mar 2007 16:09:56 +0000

On 12/03/07, Fred Baube <fbaube AT saunalahti.fi> wrote:
I'm trying to
1) subclass nu.xom.Element with a class named my.MElm, and
2) ensure that the nu.xom.Document that XOM builds for me
uses my MElm's rather than nu.xom.Element's.

According to the text at http://www.xom.nu/tutorial.xhtml#d0e1424
("Factories, Filters, Subclassing, and Streaming"), I also have to
subclass NodeFactory. I do this, calling it my.MNodeFactory.

So, in method my.MNodefactory.startMakingElement(String NS_URI,
String name) , I return an instance of my.MElm.

I verify downstream that XOM accepted this instance of the subclass,
and I finish the element like so:

finishMakingElement(nu.xom.Element E) {
assert (E instanceof my.Elm); // succeeds
return (super.finishMakingElement (E));
}

But when I obtain the Document that is created by XOM, I find that
the nodes in the document are instances of nu.xom.Element, not my.Elm.


Its probably the root element that isnt matching, because that has a
separate method that you need to override, possibly by redirecting to
your startMakingElement/2 method.


public Element makeRootElement(String name, String namespace) {
return startMakingElement(name, namespace);
}




Archive powered by MHonArc 2.6.24.

Top of Page