You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2004/02/10 12:37:17 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/rc RCML.java
andreas 2004/02/10 03:37:17
Modified: src/java/org/apache/lenya/cms/rc RCML.java
Log:
replaced DOM4j + deprecated lenya.xml stuff by JAXP
Revision Changes Path
1.22 +19 -27 cocoon-lenya/src/java/org/apache/lenya/cms/rc/RCML.java
Index: RCML.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/rc/RCML.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- RCML.java 2 Feb 2004 02:50:36 -0000 1.21
+++ RCML.java 10 Feb 2004 11:37:17 -0000 1.22
@@ -58,9 +58,11 @@
import java.io.IOException;
import java.util.Vector;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.lenya.util.XPSFileOutputStream;
-import org.apache.lenya.xml.DOMParserFactory;
-import org.apache.lenya.xml.DOMWriter;
+import org.apache.lenya.xml.DocumentHelper;
+import org.apache.lenya.xml.NamespaceHelper;
import org.apache.lenya.xml.XPointerFactory;
import org.apache.log4j.Category;
import org.w3c.dom.Document;
@@ -137,20 +139,15 @@
write();
} else {
- DOMParserFactory dpf = new DOMParserFactory();
- document = dpf.getDocument(rcmlFile.getAbsolutePath());
+ document = DocumentHelper.readDocument(rcmlFile);
}
}
/**
* initialise the RCML-document. Delete all entries
*/
- public void initDocument() {
- DOMParserFactory dpf = new DOMParserFactory();
- document = dpf.getDocument();
-
- Element root = dpf.newElementNode(document, "XPSRevisionControl");
- document.appendChild(root);
+ public void initDocument() throws ParserConfigurationException {
+ document = DocumentHelper.createDocument(null, "XPSRevisionControl", null);
}
/**
@@ -172,10 +169,7 @@
* @throws Exception if an error occurs
*/
public void write() throws IOException, Exception {
- XPSFileOutputStream xpsfos = new XPSFileOutputStream(rcmlFile.getAbsolutePath());
- new DOMWriter(xpsfos).print(this.document);
- xpsfos.close();
-
+ DocumentHelper.writeDocument(document, rcmlFile);
clearDirty();
}
@@ -192,20 +186,18 @@
*/
public void checkOutIn(short type, String identity, long time, boolean backup)
throws IOException, Exception {
- DOMParserFactory dpf = new DOMParserFactory();
-
- Element identityElement = dpf.newElementNode(document, "Identity");
- identityElement.appendChild(dpf.newTextNode(document, identity));
-
- Element timeElement = dpf.newElementNode(document, "Time");
- timeElement.appendChild(dpf.newTextNode(document, "" + time));
+
+ NamespaceHelper helper = new NamespaceHelper(null, "", document);
+
+ Element identityElement = helper.createElement("Identity", identity);
+ Element timeElement = helper.createElement("Time", "" + time);
Element checkOutElement = null;
if (type == co) {
- checkOutElement = dpf.newElementNode(document, "CheckOut");
+ checkOutElement = helper.createElement("CheckOut");
} else if (type == ci) {
- checkOutElement = dpf.newElementNode(document, "CheckIn");
+ checkOutElement = helper.createElement("CheckIn");
} else {
log.error("ERROR: " + this.getClass().getName() + ".checkOutIn(): No such type");
@@ -216,12 +208,11 @@
checkOutElement.appendChild(timeElement);
if (backup) {
- Element backupElement = dpf.newElementNode(document, "Backup");
+ Element backupElement = helper.createElement("Backup");
checkOutElement.appendChild(backupElement);
}
Element root = document.getDocumentElement();
- root.insertBefore(dpf.newTextNode(document, "\n"), root.getFirstChild());
root.insertBefore(checkOutElement, root.getFirstChild());
setDirty();
@@ -386,7 +377,8 @@
* @throws Exception if an error occurs
*/
public org.w3c.dom.Document getDOMDocumentClone() throws Exception {
- Document documentClone = new DOMParserFactory().getDocument();
+ Document documentClone = DocumentHelper.createDocument(null, "dummy", null);
+ documentClone.removeChild(documentClone.getDocumentElement());
documentClone.appendChild(documentClone.importNode(document.getDocumentElement(), true));
return documentClone;
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org