Hi folks,
we are developing a Java application (using Xerces, latest release)
which should be able to create a "customized" DOM tree out of a flat XML
file. The word "customized" means that the tree (mostly) consists of
myElementImpl (instead of ElementImpl). myElementImpl is derived from
ElementImpl and contains some additional properties (i. e. a reference
of a object tree representing the content declaration of that element
type which is not a part of DOM).
Putting it into practice may done as follows:
- new class myDOMParser derived from DOMParser
- call setDocumentClassName("myDocumentImpl") in constructor to
switch the document factory
- new class myDocumentImpl derived from DocumentImpl
- override createElement(java.lang.String) to produce
myElementImpl objects instead ElementImpl objects
The original source code of DocumentImpl.createElement is:
public Element createElement(String tagName) throws DOMException {
if (!isXMLName(tagName)) {
throw new DOMExceptionImpl(DOMException.INVALID_CHARACTER_ERR,
"INVALID_CHARACTER_ERR");
}
return new ElementImpl(this, tagName);
}
<QUESTION>
If I do it like this:
class myDocumentImpl extends DocumentImpl {
createElement(String tagname) throws DOMException {
Element localElement = super.createElement(tagname);
...
}
}
... how can I make a new myElementImpl object out of localElement
(which is a ElementImpl instance)? Some kind of cloning? No idea.
If I do it like this:
class myDocumentImpl extends DocumentImpl throws DOMException {
myDocumentImpl.createElement(String tagname) {
// no super call
if (!isXMLName(tagName)) {
throw new DOMExceptionImpl(...);
}
return new myElementImpl(this, tagname);
}
}
... I would lose functionality of DocumentImpl.createElement (okay
there is not much code in it but I do not want to lose it anyway).
</QUESTION>
Any suggestions how to solve this problem?
Thank you for helping!!
Ciao, Bens.
______________________________________________________________________
_______
/ __ /____________ ______
/ /_/ // __ / // /\ Thomas Bensler
/ ___// /_/ / 7 ___/_/ debis Systemhaus GEI
/ __ 7 ___/ / /___ /\ Lademannbogen 21-23
/ /_/ / / / / / / / D-22339 Hamburg
/_______/_____/__/___/_______/ / fon: +49-40-5395-1879
\_______\_____\__\___\_______\/ net: [EMAIL PROTECTED]