[jdom-interest] Element, Attribute, Document: Factory

bob bob at werken.com
Sat Jun 3 12:25:10 PDT 2000

I know that it's been discussed before about JDOM
probably not following the DOM route a using factories
for Element, Attribute and Document.  I think the
original context of the question was about specializing
Element into lots of different FooElement, based
upon the tag name.  ie:  HREFElement, TableElement.

What are your thoughts on going 1/2-way that far?
I'd like to create a single subclass of Elemet, and
have it used for all Element.  Basically, I just want
to add extra helper methods to the normal Element 
class.  Nothing schema/DTD specific.  Perhaps I just
want some slightly different signatures.

I'd like the FooBuilder to use my single subclass of
Element(Document/Attribute) instead of the default.
*Not* specialized by Tag name or anything.

On a particular builder, I'd like to do this before
parsing my document.

	builder.setElementClass( MyElement.class );
	builder.setAttributeClass( MyAttribute.class );
	builder.setDocumentClass( MyDocument.class );

And then parse my document, giving me a tree of my subclasses.

If those methods aren't used, then normal default org.jdom.*
classes are used.

The rationale:

I'm using WebMacro (www.webmacro.org), and it allows special
introspect to get to an object, if it's a JavaBean.  It does
special stuff with assuming 'get' prefixes, to produce pretty
HTML templates.


translates into


Purely aesthetical reaons makes me want


Which would be


That'd require me adding Element.get() and overriding Attribute.toString().

How's that for Too Much Information?


	(yes, someone will argue I should use XSLT or similar,
	but this is legacy project just now adopting XML.  No
	hope of migration at this point).

More information about the jdom-interest mailing list