Author: vgritsenko
Date: Wed Oct 11 20:35:06 2006
New Revision: 463125
URL: http://svn.apache.org/viewvc?view=rev&rev=463125
Log:
work in progress - adding dom 3 stuff.
preserves jdk 1.3 compatibility.
Added:
xml/xindice/trunk/java/dom3/
xml/xindice/trunk/java/dom3/org/
xml/xindice/trunk/java/dom3/org/w3c/
xml/xindice/trunk/java/dom3/org/w3c/dom/
xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java (with props)
xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java (with props)
xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java (with props)
xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java (with props)
xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
(with props)
Modified:
xml/xindice/trunk/build.properties
xml/xindice/trunk/build.xml
xml/xindice/trunk/java/src/org/apache/xindice/util/StringUtilities.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/AttrImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentTypeImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ElementImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/EntityImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NodeImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NotationImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/TextImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderFactoryImpl.java
Modified: xml/xindice/trunk/build.properties
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/build.properties?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/build.properties (original)
+++ xml/xindice/trunk/build.properties Wed Oct 11 20:35:06 2006
@@ -2,11 +2,11 @@
# Xindice build properties.
#
# NOTE: do not modify this file directly but copy the properties you need
-# to modify over to a file named 'local.build.properties' and modify that.
-# The build system will override these properties with the ones in the
+# to modify over to a file named 'local.build.properties' and modify that.
+# The build system will override these properties with the ones in the
# 'local.build.properties' file.
#
-# CVS $Id$
+# $Id$
#
@@ -87,6 +87,7 @@
root.dir=java
jar.dir=${root.dir}/lib
src.dir=${root.dir}/src
+dom.src.dir=${root.dir}/dom3
test.src.dir=${root.dir}/tests/src
scratchpad.src.dir=${root.dir}/scratchpad/src
scratchpad.jar.dir=${root.dir}/scratchpad/lib
@@ -94,6 +95,7 @@
# Destination directories
build.dir=build
src.build.dir=${build.dir}/classes
+dom.build.dir=${build.dir}/classes-dom
test.build.dir=${build.dir}/classes-tests
test.result.dir=${build.dir}/test-results
test.report.dir=${build.dir}/test-report
Modified: xml/xindice/trunk/build.xml
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/build.xml?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/build.xml (original)
+++ xml/xindice/trunk/build.xml Wed Oct 11 20:35:06 2006
@@ -94,13 +94,22 @@
<delete dir="${dist.dir}"/>
</target>
- <!--
+ <!--
- Compiles the source code
-->
- <target name="src-build" depends="init, clover.on">
+ <target name="dom-build" depends="init, clover.on">
+ <mkdir dir="${dom.build.dir}"/>
+ <javac srcdir="${dom.src.dir}" destdir="${dom.build.dir}"
debug="${compile.debug}" optimize="${compile.optimize}"
nowarn="${compile.nowarn}" deprecation="${compile.deprecation}"
verbose="${compile.verbose}">
+ <classpath>
+ <path refid="project.class.path"/>
+ </classpath>
+ </javac>
+ </target>
+ <target name="src-build" depends="dom-build">
<mkdir dir="${src.build.dir}"/>
<javac srcdir="${src.dir}" destdir="${src.build.dir}"
debug="${compile.debug}" optimize="${compile.optimize}"
nowarn="${compile.nowarn}" deprecation="${compile.deprecation}"
verbose="${compile.verbose}">
<classpath>
+ <path path="${dom.build.dir}"/>
<path refid="project.class.path"/>
</classpath>
</javac>
@@ -268,7 +277,14 @@
<!--
- Build the Xindice archives (jar and war)
-->
- <target name="jar-release" depends="src-build, test-build">
+ <target name="dom-release" depends="dom-build">
+ <jar
jarfile="${dist.dir}/${project.filename}-dom-${project.version}.jar"
basedir="${dom.build.dir}">
+ <manifest>
+ <attribute name="Built-By" value="${user.name}"/>
+ </manifest>
+ </jar>
+ </target>
+ <target name="jar-release" depends="dom-release, src-build, test-build">
<jar jarfile="${dist.dir}/${project.filename}-${project.version}.jar"
basedir="${src.build.dir}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
@@ -280,6 +296,7 @@
</target>
<target name="jar-clean">
<delete file="${dist.dir}/${project.filename}-${project.version}.jar"/>
+ <delete
file="${dist.dir}/${project.filename}-dom-${project.version}.jar"/>
</target>
<target name="war-release" depends="jar-release">
<mkdir dir="${build.dir}/war-bin"/>
@@ -288,7 +305,6 @@
<copy file="${bin.dir}/xindice.war.sh"
toFile="${build.dir}/war-bin/xindice.sh" filtering="on"/>
<copy file="${bin.dir}/lcp.bat" toFile="${build.dir}/war-bin/lcp.bat"
filtering="on"/>
<war destfile="${dist.dir}/${project.filename}-${project.version}.war"
update="false" webxml="config/web.xml">
- <classes dir="${src.build.dir}"/>
<webinf dir="${config.dir}">
<include name="system.xml"/>
</webinf>
@@ -299,6 +315,8 @@
<include name="*"/>
</webinf>
<lib refid="core.jars"/>
+ <lib
file="${dist.dir}/${project.filename}-${project.version}.jar"/>
+ <lib
file="${dist.dir}/${project.filename}-dom-${project.version}.jar"/>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<section name="org/apache/xindice">
Added: xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java?view=auto&rev=463125
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java (added)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java Wed Oct 11
20:35:06 2006
@@ -0,0 +1,11 @@
+package org.w3c.dom;
+
+/**
+ * @version $Id$
+ */
+public interface DOMConfiguration {
+ public void setParameter(String name, Object value) throws DOMException;
+ public Object getParameter(String name) throws DOMException;
+ boolean canSetParameter(String name, Object value);
+ public DOMStringList getParameterNames();
+}
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java?view=auto&rev=463125
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java (added)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java Wed Oct 11
20:35:06 2006
@@ -0,0 +1,10 @@
+package org.w3c.dom;
+
+/**
+ * @version $Id$
+ */
+public interface DOMStringList {
+ public String item(long index);
+ public long getLength();
+ public boolean contains(String str);
+}
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java?view=auto&rev=463125
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java (added)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java Wed Oct 11 20:35:06
2006
@@ -0,0 +1,15 @@
+package org.w3c.dom;
+
+/**
+ * @version $Id$
+ */
+public interface TypeInfo {
+ public static final int DERIVATION_RESTRICTION = 0x00000001;
+ public static final int DERIVATION_EXTENSION = 0x00000002;
+ public static final int DERIVATION_UNION = 0x00000004;
+ public static final int DERIVATION_LIST = 0x00000008;
+
+ public String getTypeName();
+ public String getTypeNamespace();
+ public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg,
int derivationMethod);
+}
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java?view=auto&rev=463125
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java (added)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java Wed Oct 11
20:35:06 2006
@@ -0,0 +1,16 @@
+package org.w3c.dom;
+
+/**
+ * @version $Id$
+ */
+public interface UserDataHandler {
+
+ // OperationType
+ public static final short NODE_CLONED = 1;
+ public static final short NODE_IMPORTED = 2;
+ public static final short NODE_DELETED = 3;
+ public static final short NODE_RENAMED = 4;
+ public static final short NODE_ADOPTED = 5;
+
+ public void handle(short operation, String key, Object data, Node src, Node
dst);
+}
\ No newline at end of file
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/util/StringUtilities.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/util/StringUtilities.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/util/StringUtilities.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/util/StringUtilities.java Wed
Oct 11 20:35:06 2006
@@ -216,4 +216,12 @@
}
return sb.toString();
}
+
+ public static boolean equals(String s1, String s2) {
+ if (s1 == null || s2 == null) {
+ return (s1 == null && s2 == null) || "".equals(s1) ||
"".equals(s2);
+ } else {
+ return s1.equals(s2);
+ }
+ }
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/AttrImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/AttrImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/AttrImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/AttrImpl.java Wed Oct
11 20:35:06 2006
@@ -19,20 +19,23 @@
package org.apache.xindice.xml.dom;
import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+import org.w3c.dom.TypeInfo;
/**
* AttrImpl
*
* @version CVS $Revision$, $Date$
*/
-public final class AttrImpl extends ContainerNodeImpl implements Attr {
+public final class AttrImpl extends ContainerNodeImpl
+ implements Attr {
private boolean specified = true;
private short symbolID = -1;
+
public AttrImpl() {
}
@@ -100,9 +103,7 @@
}
protected void checkLoaded() {
- if (loaded) {
- return;
- } else {
+ if (!loaded) {
loaded = true;
}
}
@@ -140,7 +141,8 @@
/**
* On retrieval, the value of the attribute is returned as a string.
* Character and general entity references are replaced with their values.
- * <br>On setting, this creates a <code>Text</code> node with the unparsed
+ * <br>
+ * On setting, this creates a <code>Text</code> node with the unparsed
* contents of the string.
*/
public String getValue() {
@@ -153,15 +155,36 @@
for (int i = 0; i < size; i++) {
sb.append(childNodes.item(i).getNodeValue());
}
-
+
return sb.toString();
}
+ /**
+ * @since DOM Level 2
+ */
public Element getOwnerElement() {
if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
return (Element) parentNode;
} else {
return null;
}
+ }
+
+ //
+ // DOM Level 3 Implementation
+ //
+
+ /**
+ * @since DOM Level 3
+ */
+ public TypeInfo getSchemaTypeInfo() {
+ return null;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public boolean isId() {
+ return false;
}
}
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java
Wed Oct 11 20:35:06 2006
@@ -41,7 +41,7 @@
* ContainerNodeImpl performs most of the child-rearing behavior of the
* Element and Document implementations.
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public abstract class ContainerNodeImpl extends NodeImpl {
@@ -443,13 +443,14 @@
};
NodeIterator iter = ((DocumentTraversal)
getOwnerDocument()).createNodeIterator(this, NodeFilter.SHOW_ELEMENT, filter,
false);
- Node node = null;
+ Node node;
do {
node = iter.nextNode();
if (node != null) {
list.add(node);
}
} while (node != null);
+
return list;
}
@@ -468,17 +469,74 @@
};
NodeIterator iter = ((DocumentTraversal)
getOwnerDocument()).createNodeIterator(this, NodeFilter.SHOW_ELEMENT, filter,
false);
- Node node = null;
+ Node node;
do {
node = iter.nextNode();
if (node != null) {
list.add(node);
}
} while (node != null);
+
return list;
}
public final Element getElementById(String elementId) {
return null;
+ }
+
+ //
+ // DOM Level 3 Implementation
+ //
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getTextContent() {
+ StringBuffer val = new StringBuffer();
+
+ NodeList children = getChildNodes();
+ if (children == null || children.getLength() == 0) {
+ return "";
+ }
+
+ for (int i = 0; i < children.getLength(); i++ ) {
+ val.append(((NodeImpl) children.item(i)).getTextContent());
+ }
+ return val.toString();
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public boolean isEqualNode(Node other) {
+ if (!super.isEqualNode(other)) {
+ return false;
+ }
+
+ // The childNodes NodeLists have to be equal
+ other.normalize();
+ normalize();
+
+ if (!hasChildNodes() && !other.hasChildNodes()) {
+ return true;
+ }
+
+ if (!hasChildNodes() || !other.hasChildNodes()) {
+ return false;
+ }
+
+ NodeList thisChildren = getChildNodes();
+ NodeList otherChildren = other.getChildNodes();
+ if (thisChildren.getLength() != otherChildren.getLength()) {
+ return false;
+ }
+
+ for (int i = 0; i < thisChildren.getLength(); i++) {
+ if (!((NodeImpl)
thisChildren.item(i)).isEqualNode(otherChildren.item(i))) {
+ return false;
+ }
+ }
+
+ return true;
}
}
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMImplementationImpl.java
Wed Oct 11 20:35:06 2006
@@ -27,33 +27,35 @@
/**
* DOMImplementationImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public final class DOMImplementationImpl implements DOMImplementation {
+
private static final String[][] FEATURES = {
- {"XML", "1.0"},
- {"XML", "2.0"},
- {"Traversal", "2.0"},
- {"Xindice-DB", "1.0"}, // DBNode and DBDocument
+ {"XML", "1.0"},
+ {"XML", "2.0"},
+ {"Traversal", "2.0"},
+ {"Xindice-DB", "1.0"}, // DBNode and DBDocument
{"Xindice-Comp", "1.0"} // CompressedNode and CompressedDocument
};
- private static final DOMImplementation domImpl = new
DOMImplementationImpl();
+ private static final DOMImplementation IMPL = new DOMImplementationImpl();
+
private DOMImplementationImpl() {
}
public static DOMImplementation getInstance() {
- return domImpl;
+ return IMPL;
}
- public static boolean HasFeature(String feature, String version) {
+ static boolean HasFeature(String feature, String version) {
for (int i = 0; i < FEATURES.length; i++) {
- if (FEATURES[i][0].equals(feature)
- && FEATURES[i][1].equals(version)) {
+ if (FEATURES[i][0].equals(feature) &&
FEATURES[i][1].equals(version)) {
return true;
}
}
+
return false;
}
@@ -141,6 +143,17 @@
doc.setDoctype(doctype);
}
return doc;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public Object getFeature(String feature, String version) {
+ if (hasFeature(feature, version)) {
+ return this;
+ }
+
+ return null;
}
}
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentImpl.java Wed
Oct 11 20:35:06 2006
@@ -28,6 +28,7 @@
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
+import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -52,7 +53,7 @@
/**
* DocumentImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public final class DocumentImpl extends ContainerNodeImpl
implements CompressedDocument, DBDocument,
DocumentTraversal {
@@ -61,8 +62,8 @@
private DocumentType docType;
private String version;
- private String actualEncoding;
- private String encoding;
+ private String xmlEncoding;
+ private String inputEncoding;
private boolean standalone;
private boolean strictErrorChecking;
private SymbolTable symbols;
@@ -460,8 +461,13 @@
return new TreeWalkerImpl(root, whatToShow, filter,
entityReferenceExpansion);
}
- // DOM Level 3 Stuff
+ //
+ // DOM Level 3 Implementation
+ //
+ /**
+ * @since DOM Level 3
+ */
public Node adoptNode(Node src) {
// If we're a Xindice DOM Node and share the same symbol table
// or the adopted node has no symbol table, then we're golden
@@ -477,58 +483,122 @@
return importNode(src, true);
}
- public String getActualEncoding() {
+ /**
+ * @since DOM Level 3
+ */
+ public boolean getStrictErrorChecking() {
checkLoaded();
- return actualEncoding;
+ return strictErrorChecking;
}
- public void setActualEncoding(String actualEncoding) {
+ /**
+ * @since DOM Level 3
+ */
+ public void setStrictErrorChecking(boolean strictErrorChecking) {
checkReadOnly();
checkLoaded();
- this.actualEncoding = actualEncoding;
+ this.strictErrorChecking = strictErrorChecking;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getDocumentURI() {
+ return null;
}
- public String getEncoding() {
+ /**
+ * @since DOM Level 3
+ */
+ public void setDocumentURI(String documentURI) {
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getInputEncoding() {
checkLoaded();
- return encoding;
+ return inputEncoding;
}
- public void setEncoding(String encoding) {
+ public void setInputEncoding(String inputEncoding) {
checkReadOnly();
checkLoaded();
- this.encoding = encoding;
+ this.inputEncoding = inputEncoding;
}
- public String getVersion() {
+ /**
+ * @since DOM Level 3
+ */
+ public String getXmlEncoding() {
checkLoaded();
- return version;
+ return xmlEncoding;
}
- public void setVersion(String version) {
+ public void setXmlEncoding(String xmlEncoding) {
checkReadOnly();
checkLoaded();
- this.version = version;
+ this.xmlEncoding = xmlEncoding;
}
- public boolean getStandalone() {
+ /**
+ * @since DOM Level 3
+ */
+ public boolean getXmlStandalone() {
checkLoaded();
return standalone;
}
- public void setStandalone(boolean standalone) {
+ /**
+ * @since DOM Level 3
+ */
+ public void setXmlStandalone(boolean standalone) throws DOMException {
checkReadOnly();
checkLoaded();
this.standalone = standalone;
}
- public boolean getStrictErrorChecking() {
+ /**
+ * @since DOM Level 3
+ */
+ public String getXmlVersion() {
checkLoaded();
- return strictErrorChecking;
+ return version;
}
- public void setStrictErrorChecking(boolean strictErrorChecking) {
+ /**
+ * @since DOM Level 3
+ */
+ public void setXmlVersion(String version) throws DOMException {
checkReadOnly();
checkLoaded();
- this.strictErrorChecking = strictErrorChecking;
+ this.version = version;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public DOMConfiguration getDomConfig() {
+ return null;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public void normalizeDocument() {
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public Node renameNode(Node n, String namespaceURI, String qualifiedName)
throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is
not supported");
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getTextContent() {
+ return "";
}
}
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentTypeImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentTypeImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentTypeImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DocumentTypeImpl.java
Wed Oct 11 20:35:06 2006
@@ -18,6 +18,8 @@
package org.apache.xindice.xml.dom;
+import org.apache.xindice.util.StringUtilities;
+
import org.w3c.dom.DocumentType;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -25,9 +27,10 @@
/**
* DocumentTypeImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
-public final class DocumentTypeImpl extends NodeImpl implements DocumentType {
+public final class DocumentTypeImpl extends NodeImpl
+ implements DocumentType {
public DocumentTypeImpl() {
super(null, true);
@@ -97,5 +100,97 @@
public String getInternalSubset() {
return null;
}
-}
+ //
+ // DOM Level 3 Implementation
+ //
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getTextContent() {
+ return "";
+ }
+
+ /**
+ * Tests whether two nodes are equal.
+ * This method tests for equality of nodes, not sameness (i.e., whether
+ * the two nodes are references to the same object) which can be tested
with
+ * <code>Node.isSameNode()</code>. All nodes that are the same will also be
+ * equal, though the reverse may not be true.
+ * <br>
+ * Two nodes are equal if and only if the following conditions are
satisfied:
+ * <ul><li>The two nodes are of the same type.</li>
+ * <li>The following string attributes are equal: nodeName, localName,
+ * namespaceURI, prefix, nodeValue. This is: they are both null, or they
have
+ * the same length and are character for character identical.</li>
+ * <li>The attributes <code>NamedNodeMaps</code> are equal. This is: they
are both null,
+ * or they have the same length and for each node that exists in one map
there
+ * is a node that exists in the other map and is equal, although not
+ * necessarily at the same index.</li>
+ * <li>The childNodes NodeLists are equal. This is: they are both null, or
they
+ * have the same length and contain equal nodes at the same index. Note
that
+ * normalization can affect equality; to avoid this, nodes should be
normalized
+ * before being compared.</li></ul>
+ * <br>
+ * For two DocumentType nodes to be equal, the following conditions must
also
+ * be satisfied:
+ * <ul><li>The following string attributes are equal: publicId, systemId,
+ * internalSubset.</li>
+ * <li>The entities <code>NamedNodeMaps</code> are equal.</li>
+ * <li>The notations <code>NamedNodeMaps</code> are equal.</li></ul>
+ * <br>
+ * On the other hand, the following do not affect equality: the
ownerDocument,
+ * baseURI, and parentNode attributes, the specified attribute for Attr
nodes,
+ * the schemaTypeInfo attribute for Attr and Element nodes,
+ * the Text.isElementContentWhitespace attribute for Text nodes, as well
as any
+ * user data or event listeners registered on the nodes.
+ * @param other Node to test againts
+ * @return true if nodes are equal, false otherwise
+ * @since DOM Level 3
+ */
+ public boolean isEqualNode(Node other) {
+ if (!super.isEqualNode(other)) {
+ return false;
+ }
+
+ DocumentType otherDocType = (DocumentType) other;
+ if (!(StringUtilities.equals(this.getPublicId(),
otherDocType.getPublicId()) &&
+ StringUtilities.equals(this.getSystemId(),
otherDocType.getSystemId()) &&
+ StringUtilities.equals(this.getInternalSubset(),
otherDocType.getInternalSubset()))) {
+ return false;
+ }
+
+ NamedNodeMap ent = getEntities();
+ NamedNodeMap otherEnt = otherDocType.getEntities();
+ if (!equalNodeMaps(ent, otherEnt)) {
+ return false;
+ }
+
+ NamedNodeMap not = getNotations();
+ NamedNodeMap otherNot = otherDocType.getNotations();
+
+ return equalNodeMaps(not, otherNot);
+ }
+
+ private boolean equalNodeMaps(NamedNodeMap map1, NamedNodeMap map2) {
+ if (map1 == null && map2 == null) {
+ return true;
+ }
+ if (map1 == null || map2 == null) {
+ return false;
+ }
+
+ if (map1.getLength() != map2.getLength()) {
+ return false;
+ }
+
+ for (int i = 0; i < map1.getLength(); i++) {
+ if (!((NodeImpl) map1.item(i)).isEqualNode(map2.item(i))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ElementImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ElementImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ElementImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/ElementImpl.java Wed
Oct 11 20:35:06 2006
@@ -25,12 +25,12 @@
import org.apache.xindice.xml.NodeSource;
import org.apache.xindice.xml.SymbolTable;
import org.apache.xindice.xml.XMLCompressedInput;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.TypeInfo;
import java.io.IOException;
import java.util.HashSet;
@@ -38,7 +38,7 @@
/**
* ElementImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public final class ElementImpl extends ContainerNodeImpl implements Element {
@@ -51,7 +51,9 @@
private NamedNodeMapImpl attributes = new NamedNodeMapImpl(this);
private short symbolID = -1;
- public ElementImpl() {}
+
+ public ElementImpl() {
+ }
public ElementImpl(NodeImpl parentNode, byte[] data, int pos, int len) {
super(parentNode, data, pos, len);
@@ -119,7 +121,7 @@
}
/**
- * Add "src" and "col" attributes in [EMAIL PROTECTED]
NodeSource#SOURCE_NS} namespace.
+ * Add "src" and "col" attributes in [EMAIL PROTECTED]
NodeSource#SOURCE_NS} namespace.
*/
public void expandSource() {
NodeSource src = getSource();
@@ -460,7 +462,72 @@
return setAttributeNode(newAttr);
}
+ /**
+ * @since DOM Level 2
+ */
public boolean hasAttributeNS(String namespaceURI, String localName) {
return attributes.getNamedItemNS(namespaceURI, localName) != null;
+ }
+
+ //
+ // DOM Level 3 Implementation
+ //
+
+ /**
+ * @since DOM Level 3
+ */
+ public TypeInfo getSchemaTypeInfo() {
+ return null;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public void setIdAttribute(String name, boolean isId) throws DOMException {
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public void setIdAttributeNS(String namespaceURI, String localName,
boolean isId) throws DOMException {
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public void setIdAttributeNode(Attr idAttr, boolean isId) throws
DOMException {
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public boolean isEqualNode(Node other) {
+ if (!super.isEqualNode(other)) {
+ return false;
+ }
+
+ // Attributes of the nodes have to be the same, but can have different
order
+ if (!hasAttributes() && !other.hasAttributes()) {
+ return true;
+ }
+ if (!hasAttributes() || !other.hasAttributes()) {
+ return false;
+ }
+
+ NamedNodeMap attrMap = getAttributes();
+ NamedNodeMap otherAttrMap = other.getAttributes();
+ if (attrMap.getLength() != otherAttrMap.getLength()) {
+ return false;
+ }
+
+ for (int i = 0; i < attrMap.getLength(); i++) {
+ String name = attrMap.item(i).getNodeName();
+ Node attr = otherAttrMap.getNamedItem(name);
+ if (attr == null ||
!attrMap.item(i).getNodeValue().equals(attr.getNodeValue())) {
+ return false;
+ }
+ }
+
+ return true;
}
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/EntityImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/EntityImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/EntityImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/EntityImpl.java Wed
Oct 11 20:35:06 2006
@@ -24,11 +24,14 @@
/**
* EntityImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public final class EntityImpl extends NodeImpl implements Entity {
- private String encoding = null;
- private String version = null;
+
+ private String encoding;
+ private String inputEncoding;
+ private String version;
+
public EntityImpl() {
}
@@ -69,25 +72,36 @@
return null;
}
- // DOM Level 3 Stuff
+ public String getInputEncoding() {
+ checkLoaded();
+ return inputEncoding;
+ }
- public String getEncoding() {
+ public String getXmlEncoding() {
checkLoaded();
return encoding;
}
+ // DOM Level 3 Stuff
+ public String getXmlVersion() {
+ checkLoaded();
+ return version;
+ }
+
+ // Setters
public void setEncoding(String encoding) {
checkReadOnly();
checkLoaded();
this.encoding = encoding;
}
- public String getVersion() {
+ public void setInputEncoding(String inputEncoding) {
+ checkReadOnly();
checkLoaded();
- return version;
+ this.inputEncoding = inputEncoding;
}
- public void setVersion(String version) {
+ public void setXmlVersion(String version) {
checkReadOnly();
checkLoaded();
this.version = version;
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NodeImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NodeImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NodeImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NodeImpl.java Wed Oct
11 20:35:06 2006
@@ -20,6 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xindice.util.StringUtilities;
import org.apache.xindice.xml.NodeSource;
import org.apache.xindice.xml.TextWriter;
@@ -30,13 +31,14 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.UserDataHandler;
import java.util.HashMap;
/**
* NodeImpl implements the foundation of the Xindice compressed DOM.
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public abstract class NodeImpl implements CompressedNode, DBNode {
@@ -102,8 +104,10 @@
// DOM Level 3 Stuff
protected HashMap userData;
+ protected HashMap handlers;
protected Object key;
+
public NodeImpl() {
}
@@ -130,9 +134,7 @@
}
protected void checkLoaded() {
- if (loaded) {
- return;
- } else {
+ if (!loaded) {
loaded = true;
}
}
@@ -783,15 +785,16 @@
: null;
}
- // Some DOM Level 3 Core Methods
+ //
+ // DOM Level 3 Implementation
+ //
/**
- * Returns whether this node is the same node as the given one. Do we
- * really want to make this different from equals?Yes, change name from
- * isIdentical to isSameNode. (Telcon 4 Jul 2000).
+ * Returns whether this node is the same node as the given one.
* @param other The node to test against.
* @return Returns <code>true</code> if the nodes are the same,
* <code>false</code> otherwise.
+ * @since DOM Level 3
*/
public final boolean isSameNode(Node other) {
return this == other;
@@ -799,12 +802,13 @@
/**
* Look up the prefix associated to the given namespace URI, starting from
- * this node.
+ * this node. The default namespace declarations are ignored by this
method.
* @param namespaceURI The namespace URI to look for.
* @return Returns the associated namespace prefix or <code>null</code>
* if none is found.
+ * @since DOM Level 3
*/
- public final String lookupNamespacePrefix(String namespaceURI) {
+ public final String lookupPrefix(String namespaceURI) {
if (getNodeType() == Node.ELEMENT_NODE) {
NamedNodeMap map = getAttributes();
int size = map.getLength();
@@ -814,11 +818,10 @@
if (name.startsWith(XMLNS_PREFIX + ':')
&& attr.getValue().equals(namespaceURI)) {
return name.substring(XMLNS_PREFIX.length() + 1);
- }
+ }
}
}
- return parentNode != null ?
parentNode.lookupNamespacePrefix(namespaceURI)
- : null;
+ return parentNode != null ? parentNode.lookupPrefix(namespaceURI) :
null;
}
/**
@@ -829,6 +832,7 @@
* @param prefix The prefix to look for.
* @return Returns the associated namespace URI or <code>null</code> if
* none is found.
+ * @since DOM Level 3
*/
public final String lookupNamespaceURI(String prefix) {
String uri = null;
@@ -839,29 +843,7 @@
return uri;
}
- return parentNode != null ? parentNode.lookupNamespaceURI(prefix)
- : null;
- }
-
- /**
- * This method walks down the tree, starting from this node, and adds
- * namespace declarations where needed so that every namespace being
- * used is properly declared. It also changes or assign prefixes when
- * needed. This effectively makes this node subtree is "namespace
- * wellformed".
- * <br>What the generated prefixes are and/or how prefixes are changed to
- * achieve this is implementation dependent.Any other name?How specific
- * should this be? Should we not even specify that this should be done
- * by walking down the tree?What does this do on attribute nodes?Doesn't
- * do anything (F2F 1 Aug 2000).How does it work with entity reference
- * subtree which may be broken?This doesn't affect entity references
- * which are not visited in this operation (F2F 1 Aug 2000).Should this
- * be really be on Node?Yes, but this only works on Document, Element,
- * and DocumentFragment. On other types it is a no-op. (F2F 1 Aug 2000).
- * What happens with read-only nodes?What/how errors should be reported?
- * Are there any?
- */
- public void normalizeNS() throws DOMException {
+ return parentNode != null ? parentNode.lookupNamespaceURI(prefix) :
null;
}
/**
@@ -876,13 +858,27 @@
* @param key The key to associate this data to.
* @return The object previously associated to this node and the given
* key or <code>null</code>.
+ * @since DOM Level 3
*/
- public final synchronized Object setUserData(Object data, String key) {
+ public final synchronized Object setUserData(String key, Object data,
UserDataHandler handler) {
if (userData == null) {
userData = new HashMap();
}
+ if (handlers == null) {
+ handlers = new HashMap();
+ }
+
Object oldData = userData.get(key);
- userData.put(key, data);
+ if (data != null) {
+ userData.put(key, data);
+ if (handler != null) {
+ handlers.put(key, handler);
+ }
+ } else {
+ userData.remove(key);
+ handlers.remove(key);
+ }
+
return oldData;
}
@@ -892,6 +888,7 @@
* @param key The key to look for.
* @return The object associated to this node and the given key or
* <code>null</code>.
+ * @since DOM Level 3
*/
public final synchronized Object getUserData(String key) {
if (userData == null) {
@@ -901,18 +898,181 @@
}
/**
+ * @since DOM Level 3
+ */
+ public String getBaseURI() {
+ return null;
+ }
+
+ /**
+ * This method returns the text content of this node and its descendants.
+ * No serialization is performed, the returned string does not contain any
+ * markup. No whitespace normalization is performed and the returned string
+ * does not contain the white spaces in element content (see the attribute
+ * Text.isElementContentWhitespace).
+ * <br>
+ * The string returned is made of the text content of this node depending
on
+ * its type, as defined below:
+ * <table border=1><tr><th>Node type</th><th>Content</th></tr>
+ * <tr><td>ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE,
ENTITY_REFERENCE_NODE,
+ * DOCUMENT_FRAGMENT_NODE</td>
+ * <td>concatenation of the textContent attribute value of every child
node,
+ * excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is
the
+ * empty string if the node has no children.</td></tr>
+ * <tr><td>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE,
+ * PROCESSING_INSTRUCTION_NODE</td><td>nodeValue</td></tr>
+ * <tr><td>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
+ * <td>null</td></tr></table>
+ * @return the text content of this node and its descendants
+ * @since DOM Level 3
+ */
+ public String getTextContent() {
+ return getNodeValue();
+ }
+
+ /**
+ * This method changes the text content of this node. When it is defined
to be
+ * null, setting it has no effect. On setting, any possible children this
node
+ * may have are removed and, if it the new string is not empty or null,
replaced
+ * by a single Text node containing the string this attribute is set to.
+ * No parsing is performed, the input string is taken as pure textual
content.
+ * @param textContent new text content
+ * @throws DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the
node is readonly
+ */
+ public void setTextContent(String textContent) throws DOMException {
+ checkReadOnly();
+ checkLoaded();
+ if (textContent == null || "".equals(textContent)) return;
+
+ // remove all child nodes, if any
+ if (hasChildNodes()) {
+ int num = getChildNodes().getLength();
+ for (int i = 0; i < num; i++) {
+ removeChild(getChildNodes().item(0));
+ }
+ }
+
+ appendChild(new TextImpl(this, textContent));
+ }
+
+ /**
+ * Tests whether two nodes are equal.
+ * This method tests for equality of nodes, not sameness (i.e., whether
+ * the two nodes are references to the same object) which can be tested
with
+ * <code>Node.isSameNode()</code>. All nodes that are the same will also be
+ * equal, though the reverse may not be true.
+ * <br>
+ * Two nodes are equal if and only if the following conditions are
satisfied:
+ * <ul><li>The two nodes are of the same type.</li>
+ * <li>The following string attributes are equal: nodeName, localName,
+ * namespaceURI, prefix, nodeValue. This is: they are both null, or they
have
+ * the same length and are character for character identical.</li>
+ * <li>The attributes <code>NamedNodeMaps</code> are equal. This is: they
are both null,
+ * or they have the same length and for each node that exists in one map
there
+ * is a node that exists in the other map and is equal, although not
+ * necessarily at the same index.</li>
+ * <li>The childNodes NodeLists are equal. This is: they are both null, or
they
+ * have the same length and contain equal nodes at the same index. Note
that
+ * normalization can affect equality; to avoid this, nodes should be
normalized
+ * before being compared.</li></ul>
+ * <br>
+ * For two DocumentType nodes to be equal, the following conditions must
also
+ * be satisfied:
+ * <ul><li>The following string attributes are equal: publicId, systemId,
+ * internalSubset.</li>
+ * <li>The entities <code>NamedNodeMaps</code> are equal.</li>
+ * <li>The notations <code>NamedNodeMaps</code> are equal.</li></ul>
+ * <br>
+ * On the other hand, the following do not affect equality: the
ownerDocument,
+ * baseURI, and parentNode attributes, the specified attribute for Attr
nodes,
+ * the schemaTypeInfo attribute for Attr and Element nodes,
+ * the Text.isElementContentWhitespace attribute for Text nodes, as well
as any
+ * user data or event listeners registered on the nodes.
+ * @param other Node to test againts
+ * @return true if nodes are equal, false otherwise
+ * @since DOM Level 3
+ */
+ public boolean isEqualNode(Node other) {
+ if (this.isSameNode(other)) return true;
+
+ // Node has to be of the same type
+ if (other == null || other.getNodeType() != this.getNodeType()) {
+ return false;
+ }
+
+ // The following string attributes have to be equal: nodeName,
localName,
+ // namespaceURI, prefix, nodeValue
+ return StringUtilities.equals(getNodeName(), other.getNodeName()) &&
+ StringUtilities.equals(getLocalName(), other.getLocalName()) &&
+ StringUtilities.equals(getNamespaceURI(),
other.getNamespaceURI()) &&
+ StringUtilities.equals(getPrefix(), other.getPrefix()) &&
+ StringUtilities.equals(getNodeValue(), other.getNodeValue());
+
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public Object getFeature(String feature, String version) {
+ if (DOMImplementationImpl.HasFeature(feature, version)) {
+ return this;
+ }
+
+ return null;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public boolean isDefaultNamespace(String namespaceURI) {
+ return namespaceURI.equals(lookupDefaultNamespaceURI());
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public short compareDocumentPosition(Node other) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is
not supported");
+ }
+
+ //
+ // Implementation Methods
+ //
+
+ /**
+ * This method walks down the tree, starting from this node, and adds
+ * namespace declarations where needed so that every namespace being
+ * used is properly declared. It also changes or assign prefixes when
+ * needed. This effectively makes this node subtree is "namespace
+ * wellformed".
+ * <br>What the generated prefixes are and/or how prefixes are changed to
+ * achieve this is implementation dependent.Any other name?How specific
+ * should this be? Should we not even specify that this should be done
+ * by walking down the tree?What does this do on attribute nodes?Doesn't
+ * do anything (F2F 1 Aug 2000).How does it work with entity reference
+ * subtree which may be broken?This doesn't affect entity references
+ * which are not visited in this operation (F2F 1 Aug 2000).Should this
+ * be really be on Node?Yes, but this only works on Document, Element,
+ * and DocumentFragment. On other types it is a no-op. (F2F 1 Aug 2000).
+ * What happens with read-only nodes?What/how errors should be reported?
+ * Are there any?
+ public void normalizeNS() throws DOMException {
+ }
+ */
+
+ /**
* This attribute returns a unique key identifying this node.
*
* What type should this really be? In what space is this key
* unique (Document, DOMImplementation)? What is the lifetime of
* the uniqueness of this key (Node, Document, ...)?
- */
public final synchronized Object getKey() {
if (key == null) {
key = new Object();
}
return key;
}
+ */
/**
* Converts this node into its textual representation.
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NotationImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NotationImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NotationImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/NotationImpl.java Wed
Oct 11 20:35:06 2006
@@ -24,7 +24,7 @@
/**
* NotationImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public final class NotationImpl extends NodeImpl implements Notation {
@@ -57,6 +57,13 @@
*/
public String getSystemId() {
return null;
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getTextContent() {
+ return "";
}
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/TextImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/TextImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/TextImpl.java
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/TextImpl.java Wed Oct
11 20:35:06 2006
@@ -25,7 +25,7 @@
/**
* TextImpl
*
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public class TextImpl extends CharacterDataImpl implements Text {
@@ -81,5 +81,25 @@
throw EX_INDEX_SIZE;
}
}
-}
+ /**
+ * @since DOM Level 3
+ */
+ public boolean isElementContentWhitespace() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is
not supported");
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public String getWholeText() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is
not supported");
+ }
+
+ /**
+ * @since DOM Level 3
+ */
+ public Text replaceWholeText(String content) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is
not supported");
+ }
+}
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderFactoryImpl.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderFactoryImpl.java?view=diff&rev=463125&r1=463124&r2=463125
==============================================================================
---
xml/xindice/trunk/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderFactoryImpl.java
(original)
+++
xml/xindice/trunk/java/src/org/apache/xindice/xml/jaxp/DocumentBuilderFactoryImpl.java
Wed Oct 11 20:35:06 2006
@@ -40,6 +40,14 @@
return attrs.get(name);
}
+ public void setFeature(String name, boolean value) throws
ParserConfigurationException {
+
+ }
+
+ public boolean getFeature(String name) throws ParserConfigurationException
{
+ return false;
+ }
+
public DocumentBuilder newDocumentBuilder() throws
ParserConfigurationException {
return new DocumentBuilderImpl();
}
Added: xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
URL:
http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java?view=auto&rev=463125
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
(added)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
Wed Oct 11 20:35:06 2006
@@ -0,0 +1,66 @@
+package org.apache.xindice.xml.dom;
+
+import junit.framework.TestCase;
+import org.w3c.dom.Node;
+
+/**
+ * Tests NodeImpl class
+ *
+ */
+public class NodeTest extends TestCase {
+
+ private static final String XML =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
+ "<a xmlns:name=\"http://apache.org\">" +
+ "<b/>" +
+ "<name:c attr1=\"a\" attr2=\"b\">" +
+ "<d attr3=\"c\" attr4=\"d\" />" +
+ "</name:c>" +
+ "<c attr1=\"a\" attr2=\"b\">" +
+ "<d attr3=\"c\" attr4=\"d\" />" +
+ "</c>" +
+ "<name:c attr2=\"b\" attr1=\"a\">" +
+ "<d attr3=\"c\" attr4=\"d\" />" +
+ "</name:c>" +
+ "<name:c attr1=\"a\" attr2=\"b\">" +
+ "<d attr3=\"c\" attr5=\"d\" />" +
+ "</name:c>" +
+ "<d>Parent text<e>Child text</e></d>" +
+ "</a>";
+
+ private Node dom;
+
+ public void setUp() throws Exception {
+ dom = DOMParser.toDocument(NodeTest.XML).getDocumentElement();
+ }
+
+ public void testNodeEquality() throws Exception {
+ Node node1 = dom.getFirstChild().getNextSibling();
+ assertEquals(true, ((NodeImpl) node1).isEqualNode(node1));
+ assertEquals(true, ((NodeImpl) node1).isSameNode(node1));
+
+ Node node2 = node1.getNextSibling();
+ // wrong node name
+ assertEquals(false, ((NodeImpl) node1).isEqualNode(node2));
+ Node node3 = node2.getNextSibling();
+ assertEquals(true, ((NodeImpl) node1).isEqualNode(node3));
+ Node node4 = node3.getNextSibling();
+ // wrong child attribute name
+ assertEquals(false, ((NodeImpl) node1).isEqualNode(node4));
+ }
+
+ public void testTextContent() throws Exception {
+ Node node =
dom.getFirstChild().getNextSibling().getAttributes().item(1);
+ assertEquals("b", ((NodeImpl) node).getTextContent());
+
+ Node node1 = dom.getLastChild();
+ assertEquals("Parent textChild text", ((NodeImpl)
node1).getTextContent());
+
+ ((NodeImpl) node1).setTextContent("");
+ assertEquals("Parent textChild text", ((NodeImpl)
node1).getTextContent());
+
+ ((NodeImpl) node1).setTextContent("New text");
+ assertEquals("New text", ((NodeImpl) node1).getTextContent());
+ assertEquals(1, node1.getChildNodes().getLength());
+ }
+}
Propchange:
xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
------------------------------------------------------------------------------
svn:keywords = Id