Alex
--- dom4j-1.4/src/java/org/dom4j/tree/AbstractDocument.java 2003-04-07
21:51:34.000000000 -0700
+++ /home/avernet/java-src/dom4j-1.4/src/java/org/dom4j/tree/AbstractDocument.java
2003-11-06 15:32:54.069225600 -0800
@@ -140,22 +140,25 @@
}
public Element addElement(String name) {
- checkAddElementAllowed();
- Element node = super.addElement(name);
+ Element node = getDocumentFactory().createElement(name);
+ checkAddElementAllowed(node);
+ super.addElement(name);
rootElementAdded(node);
return node;
}
public Element addElement(String qualifiedName, String namespaceURI) {
- checkAddElementAllowed();
- Element node = super.addElement(qualifiedName, namespaceURI);
+ Element node = getDocumentFactory().createElement(qualifiedName,
namespaceURI);
+ checkAddElementAllowed(node);
+ super.add(node);
rootElementAdded(node);
return node;
}
public Element addElement(QName qName) {
- checkAddElementAllowed();
- Element node = super.addElement(qName);
+ Element node = getDocumentFactory().createElement(qName);
+ checkAddElementAllowed(node);
+ super.add(node);
rootElementAdded(node);
return node;
}
@@ -169,7 +172,7 @@
}
public void add(Element element) {
- checkAddElementAllowed();
+ checkAddElementAllowed(element);
super.add(element);
rootElementAdded(element);
}
@@ -203,12 +206,12 @@
}
}
- protected void checkAddElementAllowed() {
+ protected void checkAddElementAllowed(Element node) {
Element root = getRootElement();
if ( root != null ) {
throw new IllegalAddException(
this,
- root,
+ node,
"Cannot add another element to this Document as it already has "
+ " a root element of: " + root.getQualifiedName()
);
