Author: vgritsenko
Date: Tue Oct 24 06:09:46 2006
New Revision: 467324
URL: http://svn.apache.org/viewvc?view=rev&rev=467324
Log:
<action dev="VG" type="update">
Implement DOM3 API compatibility.
</action>
Added:
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java (with props)
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java (with props)
xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java (with props)
Modified:
xml/xindice/trunk/build.xml
xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java
xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java
xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java
xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java
xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/AttrImpl.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/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/tests/src/org/apache/xindice/core/CollectionTest.java
xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java (contents, props changed)
xml/xindice/trunk/status.xml
Modified: xml/xindice/trunk/build.xml
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/build.xml?view=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/build.xml (original)
+++ xml/xindice/trunk/build.xml Tue Oct 24 06:09:46 2006
@@ -68,6 +68,7 @@
-->
<path id="project.class.path">
<!-- compiled classes directory -->
+ <pathelement location="${dom.build.dir}"/>
<pathelement location="${src.build.dir}"/>
<fileset refid="core.jars"/>
<fileset refid="servlet.jars"/>
Modified: 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=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java (original)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/DOMConfiguration.java Tue Oct 24 06:09:46 2006
@@ -1,11 +1,436 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
package org.w3c.dom;
/**
- * @version $Id$
+ * The DOMConfiguration interface represents the configuration of a document
+ * and maintains a table of recognized parameters. Using the configuration, it
+ * is possible to change Document.normalizeDocument() behavior, such as
+ * replacing the CDATASection nodes with Text nodes or specifying the type of
+ * the schema that must be used when the validation of the Document is
+ * requested. DOMConfiguration objects are also used in [DOM Level 3 Load and
+ * Save] in the DOMParser and DOMSerializer interfaces.
+ * <p/>
+ * The parameter names used by the DOMConfiguration object are defined
+ * throughout the DOM Level 3 specifications. Names are case-insensitive. To
+ * avoid possible conflicts, as a convention, names referring to parameters
+ * defined outside the DOM specification should be made unique. Because
+ * parameters are exposed as properties in the ECMAScript Language Binding,
+ * names are recommended to follow the section "5.16 Identifiers" of [Unicode]
+ * with the addition of the character '-' (HYPHEN-MINUS) but it is not
+ * enforced by the DOM implementation. DOM Level 3 Core Implementations are
+ * required to recognize all parameters defined in this specification. Some
+ * parameter values may also be required to be supported by the
+ * implementation. Refer to the definition of the parameter to know if a value
+ * must be supported or not.
+ * <p/>
+ * <b>Note</b>: Parameters are similar to features and properties used in SAX2 [SAX].
+ * <p/>
+ * The following list of parameters defined in the DOM:
+ * <dl>
+ * <dt><b>"canonical-form"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[optional]<br/>
+ * Canonicalize the document according to the rules specified in [Canonical
+ * XML], such as removing the DocumentType node (if any) from the tree, or
+ * removing superfluous namespace declarations from each element. Note that
+ * this is limited to what can be represented in the DOM; in particular, there
+ * is no way to specify the order of the attributes in the DOM. In addition,
+ * setting this parameter to true will also set the state of the parameters
+ * listed below. Later changes to the state of one of those parameters will
+ * revert "canonical-form" back to false.<br/>
+ * Parameters set to false: "entities", "normalize-characters",
+ * "cdata-sections".<br/>
+ * Parameters set to true: "namespaces", "namespace-declarations",
+ * "well-formed", "element-content-whitespace".<br/>
+ * Other parameters are not changed unless explicitly specified in the
+ * description of the parameters.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required] (default)<br/>
+ * Do not canonicalize the document.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"cdata-sections"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>
+ * [required] (default)<br/>
+ * Keep CDATASection nodes in the document.
+ * </dd>
+ * <dt><b>false</b>
+ * </dt><dd>
+ * [required]<br/>
+ * Transform CDATASection nodes in the document into Text nodes. The new Text
+ * node is then combined with any adjacent Text node.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"check-character-normalization"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>
+ * [optional]<br/>
+ * Check if the characters in the document are fully normalized, as defined in
+ * appendix B of [XML 1.1]. When a sequence of characters is encountered that
+ * fails normalization checking, an error with the DOMError.type equals to
+ * "check-character-normalization-failure" is issued.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required] (default)<br/>
+ * Do not check if characters are normalized.
+ * </dd></dl>
+ * <dd>
+ * <dt><b>"comments"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required] (default)<br/>
+ * Keep Comment nodes in the document.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required]<br/>
+ * Discard Comment nodes in the document.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"datatype-normalization"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[optional]<br/>
+ * Expose schema normalized values in the tree, such as XML Schema normalized
+ * values in the case of XML Schema. Since this parameter requires to have
+ * schema information, the "validate" parameter will also be set to true.
+ * Having this parameter activated when "validate" is false has no effect and
+ * no schema-normalization will happen.
+ * <p/>
+ * <b>Note</b>: Since the document contains the result of the XML 1.0 processing,
+ * this parameter does not apply to attribute value normalization as defined
+ * in section 3.3.3 of [XML 1.0] and is only meant for schema languages other
+ * than Document Type Definition (DTD).
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required] (default)<br/>
+ * Do not perform schema normalization on the tree.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"element-content-whitespace"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * </dt>
+ * <dd>[required] (default)<br/>
+ * Keep all whitespaces in the document.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[optional]<br/>
+ * Discard all Text nodes that contain whitespaces in element content, as
+ * described in [element content whitespace]. The implementation is expected
+ * to use the attribute Text.isElementContentWhitespace to determine if a Text
+ * node should be discarded or not.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"entities"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required] (default)<br/>
+ * Keep EntityReference nodes in the document.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required]<br/>
+ * Remove all EntityReference nodes from the document, putting the entity
+ * expansions directly in their place. Text nodes are normalized, as defined
+ * in Node.normalize. Only unexpanded entity references are kept in the
+ * document.
+ * <p/>
+ * <b>Note</b>: This parameter does not affect Entity nodes.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"error-handler"</b>
+ * <dd>[required]<br/>
+ * Contains a DOMErrorHandler object. If an error is encountered in the
+ * document, the implementation will call back the DOMErrorHandler registered
+ * using this parameter. The implementation may provide a default
+ * DOMErrorHandler object.
+ * <p/>
+ * When called, DOMError.relatedData will contain the closest node to where
+ * the error occurred. If the implementation is unable to determine the node
+ * where the error occurs, DOMError.relatedData will contain the Document node.
+ * Mutations to the document from within an error handler will result in
+ * implementation dependent behavior.
+ * </dd>
+ * <dt><b>"infoset"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required]<br/>
+ * Keep in the document the information defined in the XML Information Set
+ * [XML Information Set].<br/>
+ * This forces the following parameters to false: "validate-if-schema",
+ * "entities", "datatype-normalization", "cdata-sections".<br/>
+ * This forces the following parameters to true: "namespace-declarations",
+ * "well-formed", "element-content-whitespace", "comments", "namespaces".<br/>
+ * Other parameters are not changed unless explicitly specified in the
+ * description of the parameters.<br/>
+ * Note that querying this parameter with getParameter returns true only if
+ * the individual parameters specified above are appropriately set.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>Setting infoset to false has no effect.
+ * </dl>
+ * </dd>
+ * <dt><b>"namespaces"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required] (default)<br/>
+ * Perform the namespace processing as defined in Namespace Normalization.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[optional]<br/>
+ * Do not perform the namespace processing.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"namespace-declarations"</b>
+ * <dd>This parameter has no effect if the parameter "namespaces" is set to false.
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required] (default)<br/>
+ * Include namespace declaration attributes, specified or defaulted from the
+ * schema, in the document. See also the sections "Declaring Namespaces" in
+ * [XML Namespaces] and [XML Namespaces 1.1].
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required]<br/>
+ * Discard all namespace declaration attributes. The namespace prefixes
+ * (Node.prefix) are retained even if this parameter is set to false.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"normalize-characters"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[optional]<br/>
+ * Fully normalized the characters in the document as defined in appendix B of
+ * [XML 1.1].
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required] (default)<br/>
+ * Do not perform character normalization.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"schema-location"</b>
+ * <dd>[optional]<br/>
+ * Represent a DOMString object containing a list of URIs, separated by
+ * whitespaces (characters matching the nonterminal production S defined in
+ * section 2.3 [XML 1.0]), that represents the schemas against which validation
+ * should occur, i.e. the current schema. The types of schemas referenced in
+ * this list must match the type specified with schema-type, otherwise the
+ * behavior of an implementation is undefined.<br/>
+ * The schemas specified using this property take precedence to the schema
+ * information specified in the document itself. For namespace aware schema,
+ * if a schema specified using this property and a schema specified in the
+ * document instance (i.e. using the schemaLocation attribute) in a schema
+ * document (i.e. using schema import mechanisms) share the same
+ * targetNamespace, the schema specified by the user using this property will
+ * be used. If two schemas specified using this property share the same
+ * targetNamespace or have no namespace, the behavior is implementation
+ * dependent.<br/>
+ * If no location has been provided, this parameter is null.
+ * <p/>
+ * <b>Note</b>: The "schema-location" parameter is ignored unless the
+ * "schema-type" parameter value is set. It is strongly recommended that
+ * Document.documentURI will be set so that an implementation can successfully
+ * resolve any external entities referenced.
+ * </dd>
+ * <dt><b>"schema-type"</b>
+ * <dd>[optional]<br/>
+ * Represent a DOMString object containing an absolute URI and representing
+ * the type of the schema language used to validate a document against. Note
+ * that no lexical checking is done on the absolute URI.<br/>
+ * If this parameter is not set, a default value may be provided by the
+ * implementation, based on the schema languages supported and on the schema
+ * language used at load time. If no value is provided, this parameter is null.
+ * <p/>
+ * <b>Note</b>: For XML Schema [XML Schema Part 1], applications must use the
+ * value "http://www.w3.org/2001/XMLSchema". For XML DTD [XML 1.0],
+ * applications must use the value "http://www.w3.org/TR/REC-xml". Other schema
+ * languages are outside the scope of the W3C and therefore should recommend an
+ * absolute URI in order to use this method.
+ * </dd>
+ * <dt><b>"split-cdata-sections"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required] (default)<br/>
+ * Split CDATA sections containing the CDATA section termination marker ']]>'.
+ * When a CDATA section is split a warning is issued with a DOMError.type
+ * equals to "cdata-sections-splitted" and DOMError.relatedData equals to the
+ * first CDATASection node in document order resulting from the split.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required]<br/>
+ * Signal an error if a CDATASection contains an unrepresentable character.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"validate"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[optional]<br/>
+ * Require the validation against a schema (i.e. XML schema, DTD, any other
+ * type or representation of schema) of the document as it is being normalized
+ * as defined by [XML 1.0]. If validation errors are found, or no schema was
+ * found, the error handler is notified. Schema-normalized values will not be
+ * exposed according to the schema in used unless the parameter
+ * "datatype-normalization" is true.<br/>
+ * This parameter will reevaluate:
+ * <ul>
+ * <li>Attribute nodes with Attr.specified equals to false, as specified in the
+ * description of the Attr interface;
+ * <li>The value of the attribute Text.isElementContentWhitespace for all Text nodes;
+ * <li>The value of the attribute Attr.isId for all Attr nodes;
+ * <li>The attributes Element.schemaTypeInfo and Attr.schemaTypeInfo.
+ * </ul>
+ * <b>Note</b>: "validate-if-schema" and "validate" are mutually exclusive,
+ * setting one of them to true will set the other one to false. Applications
+ * should also consider setting the parameter "well-formed" to true, which is
+ * the default for that option, when validating the document.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required] (default)<br/>
+ * Do not accomplish schema processing, including the internal subset
+ * processing. Default attribute values information are kept. Note that
+ * validation might still happen if "validate-if-schema" is true.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"validate-if-schema"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[optional]<br/>
+ * Enable validation only if a declaration for the document element can be
+ * found in a schema (independently of where it is found, i.e. XML schema, DTD,
+ * or any other type or representation of schema). If validation is enabled,
+ * this parameter has the same behavior as the parameter "validate" set to true.
+ * <p/>
+ * <b>Note</b>: "validate-if-schema" and "validate" are mutually exclusive,
+ * setting one of them to true will set the other one to false.
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[required] (default)<br/>
+ * No schema processing should be performed if the document has a schema,
+ * including internal subset processing. Default attribute values information
+ * are kept. Note that validation must still happen if "validate" is true.
+ * </dd></dl>
+ * </dd>
+ * <dt><b>"well-formed"</b>
+ * <dd>
+ * <dl>
+ * <dt><b>true</b>
+ * <dd>[required] (default)<br/>
+ * Check if all nodes are XML well formed according to the XML version in use
+ * in Document.xmlVersion:
+ * <ul>
+ * <li>check if the attribute Node.nodeName contains invalid characters according
+ * to its node type and generate a DOMError of type
+ * "wf-invalid-character-in-node-name", with a DOMError.SEVERITY_ERROR
+ * severity, if necessary;
+ * <li>check if the text content inside Attr, Element, Comment, Text, CDATASection
+ * nodes for invalid characters and generate a DOMError of type
+ * "wf-invalid-character", with a DOMError.SEVERITY_ERROR severity, if
+ * necessary;
+ * <li>check if the data inside ProcessingInstruction nodes for invalid characters
+ * and generate a DOMError of type "wf-invalid-character", with a
+ * DOMError.SEVERITY_ERROR severity, if necessary;
+ * </ul>
+ * </dd>
+ * <dt><b>false</b>
+ * <dd>[optional]<br/>
+ * Do not check for XML well-formedness.
+ * </dd></dl>
+ * </dd></dl>
+ * <p/>
+ * The resolution of the system identifiers associated with entities is done
+ * using Document.documentURI. However, when the feature "LS" defined in
+ * [DOM Level 3 Load and Save] is supported by the DOM implementation, the
+ * parameter "resource-resolver" can also be used on DOMConfiguration objects
+ * attached to Document nodes. If this parameter is set,
+ * Document.normalizeDocument() will invoke the resource resolver instead of
+ * using Document.documentURI.
+ * @since DOM Level 3
+ *
+ * @version $Revision: 192827 $, $Date: 2004-02-07 22:57:16 -0500 (Sat, 07 Feb 2004) $
*/
public interface DOMConfiguration {
+ /**
+ * Set the value of a parameter.
+ * @param name The name of the parameter to set.
+ * @param value The new value or null if the user wishes to unset the
+ * parameter. While the type of the value parameter is defined as
+ * DOMUserData, the object type must match the type defined by the
+ * definition of the parameter. For example, if the parameter is
+ * "error-handler", the value must be of type DOMErrorHandler.
+ * @throws DOMException NOT_FOUND_ERR: Raised when the parameter name is
+ * not recognized.
+ * @throws DOMException NOT_SUPPORTED_ERR: Raised when the parameter name
+ * is recognized but the requested value cannot be set.
+ * @throws DOMException TYPE_MISMATCH_ERR: Raised if the value type for
+ * this parameter name is incompatible with the expected value type.
+ */
public void setParameter(String name, Object value) throws DOMException;
+
+ /**
+ * Return the value of a parameter if known.
+ * @param name he name of the parameter.
+ * @return The current object associated with the specified parameter or
+ * null if no object has been associated or if the parameter is not
+ * supported.
+ * @throws DOMException NOT_FOUND_ERR: Raised when the parameter name is
+ * not recognized.
+ */
public Object getParameter(String name) throws DOMException;
+
+ /**
+ * Check if setting a parameter to a specific value is supported.
+ * @param name The name of the parameter to check.
+ * @param value An object. if null, the returned value is true.
+ * @return true if the parameter could be successfully set to the specified
+ * value, or false if the parameter is not recognized or the requested
+ * value is not supported. This does not change the current value of the
+ * parameter itself.
+ */
boolean canSetParameter(String name, Object value);
+
+ /**
+ * The list of the parameters supported by this DOMConfiguration object
+ * and for which at least one value can be set by the application. Note
+ * that this list can also contain parameter names defined outside this
+ * specification.
+ * @return The list of the parameters supported by this DOMConfiguration
+ * object and for which at least one value can be set by the application.
+ * Note that this list can also contain parameter names defined outside
+ * this specification.
+ */
public DOMStringList getParameterNames();
}
Modified: 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=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java (original)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/DOMStringList.java Tue Oct 24 06:09:46 2006
@@ -1,10 +1,55 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
package org.w3c.dom;
/**
- * @version $Id$
+ * The DOMStringList interface provides the abstraction of an ordered
+ * collection of DOMString values, without defining or constraining how this
+ * collection is implemented. The items in the DOMStringList are accessible
+ * via an integral index, starting from 0.
+ *
+ * @since DOM Level 3
+ * @version $Revision: 192827 $, $Date: 2004-02-07 22:57:16 -0500 (Sat, 07 Feb 2004) $
*/
public interface DOMStringList {
- public String item(long index);
- public long getLength();
+
+ /**
+ * Returns the indexth item in the collection. If index is greater than or
+ * equal to the number of DOMStrings in the list, this returns null.
+ * @param index Index into the collection.
+ * @return The DOMString at the indexth position in the DOMStringList, or
+ * null if that is not a valid index.
+ */
+ public String item(int index);
+
+ /**
+ * The number of DOMStrings in the list. The range of valid child node
+ * indices is 0 to length-1 inclusive.
+ * @return The number of DOMStrings in the list. The range of valid child
+ * node indices is 0 to length-1 inclusive.
+ */
+ public int getLength();
+
+ /**
+ * Test if a string is part of this DOMStringList.
+ * @param str The string to look for.
+ * @return true if the string has been found, false otherwise.
+ */
public boolean contains(String str);
}
Modified: 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=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java (original)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/TypeInfo.java Tue Oct 24 06:09:46 2006
@@ -1,15 +1,182 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
package org.w3c.dom;
/**
- * @version $Id$
+ * The TypeInfo interface represents a type referenced from <code>Element</code>
+ * or <code>Attr</code> nodes, specified in the schemas associated with the
+ * document. The type is a pair of a namespace URI and name properties, and
+ * depends on the document's schema.
+ * <p/>
+ * If the document's schema is an XML DTD [XML 1.0], the values are computed as
+ * follows:
+ * <ul>
+ * <li>If this type is referenced from an <code>Attr</code> node, <code>typeNamespace</code> is
+ * "<code>http://www.w3.org/TR/REC-xml</code>" and <code>typeName</code> represents the
+ * <b>[attribute type]</b> property in the [XML Information Set]. If there is no declaration
+ * for the attribute, <code>typeNamespace</code> and <code>typeName</code> are <code>null</code>.
+ * <li>If this type is referenced from an <code>Element</code> node, <code>typeNamespace</code>
+ * and <code>typeName</code> are <code>null</code>.
+ * </ul>
+ * <p/>
+ * If the document's schema is an XML Schema [XML Schema Part 1], the values are computed as
+ * follows using the post-schema-validation infoset contributions (also called PSVI
+ * contributions):
+ * <ul>
+ * <li> If the <b>[validity]</b> property exists AND is <i>"invalid"</i> or <i>"notKnown"</i>:
+ * the {target namespace} and {name} properties of the declared type if
+ * available, otherwise <code>null</code>.
+ * <p/>
+ * <b>Note</b>: At the time of writing, the XML Schema specification does not
+ * require exposing the declared type. Thus, DOM implementations might choose
+ * not to provide type information if validity is not valid.
+ * <li>If the <b>[validity]</b> property exists and is <i>"valid"</i>:
+ * <ol>
+ * <li>If <b>[member type definition]</b> exists:
+ * <ol>
+ * <li>If {name} is not absent, then expose {name} and {target namespace}
+ * properties of the <b>[member type definition]</b> property;
+ * <li>Otherwise, expose the namespace and local name of the corresponding
+ * anonymous type name.
+ * </ol>
+ * <li>If the <b>[type definition]</b> property exists:
+ * <ol>
+ * <li>If {name} is not absent, then expose {name} and {target namespace}
+ * properties of the <b>[type definition]</b> property;
+ * <li>Otherwise, expose the namespace and local name of the corresponding
+ * anonymous type name.
+ * </ol>
+ * <li>If the <b>[member type definition anonymous]</b> exists:
+ * <ol>
+ * <li>If it is false, then expose <b>[member type definition name]</b> and <b>[member
+ * type definition namespace]</b> properties;
+ * <li>Otherwise, expose the namespace and local name of the corresponding
+ * anonymous type name.
+ * </ol>
+ * <li>If the <b>[type definition anonymous]</b> exists:
+ * <ol>
+ * <li>If it is false, then expose <b>[type definition name]</b> and <b>[type definition
+ * namespace]</b> properties;
+ * <li>Otherwise, expose the namespace and local name of the corresponding
+ * anonymous type name.
+ * </ol>
+ * </ol>
+ * </ul>
+ *
+ * @since DOM Level 3
+ * @version $Revision: 192827 $, $Date: 2004-02-07 22:57:16 -0500 (Sat, 07 Feb 2004) $
*/
public interface TypeInfo {
+
+ /**
+ * If the document's schema is an XML Schema [XML Schema Part 1], this
+ * constant represents the derivation by restriction if complex types
+ * are involved, or a restriction if simple types are involved.
+ * <p/>
+ * The reference type definition is derived by restriction from the
+ * other type definition if the other type definition is the same as the
+ * reference type definition, or if the other type definition can be
+ * reached recursively following the {base type definition} property from
+ * the reference type definition, and all the derivation methods involved
+ * are restriction.
+ */
public static final int DERIVATION_RESTRICTION = 0x00000001;
+
+ /**
+ * If the document's schema is an XML Schema [XML Schema Part 1], this
+ * constant represents the derivation by extension.
+ * <p/>
+ * The reference type definition is derived by extension from the other
+ * type definition if the other type definition can be reached recursively
+ * following the {base type definition} property from the reference type
+ * definition, and at least one of the derivation methods involved is an
+ * extension.
+ */
public static final int DERIVATION_EXTENSION = 0x00000002;
+
+ /**
+ * If the document's schema is an XML Schema [XML Schema Part 1], this
+ * constant represents the union if simple types are involved.
+ * <p/>
+ * The reference type definition is derived by union from the other type
+ * definition if there exists two type definitions T1 and T2 such as the
+ * reference type definition is derived from T1 by DERIVATION_RESTRICTION
+ * or DERIVATION_EXTENSION, T2 is derived from the other type definition
+ * by DERIVATION_RESTRICTION, T1 has {variety} union, and one of the
+ * {member type definitions} is T2. Note that T1 could be the same as the
+ * reference type definition, and T2 could be the same as the other type
+ * definition.
+ */
public static final int DERIVATION_UNION = 0x00000004;
+
+ /**
+ * If the document's schema is an XML Schema [XML Schema Part 1], this
+ * constant represents the list.
+ * <p/>
+ * The reference type definition is derived by list from the other type
+ * definition if there exists two type definitions T1 and T2 such as the
+ * reference type definition is derived from T1 by DERIVATION_RESTRICTION
+ * or DERIVATION_EXTENSION, T2 is derived from the other type definition
+ * by DERIVATION_RESTRICTION, T1 has {variety} list, and T2 is the {item
+ * type definition}. Note that T1 could be the same as the reference type
+ * definition, and T2 could be the same as the other type definition.
+ */
public static final int DERIVATION_LIST = 0x00000008;
+ /**
+ * The name of a type declared for the associated element or attribute, or
+ * <code>null</code> if unknown.
+ * @return The name of a type declared for the associated element or
+ * attribute, or null if unknown.
+ */
public String getTypeName();
+
+ /**
+ * The namespace of the type declared for the associated element or
+ * attribute or <code>null</code> if the element does not have declaration
+ * or if no namespace information is available.
+ * @return The namespace of the type declared for the associated element
+ * or attribute or null if the element does not have declaration or if
+ * no namespace information is available.
+ */
public String getTypeNamespace();
+
+ /**
+ * This method returns if there is a derivation between the reference type
+ * definition, i.e. the TypeInfo on which the method is being called, and
+ * the other type definition, i.e. the one passed as parameters.
+ * @param typeNamespaceArg the namespace of the other type definition.
+ * @param typeNameArg the name of the other type definition.
+ * @param derivationMethod the type of derivation and conditions applied
+ * between two types, as described in the list of constants provided in this
+ * interface.
+ * @return If the document's schema is a DTD or no schema is associated
+ * with the document, this method will always return false.
+ * <p/>
+ * If the document's schema is an XML Schema, the method will true if the
+ * reference type definition is derived from the other type definition
+ * according to the derivation parameter. If the value of the parameter is
+ * 0 (no bit is set to 1 for the derivationMethod parameter), the method
+ * will return true if the other type definition can be reached by
+ * recursing any combination of {base type definition}, {item type
+ * definition}, or {member type definitions} from the reference type
+ * definition.
+ */
public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod);
}
Modified: 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=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java (original)
+++ xml/xindice/trunk/java/dom3/org/w3c/dom/UserDataHandler.java Tue Oct 24 06:09:46 2006
@@ -1,16 +1,75 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
package org.w3c.dom;
/**
- * @version $Id$
+ * When associating an object to a key on a node using Node.setUserData()
+ * the application can provide a handler that gets called when the node the
+ * object is associated to is being cloned, imported, or renamed. This can be
+ * used by the application to implement various behaviors regarding the data
+ * it associates to the DOM nodes. This interface defines that handler.
+ *
+ * @since DOM Level 3
+ * @version $Revision: 192827 $, $Date: 2004-02-07 22:57:16 -0500 (Sat, 07 Feb 2004) $
*/
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;
+ // An integer indicating the type of operation being performed on a node.
+
+ /**
+ * The node is cloned, using Node.cloneNode().
+ */
+ public static final short NODE_CLONED = 1;
+
+ /**
+ * The node is imported, using Document.importNode().
+ */
+ public static final short NODE_IMPORTED = 2;
+
+ /**
+ * The node is deleted.
+ */
+ public static final short NODE_DELETED = 3;
+
+ /**
+ * The node is renamed, using Document.renameNode().
+ */
+ public static final short NODE_RENAMED = 4;
+
+ /**
+ * The node is adopted, using Document.adoptNode().
+ */
+ public static final short NODE_ADOPTED = 5;
- public void handle(short operation, String key, Object data, Node src, Node dst);
+ /**
+ * This method is called whenever the node for which this handler is
+ * registered is imported or cloned.<br/>
+ * DOM applications must not raise exceptions in a UserDataHandler. The
+ * effect of throwing exceptions from the handler is DOM implementation
+ * dependent.
+ * @param operation Specifies the type of operation that is being
+ * performed on the node.
+ * @param key Specifies the key for which this handler is being called.
+ * @param data Specifies the data for which this handler is being called.
+ * @param src Specifies the node being cloned, adopted, imported, or
+ * renamed. This is null when the node is being deleted.
+ * @param dst Specifies the node newly created if any, or null.
+ */
+ public void handle(short operation, String key, Object data, Node src, Node dst);
}
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -187,4 +187,21 @@
public boolean isId() {
return false;
}
+
+ Node renameNode(String namespaceURI, String qualifiedName, String prefix) {
+ checkLoaded();
+ checkReadOnly();
+
+ if ((XMLNS_PREFIX.equals(prefix) || XMLNS_PREFIX.equals(qualifiedName)) &&
+ !XMLNS_URI.equals(namespaceURI)) {
+ throw new DOMException(DOMException.NAMESPACE_ERR, XMLNS_PREFIX + " prefix is reserved.");
+ }
+
+ nodeName = qualifiedName;
+ if (prefix != null) {
+ getOwnerElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, namespaceURI);
+ }
+
+ return this;
+ }
}
Added: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java?view=auto&rev=467324
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java (added)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java Tue Oct 24 06:09:46 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.xindice.xml.dom;
+
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMStringList;
+
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ *
+ * @version $Revision$, $Date$
+ */
+public class DOMConfigurationImpl implements DOMConfiguration {
+
+ private static final DOMStringList NAMES = new DOMStringListImpl();
+
+ private Map config = Collections.synchronizedMap(new HashMap());
+
+ DOMConfigurationImpl() {
+ config.put("canonical-form", null);
+ config.put("cdata-sections", null);
+ config.put("check-character-normalization", null);
+ config.put("comments", null);
+ config.put("datatype-normalization", null);
+ config.put("element-content-whitespace", null);
+ config.put("entities", null);
+ config.put("error-handler", null);
+ config.put("infoset", null);
+ config.put("namespaces", null);
+ config.put("namespace-declarations", null);
+ config.put("normalize-characters", null);
+ config.put("schema-location", null);
+ config.put("schema-type", null);
+ config.put("split-cdata-sections", null);
+ config.put("validate", null);
+ config.put("validate-if-schema", null);
+ config.put("well-formed", null);
+ }
+
+ public void setParameter(String name, Object value) throws DOMException {
+ if (!config.containsKey(name)) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Parameter " + name + " is not recognized");
+ }
+ }
+
+ public Object getParameter(String name) throws DOMException {
+ if (!config.containsKey(name)) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "Parameter " + name + " is not recognized");
+ }
+
+ return config.get(name);
+ }
+
+ public boolean canSetParameter(String name, Object value) {
+ return false;
+ }
+
+ public DOMStringList getParameterNames() {
+ return NAMES;
+ }
+}
Propchange: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMConfigurationImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java?view=auto&rev=467324
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java (added)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java Tue Oct 24 06:09:46 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.xindice.xml.dom;
+
+import org.w3c.dom.DOMStringList;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ *
+ * @version $Revision$, $Date$
+ */
+public class DOMStringListImpl implements DOMStringList {
+
+ private List list;
+
+
+ DOMStringListImpl() {
+ list = new ArrayList();
+ }
+
+ DOMStringListImpl(String[] strings) {
+ list = Arrays.asList(strings);
+ }
+
+ public String item(int index) {
+ try {
+ return (String) list.get(index);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
+ }
+
+ public int getLength() {
+ return list.size();
+ }
+
+ public boolean contains(String str) {
+ return list.contains(str);
+ }
+}
Propchange: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMStringListImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -68,6 +68,7 @@
private boolean strictErrorChecking;
private SymbolTable symbols;
private boolean readOnly;
+ private DOMConfiguration domConfig = new DOMConfigurationImpl();
public DocumentImpl() {
@@ -579,7 +580,7 @@
* @since DOM Level 3
*/
public DOMConfiguration getDomConfig() {
- return null;
+ return domConfig;
}
/**
@@ -589,16 +590,84 @@
}
/**
+ * Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE.
+ * <p/>
+ * When possible this simply changes the name of the given node, otherwise
+ * this creates a new node with the specified name and replaces the
+ * existing node with the new node as described below.
+ * <p/>
+ * If simply changing the name of the given node is not possible, the
+ * following operations are performed: a new node is created, any
+ * registered event listener is registered on the new node, any user data
+ * attached to the old node is removed from that node, the old node is
+ * removed from its parent if it has one, the children are moved to the
+ * new node, if the renamed node is an Element its attributes are moved to
+ * the new node, the new node is inserted at the position the old node used
+ * to have in its parent's child nodes list if it has one, the user data
+ * that was attached to the old node is attached to the new node.
+ * <p/>
+ * When the node being renamed is an Element only the specified attributes
+ * are moved, default attributes originated from the DTD are updated
+ * according to the new element name. In addition, the implementation may
+ * update default attributes from other schemas. Applications should use
+ * Document.normalizeDocument() to guarantee these attributes are
+ * up-to-date.
+ * <p/>
+ * When the node being renamed is an Attr that is attached to an Element,
+ * the node is first removed from the Element attributes map. Then, once
+ * renamed, either by modifying the existing node or creating a new one as
+ * described above, it is put back.
+ * <p/>
+ * In addition, <ul>
+ * <li>a user data event NODE_RENAMED is fired,
+ * <li>when the implementation supports the feature "MutationNameEvents",
+ * each mutation operation involved in this method fires the appropriate
+ * event, and in the end the event {http://www.w3.org/2001/xml-events,
+ * DOMElementNameChanged} or {http://www.w3.org/2001/xml-events,
+ * DOMAttributeNameChanged} is fired.
+ * </ul>
+ * @param n The node to rename.
+ * @param namespaceURI The new namespace URI.
+ * @param qualifiedName The new qualified name.
+ * @return The renamed node. This is either the specified node or the new
+ * node that was created to replace the specified node.
+ * @throws DOMException NOT_SUPPORTED_ERR: Raised when the type of the
+ * specified node is neither ELEMENT_NODE nor ATTRIBUTE_NODE, or if the
+ * implementation does not support the renaming of the document element.
+ * @throws DOMException INVALID_CHARACTER_ERR: Raised if the new qualified
+ * name is not an XML name according to the XML version in use specified
+ * in the Document.xmlVersion attribute.
+ * @throws DOMException WRONG_DOCUMENT_ERR: Raised when the specified node
+ * was created from a different document than this document.
+ * @throws DOMException NAMESPACE_ERR: Raised if the qualifiedName is a
+ * malformed qualified name, if the qualifiedName has a prefix and the
+ * namespaceURI is null, or if the qualifiedName has a prefix that is
+ * "xml" and the namespaceURI is different from
+ * "http://www.w3.org/XML/1998/namespace" [XML Namespaces]. Also raised,
+ * when the node being renamed is an attribute, if the qualifiedName, or
+ * its prefix, is "xmlns" and the namespaceURI is different from
+ * "http://www.w3.org/2000/xmlns/".
* @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");
+ if (!(n instanceof NodeImpl) || n.getOwnerDocument() != this) {
+ throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "Node was created from a different document");
+ }
+
+ int idx = qualifiedName.indexOf(':');
+ String prefix = idx >= 0 ? qualifiedName.substring(0, idx) : null;
+
+ if (prefix != null && ("".equals(prefix) || namespaceURI == null || "".equals(namespaceURI))) {
+ throw new DOMException(DOMException.NAMESPACE_ERR, "Malformed qualified name '" + qualifiedName + "'.");
+ }
+
+ return ((NodeImpl) n).renameNode(namespaceURI, qualifiedName, prefix);
}
/**
* @since DOM Level 3
*/
public String getTextContent() {
- return "";
+ return null;
}
}
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -109,7 +109,7 @@
* @since DOM Level 3
*/
public String getTextContent() {
- return "";
+ return null;
}
/**
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -530,4 +530,16 @@
return true;
}
+
+ Node renameNode(String namespaceURI, String qualifiedName, String prefix) throws DOMException {
+ checkLoaded();
+ checkReadOnly();
+
+ nodeName = qualifiedName;
+ if (prefix != null) {
+ setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + prefix, namespaceURI);
+ }
+
+ return this;
+ }
}
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -33,7 +33,10 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.UserDataHandler;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
/**
* NodeImpl implements the foundation of the Xindice compressed DOM.
@@ -85,6 +88,42 @@
public static final DOMException EX_INDEX_SIZE =
new DOMException(DOMException.INDEX_SIZE_ERR, "Index Out Of Bounds");
+ // DocumentPosition flags
+ /**
+ * The two nodes are disconnected. Order between disconnected nodes is
+ * always implementation-specific.
+ */
+ public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01;
+
+ /**
+ * The second node precedes the reference node.
+ */
+ public static final short DOCUMENT_POSITION_PRECEDING = 0x02;
+
+ /**
+ * The node follows the reference node.
+ */
+ public static final short DOCUMENT_POSITION_FOLLOWING = 0x04;
+
+ /**
+ * The node contains the reference node. A node which contains is always
+ * preceding, too.
+ */
+ public static final short DOCUMENT_POSITION_CONTAINS = 0x08;
+
+ /**
+ * The node is contained by the reference node. A node which is contained
+ * is always following, too.
+ */
+ public static final short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
+
+ /**
+ * The determination of preceding versus following is
+ * implementation-specific.
+ */
+ public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
+
+
// Serialization Stuff
protected NodeSource source;
protected byte[] data;
@@ -897,6 +936,10 @@
return userData.get(key);
}
+ Node renameNode(String namespaceURI, String qualifiedName, String prefix) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Only Element and Attribute nodes can be renamed.");
+ }
+
/**
* @since DOM Level 3
*/
@@ -1029,10 +1072,122 @@
}
/**
+ * Compares the reference node, i.e. the node on which this method is being
+ * called, with a node, i.e. the one passed as a parameter, with regard to
+ * their position in the document and according to the document order.
+ * @param other The node to compare against the reference node.
+ * @return Returns how the node is positioned relatively to the reference
+ * node.
+ * @throws DOMException NOT_SUPPORTED_ERR: when the compared nodes are
+ * from different DOM implementations that do not coordinate to return
+ * consistent implementation-specific results.
* @since DOM Level 3
*/
public short compareDocumentPosition(Node other) throws DOMException {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is not supported");
+ if (this == other) {
+ return 0;
+ }
+
+ if (!(other instanceof NodeImpl)) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Nodes are from different DOM implementations");
+ }
+
+ if (getOwnerDocument() != other.getOwnerDocument()) {
+ return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
+ }
+
+ ArrayList ancestors = new ArrayList();
+ Node root = findAncestors(this, other, ancestors);
+ Node ancNode = (Node) ancestors.get(0);
+ Node ancOther = (Node) ancestors.get(1);
+
+ if (root == null) {
+ return DOCUMENT_POSITION_DISCONNECTED;
+ }
+
+ if (root == other) {
+ return DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING;
+ }
+
+ if (root == this) {
+ return DOCUMENT_POSITION_CONTAINED_BY | DOCUMENT_POSITION_FOLLOWING;
+ }
+
+ short ancNodeType = ancNode.getNodeType();
+ short ancOtherType = ancOther.getNodeType();
+
+ boolean nodeIsChild = ancNodeType != ATTRIBUTE_NODE && ancNodeType != NOTATION_NODE;
+ boolean otherIsChild = ancOtherType != ATTRIBUTE_NODE && ancOtherType != NOTATION_NODE;
+
+ if (nodeIsChild && otherIsChild) {
+ Node child = root.getFirstChild();
+
+ while (child != null) {
+ if (child == ancNode) {
+ return DOCUMENT_POSITION_FOLLOWING;
+ } else if (child == ancOther) {
+ return DOCUMENT_POSITION_PRECEDING;
+ }
+
+ child = child.getNextSibling();
+ }
+
+ return 0;
+ } else if (nodeIsChild ^ otherIsChild) {
+ return nodeIsChild ? DOCUMENT_POSITION_PRECEDING : DOCUMENT_POSITION_FOLLOWING;
+ } else {
+ if (ancNodeType != ancOtherType) {
+ return ancNodeType > ancOtherType ? DOCUMENT_POSITION_PRECEDING : DOCUMENT_POSITION_FOLLOWING;
+ } else {
+ return DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
+ }
+ }
+ }
+
+ private Node findParent(Set seen, Node node, ArrayList path) {
+ if (node == null) {
+ return null;
+ }
+
+ seen.add(node);
+ path.add(node);
+ return node.getParentNode();
+ }
+
+ private Node findAncestors(Node node1, Node node2, ArrayList ancestors) {
+ ArrayList path1 = new ArrayList();
+ ArrayList path2 = new ArrayList();
+ HashSet seen = new HashSet();
+
+ Node root = null;
+ do {
+ node1 = findParent(seen, node1, path1);
+ node2 = findParent(seen, node2, path2);
+
+ if (seen.contains(node1)) {
+ root = node1;
+ ancestors.add(path1.get(path1.size() - 1));
+ int idx = path2.indexOf(node1);
+ ancestors.add(path2.get(idx > 0 ? idx - 1 : 0));
+
+ break;
+ } else if (seen.contains(node2)) {
+ root = node2;
+ int idx = path1.indexOf(node2);
+ ancestors.add(path1.get(idx > 0 ? idx - 1 : 0));
+ ancestors.add(path2.get(path2.size() - 1));
+
+ break;
+ } else if (node1 != null && node1 == node2) {
+ root = node1;
+ ancestors.add(path1.get(path1.size() - 1));
+ ancestors.add(path2.get(path2.size() - 1));
+
+ break;
+ }
+ } while (node1 != null || node2 != null);
+
+ return root;
}
//
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -63,7 +63,7 @@
* @since DOM Level 3
*/
public String getTextContent() {
- return "";
+ return null;
}
}
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=467324&r1=467323&r2=467324
==============================================================================
--- 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 Tue Oct 24 06:09:46 2006
@@ -86,7 +86,7 @@
* @since DOM Level 3
*/
public boolean isElementContentWhitespace() {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Operation is not supported");
+ return false;
}
/**
Modified: xml/xindice/trunk/java/tests/src/org/apache/xindice/core/CollectionTest.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/core/CollectionTest.java?view=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/core/CollectionTest.java (original)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/core/CollectionTest.java Tue Oct 24 06:09:46 2006
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * CVS $Id$
+ * $Id$
*/
package org.apache.xindice.core;
@@ -30,7 +30,7 @@
* org.apache.xindice.core.Collection)
*
* @author <a href="mailto:[email protected]">Vadim Gritsenko</a>
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
*/
public class CollectionTest extends TestCase {
Added: xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java?view=auto&rev=467324
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java (added)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java Tue Oct 24 06:09:46 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.xindice.xml.dom;
+
+import junit.framework.TestCase;
+import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+
+/**
+ * Tests NodeImpl class
+ *
+ * @version $Revision$, $Date$
+ */
+public class DocumentTest 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>" +
+ "</a>";
+
+ private Document dom;
+
+ public void setUp() throws Exception {
+ dom = DOMParser.toDocument(DocumentTest.XML);
+ }
+
+ public void testRenameNode() throws Exception {
+ Node node1 = dom.getFirstChild().getFirstChild().getNextSibling();
+
+ node1 = ((DocumentImpl) dom).renameNode(node1, "http://xindice.org", "new:name");
+ assertEquals(node1.getNodeName(), "new:name");
+ assertEquals(node1.getNamespaceURI(), "http://xindice.org");
+
+ node1 = ((DocumentImpl) dom).renameNode(node1, "", "name");
+ assertEquals(node1.getNodeName(), "name");
+ assertEquals(node1.getNamespaceURI(), null);
+
+ NamedNodeMap attrs = dom.getFirstChild().getFirstChild().getNextSibling().getAttributes();
+ node1 = attrs.getNamedItem("attr1");
+ node1 = ((DocumentImpl) dom).renameNode(node1, "http://xindice.org", "new:attr4");
+ assertEquals(node1.getNodeName(), "new:attr4");
+ assertEquals(node1.getNamespaceURI(), "http://xindice.org");
+ }
+}
Propchange: xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/DocumentTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: 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=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java (original)
+++ xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java Tue Oct 24 06:09:46 2006
@@ -2,6 +2,8 @@
import junit.framework.TestCase;
import org.w3c.dom.Node;
+import org.w3c.dom.Document;
+import org.apache.xindice.xml.SymbolTable;
/**
* Tests NodeImpl class
@@ -28,10 +30,35 @@
"<d>Parent text<e>Child text</e></d>" +
"</a>";
+ private static final String cmpXML =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
+ "<a>" +
+ "<b/>" +
+ "<c attr1=\"a\" attr2=\"b\">" +
+ "<d attr3=\"c\" attr4=\"d\">" +
+ "<e attr=\"1\" />" +
+ "</d>" +
+ "</c>" +
+ "<f attr1=\"a\" attr2=\"b\">" +
+ "<d attr3=\"c\" attr4=\"d\" >" +
+ "<e attr=\"2\" />" +
+ "</d>" +
+ "</f>" +
+ "<d>Parent text<e>Child text</e></d>" +
+ "</a>";
+
+ private Document doc;
private Node dom;
+ private Document cmpDoc;
+ private Node cmpDom;
+
public void setUp() throws Exception {
- dom = DOMParser.toDocument(NodeTest.XML).getDocumentElement();
+ doc = DOMParser.toDocument(NodeTest.XML);
+ dom = doc.getDocumentElement();
+
+ cmpDoc = DOMParser.toDocument(NodeTest.cmpXML);
+ cmpDom = cmpDoc.getDocumentElement();
}
public void testNodeEquality() throws Exception {
@@ -63,4 +90,42 @@
assertEquals("New text", ((NodeImpl) node1).getTextContent());
assertEquals(1, node1.getChildNodes().getLength());
}
+
+ public void testCloneNode() throws Exception {
+ SymbolTable symbols = new SymbolTable();
+ Document cdoc = new DocumentImpl(DOMCompressor.Compress(doc, symbols), symbols, null);
+
+ Node node1 = cdoc.getDocumentElement().getFirstChild().getNextSibling();
+ Node node2 = node1.cloneNode(true);
+
+ assertTrue("The cloned node is equal to the original node", ((NodeImpl) node1).isEqualNode(node2));
+ assertEquals(false, ((NodeImpl) node1).isSameNode(node2));
+// assertEquals(null, node2.getParentNode());
+ }
+
+ public void testCompareNodeposition() throws Exception {
+ Node node1 = cmpDom.getFirstChild().getNextSibling();
+ assertEquals(NodeImpl.DOCUMENT_POSITION_CONTAINED_BY | NodeImpl.DOCUMENT_POSITION_FOLLOWING,
+ ((NodeImpl) cmpDoc).compareDocumentPosition(node1));
+
+ assertEquals(NodeImpl.DOCUMENT_POSITION_CONTAINS | NodeImpl.DOCUMENT_POSITION_PRECEDING,
+ ((NodeImpl) node1).compareDocumentPosition(cmpDom));
+
+ node1 = cmpDom.getFirstChild().getNextSibling().getFirstChild();
+ Node node2 = cmpDom.getFirstChild().getNextSibling().getNextSibling().getFirstChild().getFirstChild();
+ assertEquals(NodeImpl.DOCUMENT_POSITION_FOLLOWING, ((NodeImpl) node1).compareDocumentPosition(node2));
+
+ node1 = cmpDom.getFirstChild().getNextSibling().getAttributes().item(0);
+ node2 = cmpDom.getFirstChild().getNextSibling().getFirstChild();
+ assertEquals(NodeImpl.DOCUMENT_POSITION_FOLLOWING, ((NodeImpl) node1).compareDocumentPosition(node2));
+
+ assertEquals(NodeImpl.DOCUMENT_POSITION_DISCONNECTED | NodeImpl.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,
+ ((NodeImpl) doc).compareDocumentPosition(cmpDoc));
+
+ node1 = cmpDom.getFirstChild().getNextSibling();
+ node2 = cmpDom.getFirstChild().getNextSibling().getFirstChild();
+ assertEquals(NodeImpl.DOCUMENT_POSITION_FOLLOWING | NodeImpl.DOCUMENT_POSITION_CONTAINED_BY,
+ ((NodeImpl) node1).compareDocumentPosition(node2));
+ }
+
}
Propchange: xml/xindice/trunk/java/tests/src/org/apache/xindice/xml/dom/NodeTest.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Tue Oct 24 06:09:46 2006
@@ -1 +1 @@
-Id
+Author Date Id Revision
Modified: xml/xindice/trunk/status.xml
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?view=diff&rev=467324&r1=467323&r2=467324
==============================================================================
--- xml/xindice/trunk/status.xml (original)
+++ xml/xindice/trunk/status.xml Tue Oct 24 06:09:46 2006
@@ -73,7 +73,10 @@
</todo>
<changes>
- <release version="1.1b5-dev" date="Oct 10 2006">
+ <release version="1.1b5-dev" date="Oct 24 2006">
+ <action dev="VG" type="update">
+ Implement DOM3 API compatibility.
+ </action>
<action dev="VG" type="fix" fixes-bug="31159">
Data files were created 6Mb in size instead of 4Mb (default value).
</action>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.