Hi Chris

What you are trying to do sounds good to me. (And your
subject line was fine too ;-)

I will have to check the source when I get back to my
laptop but I would think the code could be patched
such that when a document is parsed via SAX (which is
very common) then a factory method could be used to
let you do this kind of thing...

createElement(QName qname, Attributes attributes)

Where Attributes is the SAX Attributes interface.

Though this mechanism would only work when using SAX.
If the XPP parser was used, or one day the XNI parser,
then a different approach would be required.

James



Hello, and sorry for the confusing subject.

I'm using my own DocumentFactory so that certain
elements are mapped
to my own classes. For the most part I have a 1:1
mapping between
element types and classes. However, for a particular
element I'd like
multiple classes depending on a particular attribute
value, e.g.:

 Element      ==> Class
 <a>          --> A
 <b>          --> B
 <c type="x"> --> X extends C
 <c type="y"> --> Y extends C
 <c type="z"> --> Z extends C

The problem is that during
DocumentFactory.createElement you don't
know what the attributes are yet. Is there a
relatively clean way to
do this short of transforming the document before
parsing?

Thanks,
Chris


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to