diff --git a/java/external/src/org/w3c/dom/Attr.java b/java/external/src/org/w3c/dom/Attr.java index 4ba62e2..d9ed6ff 100644 --- a/java/external/src/org/w3c/dom/Attr.java +++ b/java/external/src/org/w3c/dom/Attr.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -15,7 +15,7 @@ package org.w3c.dom; /** * The Attr interface represents an attribute in an * Element object. Typically the allowable values for the - * attribute are defined in a document type definition. + * attribute are defined in a schema associated with the document. *

Attr objects inherit the Node interface, but * since they are not actually child nodes of the element they describe, the * DOM does not consider them part of the document tree. Thus, the @@ -39,48 +39,137 @@ package org.w3c.dom; * this attribute, and that declaration includes a default value, then that * default value is the attribute's effective value; otherwise, the * attribute does not exist on this element in the structure model until it - * has been explicitly added. Note that the nodeValue attribute - * on the Attr instance can also be used to retrieve the string - * version of the attribute's value(s). + * has been explicitly added. Note that the Node.nodeValue + * attribute on the Attr instance can also be used to retrieve + * the string version of the attribute's value(s). + *

If the attribute was not explicitly given a value in the instance + * document but has a default value provided by the schema associated with + * the document, an attribute node will be created with + * specified set to false. Removing attribute + * nodes for which a default value is defined in the schema generates a new + * attribute node with the default value and specified set to + * false. If validation occurred while invoking + * Document.normalizeDocument(), attribute nodes with + * specified equals to false are recomputed + * according to the default attribute values provided by the schema. If no + * default value is associate with this attribute in the schema, the + * attribute node is discarded. *

In XML, where the value of an attribute can contain entity references, * the child nodes of the Attr node may be either * Text or EntityReference nodes (when these are * in use; see the description of EntityReference for - * discussion). Because the DOM Core is not aware of attribute types, it - * treats all attribute values as simple strings, even if the DTD or schema - * declares them as having tokenized types. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + * discussion). + *

The DOM Core represents all attribute values as simple strings, even if + * the DTD or schema associated with the document declares them of some + * specific type such as tokenized. + *

The way attribute value normalization is performed by the DOM + * implementation depends on how much the implementation knows about the + * schema in use. Typically, the value and + * nodeValue attributes of an Attr node initially + * returns the normalized value given by the parser. It is also the case + * after Document.normalizeDocument() is called (assuming the + * right options have been set). But this may not be the case after + * mutation, independently of whether the mutation is performed by setting + * the string value directly or by changing the Attr child + * nodes. In particular, this is true when character + * references are involved, given that they are not represented in the DOM and they + * impact attribute value normalization. On the other hand, if the + * implementation knows about the schema in use when the attribute value is + * changed, and it is of a different type than CDATA, it may normalize it + * again at that time. This is especially true of specialized DOM + * implementations, such as SVG DOM implementations, which store attribute + * values in an internal form different from a string. + *

The following table gives some examples of the relations between the + * attribute value in the original document (parsed attribute), the value as + * exposed in the DOM, and the serialization of the value: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
ExamplesParsed + * attribute valueInitial Attr.valueSerialized attribute value
+ * Character reference + *
"x²=5"
+ *
+ *
"x\u00b2=5"
+ *
+ *
"x²=5"
+ *
Built-in + * character entity + *
"y<6"
+ *
+ *
"y<6"
+ *
+ *
"y&lt;6"
+ *
Literal newline between + *
+ * "x=5&#10;y=6"
+ *
+ *
"x=5 y=6"
+ *
+ *
"x=5&#10;y=6"
+ *
Normalized newline between + *
"x=5 
+ * y=6"
+ *
+ *
"x=5 y=6"
+ *
+ *
"x=5 y=6"
+ *
Entity e with literal newline + *
+ * <!ENTITY e '...&#10;...'> [...]> "x=5&e;y=6"
+ *
Dependent on Implementation and Load OptionsDependent on Implementation and Load/Save Options
+ *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Attr extends Node { /** - * Returns the name of this attribute. + * Returns the name of this attribute. If Node.localName is + * different from null, this attribute is a qualified name. */ public String getName(); /** - * If this attribute was explicitly given a value in the original - * document, this is true; otherwise, it is - * false. Note that the implementation is in charge of this - * attribute, not the user. If the user changes the value of the - * attribute (even if it ends up having the same value as the default - * value) then the specified flag is automatically flipped - * to true. To re-specify the attribute as the default - * value from the DTD, the user must delete the attribute. The - * implementation will then make a new attribute available with - * specified set to false and the default - * value (if one exists). - *
In summary: If the attribute has an assigned value in the document - * then specified is true, and the value is - * the assigned value.If the attribute has no assigned value in the - * document and has a default value in the DTD, then - * specified is false, and the value is the - * default value in the DTD.If the attribute has no assigned value in - * the document and has a value of #IMPLIED in the DTD, then the - * attribute does not appear in the structure model of the document.If - * the ownerElement attribute is null (i.e. - * because it was just created or was set to null by the - * various removal and cloning operations) specified is - * true. + * True if this attribute was explicitly given a value in + * the instance document, false otherwise. If the + * application changed the value of this attribute node (even if it ends + * up having the same value as the default value) then it is set to + * true. The implementation may handle attributes with + * default values from other schemas similarly but applications should + * use Document.normalizeDocument() to guarantee this + * information is up-to-date. */ public boolean getSpecified(); @@ -90,12 +179,13 @@ public interface Attr extends Node { * values. See also the method getAttribute on the * Element interface. *
On setting, this creates a Text node with the unparsed - * contents of the string. I.e. any characters that an XML processor + * contents of the string, i.e. any characters that an XML processor * would recognize as markup are instead treated as literal text. See - * also the method setAttribute on the Element - * interface. - * @exception DOMException - * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * also the method Element.setAttribute(). + *
Some specialized implementations, such as some [SVG 1.1] + * implementations, may do normalization automatically, even after + * mutation; in such case, the value on retrieval may differ from the + * value on setting. */ public String getValue(); /** @@ -104,10 +194,13 @@ public interface Attr extends Node { * values. See also the method getAttribute on the * Element interface. *
On setting, this creates a Text node with the unparsed - * contents of the string. I.e. any characters that an XML processor + * contents of the string, i.e. any characters that an XML processor * would recognize as markup are instead treated as literal text. See - * also the method setAttribute on the Element - * interface. + * also the method Element.setAttribute(). + *
Some specialized implementations, such as some [SVG 1.1] + * implementations, may do normalization automatically, even after + * mutation; in such case, the value on retrieval may differ from the + * value on setting. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. */ @@ -121,4 +214,62 @@ public interface Attr extends Node { */ public Element getOwnerElement(); + /** + * The type information associated with this attribute. While the type + * information contained in this attribute is guarantee to be correct + * after loading the document or invoking + * Document.normalizeDocument(), schemaTypeInfo + * may not be reliable if the node was moved. + * @since DOM Level 3 + */ + public TypeInfo getSchemaTypeInfo(); + + /** + * Returns whether this attribute is known to be of type ID (i.e. to + * contain an identifier for its owner element) or not. When it is and + * its value is unique, the ownerElement of this attribute + * can be retrieved using the method Document.getElementById + * . The implementation could use several ways to determine if an + * attribute node is known to contain an identifier: + *

+ *
If validation occurred while invoking + * Document.normalizeDocument(), all user-determined ID + * attributes are reset and all attribute nodes ID information are then + * reevaluated in accordance to the schema used. As a consequence, if + * the Attr.schemaTypeInfo attribute contains an ID type, + * isId will always return true. + * @since DOM Level 3 + */ + public boolean isId(); + } diff --git a/java/external/src/org/w3c/dom/CDATASection.java b/java/external/src/org/w3c/dom/CDATASection.java index f3aea8a..9267227 100644 --- a/java/external/src/org/w3c/dom/CDATASection.java +++ b/java/external/src/org/w3c/dom/CDATASection.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -19,9 +19,8 @@ package org.w3c.dom; * section. CDATA sections cannot be nested. Their primary purpose is for * including material such as XML fragments, without needing to escape all * the delimiters. - *

The DOMString attribute of the Text node holds - * the text that is contained by the CDATA section. Note that this may - * contain characters that need to be escaped outside of CDATA sections and + *

The CharacterData.data attribute holds the text that is + * contained by the CDATA section. Note that this may contain characters that need to be escaped outside of CDATA sections and * that, depending on the character encoding ("charset") chosen for * serialization, it may be impossible to write out some characters as part * of a CDATA section. @@ -29,20 +28,27 @@ package org.w3c.dom; * CharacterData interface through the Text * interface. Adjacent CDATASection nodes are not merged by use * of the normalize method of the Node interface. - * Because no markup is recognized within a CDATASection, - * character numeric references cannot be used as an escape mechanism when - * serializing. Therefore, action needs to be taken when serializing a - * CDATASection with a character encoding where some of the - * contained characters cannot be represented. Failure to do so would not - * produce well-formed XML.One potential solution in the serialization - * process is to end the CDATA section before the character, output the - * character using a character reference or entity reference, and open a new - * CDATA section for any further characters in the text node. Note, however, - * that some code conversion libraries at the time of writing do not return - * an error or exception when a character is missing from the encoding, - * making the task of ensuring that data is not corrupted on serialization - * more difficult. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

No lexical check is done on the content of a CDATA section and it is + * therefore possible to have the character sequence "]]>" + * in the content, which is illegal in a CDATA section per section 2.7 of [XML 1.0]. The + * presence of this character sequence must generate a fatal error during + * serialization or the cdata section must be splitted before the + * serialization (see also the parameter "split-cdata-sections" + * in the DOMConfiguration interface). + *

Note: Because no markup is recognized within a + * CDATASection, character numeric references cannot be used as + * an escape mechanism when serializing. Therefore, action needs to be taken + * when serializing a CDATASection with a character encoding + * where some of the contained characters cannot be represented. Failure to + * do so would not produce well-formed XML. + *

Note: One potential solution in the serialization process is to + * end the CDATA section before the character, output the character using a + * character reference or entity reference, and open a new CDATA section for + * any further characters in the text node. Note, however, that some code + * conversion libraries at the time of writing do not return an error or + * exception when a character is missing from the encoding, making the task + * of ensuring that data is not corrupted on serialization more difficult. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface CDATASection extends Text { } diff --git a/java/external/src/org/w3c/dom/CharacterData.java b/java/external/src/org/w3c/dom/CharacterData.java index c067120..a12dced 100644 --- a/java/external/src/org/w3c/dom/CharacterData.java +++ b/java/external/src/org/w3c/dom/CharacterData.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -24,7 +24,7 @@ package org.w3c.dom; * the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In * the following, the term 16-bit units is used whenever necessary to * indicate that indexing on CharacterData is done in 16-bit units. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface CharacterData extends Node { /** @@ -36,8 +36,6 @@ public interface CharacterData extends Node { * may call substringData to retrieve the data in * appropriately sized pieces. * @exception DOMException - * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. - * @exception DOMException * DOMSTRING_SIZE_ERR: Raised when it would return more characters than * fit in a DOMString variable on the implementation * platform. @@ -54,10 +52,6 @@ public interface CharacterData extends Node { * appropriately sized pieces. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. - * @exception DOMException - * DOMSTRING_SIZE_ERR: Raised when it would return more characters than - * fit in a DOMString variable on the implementation - * platform. */ public void setData(String data) throws DOMException; diff --git a/java/external/src/org/w3c/dom/Comment.java b/java/external/src/org/w3c/dom/Comment.java index 1097921..b04ed4d 100644 --- a/java/external/src/org/w3c/dom/Comment.java +++ b/java/external/src/org/w3c/dom/Comment.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -17,8 +17,14 @@ package org.w3c.dom; * content of a comment, i.e., all the characters between the starting ' * <!--' and ending '-->'. Note that this is * the definition of a comment in XML, and, in practice, HTML, although some - * HTML tools may implement the full SGML comment structure. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + * HTML tools may implement the full SGML comment structure. + *

No lexical check is done on the content of a comment and it is + * therefore possible to have the character sequence "--" + * (double-hyphen) in the content, which is illegal in a comment per section + * 2.5 of [XML 1.0]. The + * presence of this character sequence must generate a fatal error during + * serialization. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Comment extends CharacterData { } diff --git a/java/external/src/org/w3c/dom/DOMConfiguration.java b/java/external/src/org/w3c/dom/DOMConfiguration.java new file mode 100644 index 0000000..7cce160 --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMConfiguration.java @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * 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. + *

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 , 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. + *

Note: Parameters are similar to features and properties used in + * SAX2 [SAX]. + *

The following list of parameters defined in the DOM: + *

+ *
+ * "canonical-form"
+ *
+ *
+ *
true
+ *
[optional] 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. Parameters set to false: "entities", " + * normalize-characters", "cdata-sections". Parameters set to + * true: "namespaces", "namespace-declarations", "well-formed", + * "element-content-whitespace". Other parameters are not changed unless + * explicitly specified in the description of the parameters.
+ *
+ * false
+ *
[required] (default)Do not canonicalize the document.
+ *
+ *
"cdata-sections"
+ *
+ *
+ *
+ * true
+ *
[required] (default)Keep CDATASection nodes in the document.
+ *
false
+ *
[required]Transform CDATASection nodes in the document into + * Text nodes. The new Text node is then combined + * with any adjacent Text node.
+ *
+ *
+ * "check-character-normalization"
+ *
+ *
+ *
true
+ *
[optional] 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.
+ *
false
+ *
[required] (default)Do not check if characters are normalized.
+ *
+ *
"comments"
+ *
+ *
+ *
+ * true
+ *
[required] (default)Keep Comment nodes in the document.
+ *
false
+ *
[required]Discard Comment nodes in the document.
+ *
+ *
+ * "datatype-normalization"
+ *
+ *
+ *
true
+ *
[optional] 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. + *

Note: 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).

+ *
+ * false
+ *
[required] (default) Do not perform schema normalization on the tree.
+ *
+ *
+ * "element-content-whitespace"
+ *
+ *
+ *
true
+ *
[required] (default)Keep all whitespaces in the document.
+ *
false
+ *
[optional] 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.
+ *
+ *
"entities"
+ *
+ *
+ *
+ * true
+ *
[required] (default)Keep EntityReference nodes in the document.
+ *
+ * false
+ *
[required] 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.
+ *
+ *

Note: This parameter does not affect Entity nodes.

+ *
+ * "error-handler"
+ *
[required] 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. + * 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.
+ *
"infoset"
+ *
+ *
+ *
+ * true
+ *
[required]Keep in the document the information defined in the XML Information Set [XML Information Set] + * .This forces the following parameters to false: " + * validate-if-schema", "entities", "datatype-normalization", "cdata-sections + * ".This forces the following parameters to true: " + * namespace-declarations", "well-formed", "element-content-whitespace", " + * comments", "namespaces".Other parameters are not changed unless + * explicitly specified in the description of the parameters. Note that + * querying this parameter with getParameter returns + * true only if the individual parameters specified above are + * appropriately set.
+ *
false
+ *
Setting infoset to + * false has no effect.
+ *
+ *
"namespaces"
+ *
+ *
+ *
+ * true
+ *
[required] (default) Perform the namespace processing as defined in .
+ *
false
+ *
[optional] Do not perform the namespace processing.
+ *
+ *
+ * "namespace-declarations"
+ *
This parameter has no effect if the + * parameter "namespaces" is set to false. + *
+ *
true
+ *
[required] (default) 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] + * .
+ *
false
+ *
[required]Discard all namespace declaration attributes. The namespace prefixes ( + * Node.prefix) are retained even if this parameter is set to + * false.
+ *
+ *
"normalize-characters"
+ *
+ *
+ *
true
+ *
[optional] Fully + * normalized the characters in the document as defined in appendix B of [XML 1.1].
+ *
+ * false
+ *
[required] (default)Do not perform character normalization.
+ *
+ *
"schema-location"
+ *
[optional] 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. 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. If no location has been provided, this + * parameter is null. + *

Note: 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.

+ *
+ * "schema-type"
+ *
[optional] 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. 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. + *

Note: 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.

+ *
"split-cdata-sections"
+ *
+ *
+ *
+ * true
+ *
[required] (default)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.
+ *
+ * false
+ *
[required]Signal an error if a CDATASection contains an + * unrepresentable character.
+ *
+ *
"validate"
+ *
+ *
+ *
true
+ *
[optional] 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. This parameter will reevaluate: + *
    + *
  • Attribute nodes with + * Attr.specified equals to false, as specified in + * the description of the Attr interface; + *
  • + *
  • The value of the + * attribute Text.isElementContentWhitespace for all + * Text nodes; + *
  • + *
  • The value of the attribute + * Attr.isId for all Attr nodes; + *
  • + *
  • The attributes + * Element.schemaTypeInfo and Attr.schemaTypeInfo. + *
  • + *
+ *

Note: "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.

+ *
false
+ *
[required] (default) 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 + * .
+ *
+ *
"validate-if-schema"
+ *
+ *
+ *
true
+ *
[optional]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. + *

Note: "validate-if-schema" and "validate" are mutually + * exclusive, setting one of them to true will set the other + * one to false.

+ *
false
+ *
[required] (default) 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.
+ *
+ *
"well-formed"
+ *
+ *
+ *
true
+ *
[required] (default) Check if all nodes are XML well formed according to the XML version in + * use in Document.xmlVersion: + *
    + *
  • 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; + *
  • + *
  • 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; + *
  • + *
  • 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; + *
  • + *
+ *
+ * false
+ *
[optional] Do not check for XML well-formedness.
+ *
+ *
+ *

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. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +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. + * @exception DOMException + * NOT_FOUND_ERR: Raised when the parameter name is not recognized. + *
NOT_SUPPORTED_ERR: Raised when the parameter name is recognized + * but the requested value cannot be set. + *
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 The 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. + * @exception 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. + */ + public 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. + */ + public DOMStringList getParameterNames(); + +} diff --git a/java/external/src/org/w3c/dom/DOMError.java b/java/external/src/org/w3c/dom/DOMError.java new file mode 100644 index 0000000..37ed7d1 --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMError.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * DOMError is an interface that describes an error. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface DOMError { + // ErrorSeverity + /** + * The severity of the error described by the DOMError is + * warning. A SEVERITY_WARNING will not cause the + * processing to stop, unless DOMErrorHandler.handleError() + * returns false. + */ + public static final short SEVERITY_WARNING = 1; + /** + * The severity of the error described by the DOMError is + * error. A SEVERITY_ERROR may not cause the processing to + * stop if the error can be recovered, unless + * DOMErrorHandler.handleError() returns false. + */ + public static final short SEVERITY_ERROR = 2; + /** + * The severity of the error described by the DOMError is + * fatal error. A SEVERITY_FATAL_ERROR will cause the + * normal processing to stop. The return value of + * DOMErrorHandler.handleError() is ignored unless the + * implementation chooses to continue, in which case the behavior + * becomes undefined. + */ + public static final short SEVERITY_FATAL_ERROR = 3; + + /** + * The severity of the error, either SEVERITY_WARNING, + * SEVERITY_ERROR, or SEVERITY_FATAL_ERROR. + */ + public short getSeverity(); + + /** + * An implementation specific string describing the error that occurred. + */ + public String getMessage(); + + /** + * A DOMString indicating which related data is expected in + * relatedData. Users should refer to the specification of + * the error in order to find its DOMString type and + * relatedData definitions if any. + *

Note: As an example, + * Document.normalizeDocument() does generate warnings when + * the "split-cdata-sections" parameter is in use. Therefore, the method + * generates a SEVERITY_WARNING with type + * "cdata-sections-splitted" and the first + * CDATASection node in document order resulting from the + * split is returned by the relatedData attribute. + */ + public String getType(); + + /** + * The related platform dependent exception if any. + */ + public Object getRelatedException(); + + /** + * The related DOMError.type dependent data if any. + */ + public Object getRelatedData(); + + /** + * The location of the error. + */ + public DOMLocator getLocation(); + +} diff --git a/java/external/src/org/w3c/dom/DOMErrorHandler.java b/java/external/src/org/w3c/dom/DOMErrorHandler.java new file mode 100644 index 0000000..3d4ad2a --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMErrorHandler.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * DOMErrorHandler is a callback interface that the DOM + * implementation can call when reporting errors that happens while + * processing XML data, or when doing some other processing (e.g. validating + * a document). A DOMErrorHandler object can be attached to a + * Document using the "error-handler" on the + * DOMConfiguration interface. If more than one error needs to + * be reported during an operation, the sequence and numbers of the errors + * passed to the error handler are implementation dependent. + *

The application that is using the DOM implementation is expected to + * implement this interface. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface DOMErrorHandler { + /** + * This method is called on the error handler when an error occurs. + *
If an exception is thrown from this method, it is considered to be + * equivalent of returning true. + * @param error The error object that describes the error. This object + * may be reused by the DOM implementation across multiple calls to + * the handleError method. + * @return If the handleError method returns + * false, the DOM implementation should stop the current + * processing when possible. If the method returns true, + * the processing may continue depending on + * DOMError.severity. + */ + public boolean handleError(DOMError error); + +} diff --git a/java/external/src/org/w3c/dom/DOMException.java b/java/external/src/org/w3c/dom/DOMException.java index 16866ce..100f251 100644 --- a/java/external/src/org/w3c/dom/DOMException.java +++ b/java/external/src/org/w3c/dom/DOMException.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -21,13 +21,14 @@ package org.w3c.dom; * NodeList. *

Implementations should raise other exceptions under other circumstances. * For example, implementations should raise an implementation-dependent - * exception if a null argument is passed. + * exception if a null argument is passed when null + * was not expected. *

Some languages and object systems do not support the concept of * exceptions. For such systems, error conditions may be indicated using * native error reporting mechanisms. For some bindings, for example, * methods may return error codes similar to those listed in the * corresponding method descriptions. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public class DOMException extends RuntimeException { public DOMException(short code, String message) { @@ -37,41 +38,40 @@ public class DOMException extends RuntimeException { public short code; // ExceptionCode /** - * If index or size is negative, or greater than the allowed value + * If index or size is negative, or greater than the allowed value. */ public static final short INDEX_SIZE_ERR = 1; /** - * If the specified range of text does not fit into a DOMString + * If the specified range of text does not fit into a + * DOMString. */ public static final short DOMSTRING_SIZE_ERR = 2; /** - * If any node is inserted somewhere it doesn't belong + * If any Node is inserted somewhere it doesn't belong. */ public static final short HIERARCHY_REQUEST_ERR = 3; /** - * If a node is used in a different document than the one that created it - * (that doesn't support it) + * If a Node is used in a different document than the one + * that created it (that doesn't support it). */ public static final short WRONG_DOCUMENT_ERR = 4; /** - * If an invalid or illegal character is specified, such as in a name. See - * production 2 in the XML specification for the definition of a legal - * character, and production 5 for the definition of a legal name - * character. + * If an invalid or illegal character is specified, such as in an XML name. */ public static final short INVALID_CHARACTER_ERR = 5; /** - * If data is specified for a node which does not support data + * If data is specified for a Node which does not support + * data. */ public static final short NO_DATA_ALLOWED_ERR = 6; /** * If an attempt is made to modify an object where modifications are not - * allowed + * allowed. */ public static final short NO_MODIFICATION_ALLOWED_ERR = 7; /** - * If an attempt is made to reference a node in a context where it does - * not exist + * If an attempt is made to reference a Node in a context + * where it does not exist. */ public static final short NOT_FOUND_ERR = 8; /** @@ -81,7 +81,7 @@ public class DOMException extends RuntimeException { public static final short NOT_SUPPORTED_ERR = 9; /** * If an attempt is made to add an attribute that is already in use - * elsewhere + * elsewhere. */ public static final short INUSE_ATTRIBUTE_ERR = 10; /** @@ -112,5 +112,22 @@ public class DOMException extends RuntimeException { * @since DOM Level 2 */ public static final short INVALID_ACCESS_ERR = 15; + /** + * If a call to a method such as insertBefore or + * removeChild would make the Node invalid + * with respect to "partial validity", this exception would be raised + * and the operation would not be done. This code is used in [DOM Level 3 Validation] + * . Refer to this specification for further information. + * @since DOM Level 3 + */ + public static final short VALIDATION_ERR = 16; + /** + * If the type of an object is incompatible with the expected type of the + * parameter associated to the object. + * @since DOM Level 3 + */ + public static final short TYPE_MISMATCH_ERR = 17; + // Added serialVersionUID to preserve binary compatibility + static final long serialVersionUID = 6627732366795969916L; } diff --git a/java/external/src/org/w3c/dom/DOMImplementation.java b/java/external/src/org/w3c/dom/DOMImplementation.java index 6e9a554..5bb71e2 100644 --- a/java/external/src/org/w3c/dom/DOMImplementation.java +++ b/java/external/src/org/w3c/dom/DOMImplementation.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -16,21 +16,14 @@ package org.w3c.dom; * The DOMImplementation interface provides a number of methods * for performing operations that are independent of any particular instance * of the document object model. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface DOMImplementation { /** - * Test if the DOM implementation implements a specific feature. - * @param feature The name of the feature to test (case-insensitive). The - * values used by DOM features are defined throughout the DOM Level 2 - * specifications and listed in the section. The name must be an XML - * name. To avoid possible conflicts, as a convention, names referring - * to features defined outside the DOM specification should be made - * unique. - * @param version This is the version number of the feature to test. In - * Level 2, the string can be either "2.0" or "1.0". If the version is - * not specified, supporting any version of the feature causes the - * method to return true. + * Test if the DOM implementation implements a specific feature and + * version, as specified in . + * @param feature The name of the feature to test. + * @param version This is the version number of the feature to test. * @return true if the feature is implemented in the * specified version, false otherwise. */ @@ -40,9 +33,7 @@ public interface DOMImplementation { /** * Creates an empty DocumentType node. Entity declarations * and notations are not made available. Entity reference expansions and - * default attribute additions do not occur. It is expected that a - * future version of the DOM will provide a way for populating a - * DocumentType. + * default attribute additions do not occur.. * @param qualifiedName The qualified name of the document type to be * created. * @param publicId The external subset public identifier. @@ -50,16 +41,13 @@ public interface DOMImplementation { * @return A new DocumentType node with * Node.ownerDocument set to null. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified qualified name is not + * an XML name according to [XML 1.0]. *
NAMESPACE_ERR: Raised if the qualifiedName is * malformed. - *
NOT_SUPPORTED_ERR: May be raised by DOM implementations which do - * not support the "XML" feature, if they choose not to - * support this method. Other features introduced in the future, by - * the DOM WG or in extensions defined by other groups, may also - * demand support for this method; please consult the definition of - * the feature to see if it requires this method. + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed through the + * Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public DocumentType createDocumentType(String qualifiedName, @@ -70,36 +58,48 @@ public interface DOMImplementation { /** * Creates a DOM Document object of the specified type with its document * element. + *
Note that based on the DocumentType given to create + * the document, the implementation may instantiate specialized + * Document objects that support additional features than + * the "Core", such as "HTML" [DOM Level 2 HTML] + * . On the other hand, setting the DocumentType after the + * document was created makes this very unlikely to happen. + * Alternatively, specialized Document creation methods, + * such as createHTMLDocument [DOM Level 2 HTML] + * , can be used to obtain specific types of Document + * objects. * @param namespaceURI The namespace URI of the document element to - * create. + * create or null. * @param qualifiedName The qualified name of the document element to be - * created. + * created or null. * @param doctype The type of document to be created or null. * When doctype is not null, its * Node.ownerDocument attribute is set to the document * being created. - * @return A new Document object. + * @return A new Document object with its document element. + * If the NamespaceURI, qualifiedName, and + * doctype are null, the returned + * Document is empty with no document element. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified qualified name is not + * an XML name according to [XML 1.0]. *
NAMESPACE_ERR: Raised if the qualifiedName is * malformed, 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" , or if the DOM - * implementation does not support the "XML" feature but - * a non-null namespace URI was provided, since namespaces were - * defined by XML. + * qualifiedName is null and the + * namespaceURI is different from 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] + * , or if the DOM implementation does not support the + * "XML" feature but a non-null namespace URI was + * provided, since namespaces were defined by XML. *
WRONG_DOCUMENT_ERR: Raised if doctype has already * been used with a different document or was created from a different * implementation. - *
NOT_SUPPORTED_ERR: May be raised by DOM implementations which do - * not support the "XML" feature, if they choose not to support this - * method. Other features introduced in the future, by the DOM WG or - * in extensions defined by other groups, may also demand support for - * this method; please consult the definition of the feature to see if - * it requires this method. + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed through the + * Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public Document createDocument(String namespaceURI, @@ -107,4 +107,30 @@ public interface DOMImplementation { DocumentType doctype) throws DOMException; + /** + * This method returns a specialized object which implements the + * specialized APIs of the specified feature and version, as specified + * in . The specialized object may also be obtained by using + * binding-specific casting methods but is not necessarily expected to, + * as discussed in . This method also allow the implementation to + * provide specialized objects which do not support the + * DOMImplementation interface. + * @param feature The name of the feature requested. Note that any plus + * sign "+" prepended to the name of the feature will be ignored since + * it is not significant in the context of this method. + * @param version This is the version number of the feature to test. + * @return Returns an object which implements the specialized APIs of + * the specified feature and version, if any, or null if + * there is no object which implements interfaces associated with that + * feature. If the DOMObject returned by this method + * implements the DOMImplementation interface, it must + * delegate to the primary core DOMImplementation and not + * return results inconsistent with the primary core + * DOMImplementation such as hasFeature, + * getFeature, etc. + * @since DOM Level 3 + */ + public Object getFeature(String feature, + String version); + } diff --git a/java/external/src/org/w3c/dom/DOMImplementationList.java b/java/external/src/org/w3c/dom/DOMImplementationList.java new file mode 100644 index 0000000..18349fd --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMImplementationList.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * The DOMImplementationList interface provides the abstraction + * of an ordered collection of DOM implementations, without defining or + * constraining how this collection is implemented. The items in the + * DOMImplementationList are accessible via an integral index, + * starting from 0. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface DOMImplementationList { + /** + * Returns the indexth item in the collection. If + * index is greater than or equal to the number of + * DOMImplementations in the list, this returns + * null. + * @param index Index into the collection. + * @return The DOMImplementation at the index + * th position in the DOMImplementationList, or + * null if that is not a valid index. + */ + public DOMImplementation item(int index); + + /** + * The number of DOMImplementations in the list. The range + * of valid child node indices is 0 to length-1 inclusive. + */ + public int getLength(); + +} diff --git a/java/external/src/org/w3c/dom/DOMImplementationSource.java b/java/external/src/org/w3c/dom/DOMImplementationSource.java new file mode 100644 index 0000000..3c32c18 --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMImplementationSource.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * This interface permits a DOM implementer to supply one or more + * implementations, based upon requested features and versions, as specified + * in . Each implemented DOMImplementationSource object is + * listed in the binding-specific list of available sources so that its + * DOMImplementation objects are made available. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface DOMImplementationSource { + /** + * A method to request the first DOM implementation that supports the + * specified features. + * @param features A string that specifies which features and versions + * are required. This is a space separated list in which each feature + * is specified by its name optionally followed by a space and a + * version number. This method returns the first item of the list + * returned by getDOMImplementationList. As an example, + * the string "XML 3.0 Traversal +Events 2.0" will + * request a DOM implementation that supports the module "XML" for its + * 3.0 version, a module that support of the "Traversal" module for + * any version, and the module "Events" for its 2.0 version. The + * module "Events" must be accessible using the method + * Node.getFeature() and + * DOMImplementation.getFeature(). + * @return The first DOM implementation that support the desired + * features, or null if this source has none. + */ + public DOMImplementation getDOMImplementation(String features); + + /** + * A method to request a list of DOM implementations that support the + * specified features and versions, as specified in . + * @param features A string that specifies which features and versions + * are required. This is a space separated list in which each feature + * is specified by its name optionally followed by a space and a + * version number. This is something like: "XML 3.0 Traversal +Events + * 2.0" + * @return A list of DOM implementations that support the desired + * features. + */ + public DOMImplementationList getDOMImplementationList(String features); + +} diff --git a/java/external/src/org/w3c/dom/DOMLocator.java b/java/external/src/org/w3c/dom/DOMLocator.java new file mode 100644 index 0000000..fcaaa23 --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMLocator.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * DOMLocator is an interface that describes a location (e.g. + * where an error occurred). + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface DOMLocator { + /** + * The line number this locator is pointing to, or -1 if + * there is no column number available. + */ + public int getLineNumber(); + + /** + * The column number this locator is pointing to, or -1 if + * there is no column number available. + */ + public int getColumnNumber(); + + /** + * The byte offset into the input source this locator is pointing to or + * -1 if there is no byte offset available. + */ + public int getByteOffset(); + + /** + * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], offset into the input source this locator is pointing to or + * -1 if there is no UTF-16 offset available. + */ + public int getUtf16Offset(); + + /** + * The node this locator is pointing to, or null if no node + * is available. + */ + public Node getRelatedNode(); + + /** + * The URI this locator is pointing to, or null if no URI is + * available. + */ + public String getUri(); + +} diff --git a/java/external/src/org/w3c/dom/DOMStringList.java b/java/external/src/org/w3c/dom/DOMStringList.java new file mode 100644 index 0000000..e6c348a --- /dev/null +++ b/java/external/src/org/w3c/dom/DOMStringList.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * 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. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface DOMStringList { + /** + * 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. + */ + 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); + +} diff --git a/java/external/src/org/w3c/dom/Document.java b/java/external/src/org/w3c/dom/Document.java index 79214e0..43ebd4e 100644 --- a/java/external/src/org/w3c/dom/Document.java +++ b/java/external/src/org/w3c/dom/Document.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -22,18 +22,28 @@ package org.w3c.dom; * to create these objects. The Node objects created have a * ownerDocument attribute which associates them with the * Document within whose context they were created. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Document extends Node { /** * The Document Type Declaration (see DocumentType) - * associated with this document. For HTML documents as well as XML - * documents without a document type declaration this returns - * null. The DOM Level 2 does not support editing the - * Document Type Declaration. docType cannot be altered in - * any way, including through the use of methods inherited from the - * Node interface, such as insertNode or - * removeNode. + * associated with this document. For XML documents without a document + * type declaration this returns null. For HTML documents, + * a DocumentType object may be returned, independently of + * the presence or absence of document type declaration in the HTML + * document. + *
This provides direct access to the DocumentType node, + * child node of this Document. This node can be set at + * document creation time and later changed through the use of child + * nodes manipulation methods, such as Node.insertBefore, + * or Node.replaceChild. Note, however, that while some + * implementations may instantiate different types of + * Document objects supporting additional features than the + * "Core", such as "HTML" [DOM Level 2 HTML] + * , based on the DocumentType specified at creation time, + * changing it afterwards is very unlikely to result in a change of the + * features supported. + * @version DOM Level 3 */ public DocumentType getDoctype(); @@ -45,8 +55,7 @@ public interface Document extends Node { /** * This is a convenience attribute that allows direct access to the child - * node that is the root element of the document. For HTML documents, - * this is the element with the tagName "HTML". + * node that is the document element of the document. */ public Element getDocumentElement(); @@ -60,16 +69,18 @@ public interface Document extends Node { *
To create an element with a qualified name and namespace URI, use * the createElementNS method. * @param tagName The name of the element type to instantiate. For XML, - * this is case-sensitive. For HTML, the tagName - * parameter may be provided in any case, but it must be mapped to the - * canonical uppercase form by the DOM implementation. + * this is case-sensitive, otherwise it depends on the + * case-sensitivity of the markup language in use. In that case, the + * name is mapped to the canonical form of that markup by the DOM + * implementation. * @return A new Element object with the * nodeName attribute set to tagName, and * localName, prefix, and * namespaceURI set to null. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified name contains an - * illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML + * name according to the XML version in use specified in the + * Document.xmlVersion attribute. */ public Element createElement(String tagName) throws DOMException; @@ -108,12 +119,19 @@ public interface Document extends Node { /** * Creates a ProcessingInstruction node given the specified * name and data strings. - * @param target The target part of the processing instruction. + * @param target The target part of the processing instruction.Unlike + * Document.createElementNS or + * Document.createAttributeNS, no namespace well-formed + * checking is done on the target name. Applications should invoke + * Document.normalizeDocument() with the parameter " + * namespaces" set to true in order to ensure that the + * target name is namespace well-formed. * @param data The data for the node. * @return The new ProcessingInstruction object. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified target contains an - * illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified target is not an XML + * name according to the XML version in use specified in the + * Document.xmlVersion attribute. *
NOT_SUPPORTED_ERR: Raised if this document is an HTML document. */ public ProcessingInstruction createProcessingInstruction(String target, @@ -132,8 +150,9 @@ public interface Document extends Node { * prefix, and namespaceURI set to * null. The value of the attribute is the empty string. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified name contains an - * illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML + * name according to the XML version in use specified in the + * Document.xmlVersion attribute. */ public Attr createAttribute(String name) throws DOMException; @@ -142,45 +161,58 @@ public interface Document extends Node { * Creates an EntityReference object. In addition, if the * referenced entity is known, the child list of the * EntityReference node is made the same as that of the - * corresponding Entity node.If any descendant of the - * Entity node has an unbound namespace prefix, the - * corresponding descendant of the created EntityReference - * node is also unbound; (its namespaceURI is - * null). The DOM Level 2 does not support any mechanism to - * resolve namespace prefixes. - * @param name The name of the entity to reference. + * corresponding Entity node. + *

Note: If any descendant of the Entity node has + * an unbound namespace prefix, the corresponding descendant of the + * created EntityReference node is also unbound; (its + * namespaceURI is null). The DOM Level 2 and + * 3 do not support any mechanism to resolve namespace prefixes in this + * case. + * @param name The name of the entity to reference.Unlike + * Document.createElementNS or + * Document.createAttributeNS, no namespace well-formed + * checking is done on the entity name. Applications should invoke + * Document.normalizeDocument() with the parameter " + * namespaces" set to true in order to ensure that the + * entity name is namespace well-formed. * @return The new EntityReference object. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified name contains an - * illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML + * name according to the XML version in use specified in the + * Document.xmlVersion attribute. *
NOT_SUPPORTED_ERR: Raised if this document is an HTML document. */ public EntityReference createEntityReference(String name) throws DOMException; /** - * Returns a NodeList of all the Elements with a - * given tag name in the order in which they are encountered in a - * preorder traversal of the Document tree. - * @param tagname The name of the tag to match on. The special value "*" - * matches all tags. + * Returns a NodeList of all the Elements in + * document order with a given tag name and are contained in the + * document. + * @param tagname The name of the tag to match on. The special value "*" + * matches all tags. For XML, the tagname parameter is + * case-sensitive, otherwise it depends on the case-sensitivity of the + * markup language in use. * @return A new NodeList object containing all the matched * Elements. */ public NodeList getElementsByTagName(String tagname); /** - * Imports a node from another document to this document. The returned - * node has no parent; (parentNode is null). - * The source node is not altered or removed from the original document; - * this method creates a new copy of the source node. + * Imports a node from another document to this document, without altering + * or removing the source node from the original document; this method + * creates a new copy of the source node. The returned node has no + * parent; (parentNode is null). *
For all nodes, importing a node creates a node object owned by the * importing document, with attribute values identical to the source * node's nodeName and nodeType, plus the * attributes related to namespaces (prefix, * localName, and namespaceURI). As in the - * cloneNode operation on a Node, the source - * node is not altered. + * cloneNode operation, the source node is not altered. + * User data associated to the imported node is not carried over. + * However, if any UserDataHandlers has been specified + * along with the associated data these handlers will be called with the + * appropriate parameters before this method returns. *
Additional information is copied as appropriate to the * nodeType, attempting to mirror the behavior expected if * a fragment of XML or HTML source was copied from one document to @@ -199,9 +231,11 @@ public interface Document extends Node { * when imported. *

DOCUMENT_FRAGMENT_NODE
*
If the deep option - * was set to true, the descendants of the source element - * are recursively imported and the resulting nodes reassembled to form - * the corresponding subtree. Otherwise, this simply generates an empty + * was set to true, the descendants of the source + * DocumentFragment are recursively imported and the + * resulting nodes reassembled under the imported + * DocumentFragment to form the corresponding subtree. + * Otherwise, this simply generates an empty * DocumentFragment.
*
DOCUMENT_NODE
*
Document @@ -210,12 +244,11 @@ public interface Document extends Node { *
DocumentType * nodes cannot be imported.
*
ELEMENT_NODE
- *
Specified attribute nodes of the - * source element are imported, and the generated Attr - * nodes are attached to the generated Element. Default - * attributes are not copied, though if the document being imported into - * defines default attributes for this element name, those are assigned. - * If the importNode deep parameter was set to + *
Specified attribute nodes of the source element are imported, and the generated + * Attr nodes are attached to the generated + * Element. Default attributes are not copied, though if the document being imported into defines default + * attributes for this element name, those are assigned. If the + * importNode deep parameter was set to * true, the descendants of the source element are * recursively imported and the resulting nodes reassembled to form the * corresponding subtree.
@@ -243,28 +276,37 @@ public interface Document extends Node { * to add these imported nodes to a DocumentType will be * considered for addition to a future release of the DOM.On import, the * publicId and systemId attributes are copied. - * Note that the deep parameter has no effect on - * Notation nodes since they never have any children. + * Note that the deep parameter has no effect on this type + * of nodes since they cannot have any children. *
* PROCESSING_INSTRUCTION_NODE
*
The imported node copies its * target and data values from those of the - * source node.
- *
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
- *
These three - * types of nodes inheriting from CharacterData copy their - * data and length attributes from those of - * the source node.
+ * source node.Note that the deep parameter has no effect + * on this type of nodes since they cannot have any children. + *
TEXT_NODE, + * CDATA_SECTION_NODE, COMMENT_NODE
+ *
These three types of nodes inheriting + * from CharacterData copy their data and + * length attributes from those of the source node.Note + * that the deep parameter has no effect on these types of + * nodes since they cannot have any children.
* * @param importedNode The node to import. * @param deep If true, recursively import the subtree under * the specified node; if false, import only the node - * itself, as explained above. This has no effect on Attr - * , EntityReference, and Notation nodes. + * itself, as explained above. This has no effect on nodes that cannot + * have any children, and on Attr, and + * EntityReference nodes. * @return The imported node that belongs to this Document. * @exception DOMException * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not * supported. + *
INVALID_CHARACTER_ERR: Raised if one of the imported names is not + * an XML name according to the XML version in use specified in the + * Document.xmlVersion attribute. This may happen when + * importing an XML 1.1 [XML 1.1] element + * into an XML 1.0 document, for instance. * @since DOM Level 2 */ public Node importNode(Node importedNode, @@ -273,12 +315,15 @@ public interface Document extends Node { /** * Creates an element of the given qualified name and namespace URI. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have no namespace. * @param namespaceURI The namespace URI of the element to create. * @param qualifiedName The qualified name of the element type to * instantiate. * @return A new Element object with the following * attributes: - * + *
* * * @@ -311,15 +356,18 @@ public interface Document extends Node { * *
AttributeValue
* @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character, per the XML 1.0 specification . - *
NAMESPACE_ERR: Raised if the qualifiedName is - * malformed per the Namespaces in XML specification, 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" . + * INVALID_CHARACTER_ERR: Raised if the specified + * qualifiedName is not an XML name according to the XML + * version in use specified in the Document.xmlVersion + * attribute. + *
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] + * , or if the qualifiedName or its prefix is "xmlns" and + * the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns". *
NOT_SUPPORTED_ERR: Always thrown if the current document does not * support the "XML" feature, since namespaces were * defined by XML. @@ -331,11 +379,15 @@ public interface Document extends Node { /** * Creates an attribute of the given qualified name and namespace URI. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param namespaceURI The namespace URI of the attribute to create. * @param qualifiedName The qualified name of the attribute to * instantiate. * @return A new Attr object with the following attributes: - * + *
* * @@ -374,18 +426,17 @@ public interface Document extends Node { * *
* Attribute
* @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character, per the XML 1.0 specification . - *
NAMESPACE_ERR: Raised if the qualifiedName is - * malformed per the Namespaces in XML specification, if the - * qualifiedName has a prefix and the - * namespaceURI is null, if the - * qualifiedName has a prefix that is "xml" and the - * namespaceURI is different from " - * http://www.w3.org/XML/1998/namespace", or if the - * qualifiedName, or its prefix, is "xmlns" and the - * namespaceURI is different from " - * http://www.w3.org/2000/xmlns/". + * INVALID_CHARACTER_ERR: Raised if the specified + * qualifiedName is not an XML name according to the XML + * version in use specified in the Document.xmlVersion + * attribute. + *
NAMESPACE_ERR: Raised if the qualifiedName is a + * malformed qualified name, if the qualifiedName has a + * prefix and the namespaceURI is null, if + * the qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is "xmlns" and the + * namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns". *
NOT_SUPPORTED_ERR: Always thrown if the current document does not * support the "XML" feature, since namespaces were * defined by XML. @@ -397,10 +448,9 @@ public interface Document extends Node { /** * Returns a NodeList of all the Elements with a - * given local name and namespace URI in the order in which they are - * encountered in a preorder traversal of the Document tree. + * given local name and namespace URI in document order. * @param namespaceURI The namespace URI of the elements to match on. The - * special value "*" matches all namespaces. + * special value "*" matches all namespaces. * @param localName The local name of the elements to match on. The * special value "*" matches all local names. * @return A new NodeList object containing all the matched @@ -411,18 +461,354 @@ public interface Document extends Node { String localName); /** - * Returns the Element whose ID is given by - * elementId. If no such element exists, returns - * null. Behavior is not defined if more than one element - * has this ID. The DOM implementation must have - * information that says which attributes are of type ID. Attributes - * with the name "ID" are not of type ID unless so defined. - * Implementations that do not know whether attributes are of type ID or - * not are expected to return null. + * Returns the Element that has an ID attribute with the + * given value. If no such element exists, this returns null + * . If more than one element has an ID attribute with that value, what + * is returned is undefined. + *
The DOM implementation is expected to use the attribute + * Attr.isId to determine if an attribute is of type ID. + *

Note: Attributes with the name "ID" or "id" are not of type + * ID unless so defined. * @param elementId The unique id value for an element. - * @return The matching element. + * @return The matching element or null if there is none. * @since DOM Level 2 */ public Element getElementById(String elementId); + /** + * An attribute specifying the encoding used for this document at the time + * of the parsing. This is null when it is not known, such + * as when the Document was created in memory. + * @since DOM Level 3 + */ + public String getInputEncoding(); + + /** + * An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when + * unspecified or when it is not known, such as when the + * Document was created in memory. + * @since DOM Level 3 + */ + public String getXmlEncoding(); + + /** + * An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when + * unspecified. + *

Note: No verification is done on the value when setting + * this attribute. Applications should use + * Document.normalizeDocument() with the "validate" + * parameter to verify if the value matches the validity + * constraint for standalone document declaration as defined in [XML 1.0]. + * @since DOM Level 3 + */ + public boolean getXmlStandalone(); + /** + * An attribute specifying, as part of the XML declaration, whether this document is standalone. This is false when + * unspecified. + *

Note: No verification is done on the value when setting + * this attribute. Applications should use + * Document.normalizeDocument() with the "validate" + * parameter to verify if the value matches the validity + * constraint for standalone document declaration as defined in [XML 1.0]. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if this document does not support the + * "XML" feature. + * @since DOM Level 3 + */ + public void setXmlStandalone(boolean xmlStandalone) + throws DOMException; + + /** + * An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if + * this document supports the "XML" feature, the value is + * "1.0". If this document does not support the "XML" + * feature, the value is always null. Changing this + * attribute will affect methods that check for invalid characters in + * XML names. Application should invoke + * Document.normalizeDocument() in order to check for + * invalid characters in the Nodes that are already part of + * this Document. + *
DOM applications may use the + * DOMImplementation.hasFeature(feature, version) method + * with parameter values "XMLVersion" and "1.0" (respectively) to + * determine if an implementation supports [XML 1.0]. DOM + * applications may use the same method with parameter values + * "XMLVersion" and "1.1" (respectively) to determine if an + * implementation supports [XML 1.1]. In both + * cases, in order to support XML, an implementation must also support + * the "XML" feature defined in this specification. Document + * objects supporting a version of the "XMLVersion" feature must not + * raise a NOT_SUPPORTED_ERR exception for the same version + * number when using Document.xmlVersion. + * @since DOM Level 3 + */ + public String getXmlVersion(); + /** + * An attribute specifying, as part of the XML declaration, the version number of this document. If there is no declaration and if + * this document supports the "XML" feature, the value is + * "1.0". If this document does not support the "XML" + * feature, the value is always null. Changing this + * attribute will affect methods that check for invalid characters in + * XML names. Application should invoke + * Document.normalizeDocument() in order to check for + * invalid characters in the Nodes that are already part of + * this Document. + *
DOM applications may use the + * DOMImplementation.hasFeature(feature, version) method + * with parameter values "XMLVersion" and "1.0" (respectively) to + * determine if an implementation supports [XML 1.0]. DOM + * applications may use the same method with parameter values + * "XMLVersion" and "1.1" (respectively) to determine if an + * implementation supports [XML 1.1]. In both + * cases, in order to support XML, an implementation must also support + * the "XML" feature defined in this specification. Document + * objects supporting a version of the "XMLVersion" feature must not + * raise a NOT_SUPPORTED_ERR exception for the same version + * number when using Document.xmlVersion. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the version is set to a value that is + * not supported by this Document or if this document + * does not support the "XML" feature. + * @since DOM Level 3 + */ + public void setXmlVersion(String xmlVersion) + throws DOMException; + + /** + * An attribute specifying whether error checking is enforced or not. When + * set to false, the implementation is free to not test + * every possible error case normally defined on DOM operations, and not + * raise any DOMException on DOM operations or report + * errors while using Document.normalizeDocument(). In case + * of error, the behavior is undefined. This attribute is + * true by default. + * @since DOM Level 3 + */ + public boolean getStrictErrorChecking(); + /** + * An attribute specifying whether error checking is enforced or not. When + * set to false, the implementation is free to not test + * every possible error case normally defined on DOM operations, and not + * raise any DOMException on DOM operations or report + * errors while using Document.normalizeDocument(). In case + * of error, the behavior is undefined. This attribute is + * true by default. + * @since DOM Level 3 + */ + public void setStrictErrorChecking(boolean strictErrorChecking); + + /** + * The location of the document or null if undefined or if + * the Document was created using + * DOMImplementation.createDocument. No lexical checking is + * performed when setting this attribute; this could result in a + * null value returned when using Node.baseURI + * . + *
Beware that when the Document supports the feature + * "HTML" [DOM Level 2 HTML] + * , the href attribute of the HTML BASE element takes precedence over + * this attribute when computing Node.baseURI. + * @since DOM Level 3 + */ + public String getDocumentURI(); + /** + * The location of the document or null if undefined or if + * the Document was created using + * DOMImplementation.createDocument. No lexical checking is + * performed when setting this attribute; this could result in a + * null value returned when using Node.baseURI + * . + *
Beware that when the Document supports the feature + * "HTML" [DOM Level 2 HTML] + * , the href attribute of the HTML BASE element takes precedence over + * this attribute when computing Node.baseURI. + * @since DOM Level 3 + */ + public void setDocumentURI(String documentURI); + + /** + * Attempts to adopt a node from another document to this document. If + * supported, it changes the ownerDocument of the source + * node, its children, as well as the attached attribute nodes if there + * are any. If the source node has a parent it is first removed from the + * child list of its parent. This effectively allows moving a subtree + * from one document to another (unlike importNode() which + * create a copy of the source node instead of moving it). When it + * fails, applications should use Document.importNode() + * instead. Note that if the adopted node is already part of this + * document (i.e. the source and target document are the same), this + * method still has the effect of removing the source node from the + * child list of its parent, if any. The following list describes the + * specifics for each type of node. + *

+ *
ATTRIBUTE_NODE
+ *
The + * ownerElement attribute is set to null and + * the specified flag is set to true on the + * adopted Attr. The descendants of the source + * Attr are recursively adopted.
+ *
DOCUMENT_FRAGMENT_NODE
+ *
The + * descendants of the source node are recursively adopted.
+ *
DOCUMENT_NODE
+ *
+ * Document nodes cannot be adopted.
+ *
DOCUMENT_TYPE_NODE
+ *
+ * DocumentType nodes cannot be adopted.
+ *
ELEMENT_NODE
+ *
Specified attribute nodes of the source element are adopted. Default attributes + * are discarded, though if the document being adopted into defines + * default attributes for this element name, those are assigned. The + * descendants of the source element are recursively adopted.
+ *
ENTITY_NODE
+ *
+ * Entity nodes cannot be adopted.
+ *
ENTITY_REFERENCE_NODE
+ *
Only + * the EntityReference node itself is adopted, the + * descendants are discarded, since the source and destination documents + * might have defined the entity differently. If the document being + * imported into provides a definition for this entity name, its value + * is assigned.
+ *
NOTATION_NODE
+ *
Notation nodes cannot be + * adopted.
+ *
PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE, + * COMMENT_NODE
+ *
These nodes can all be adopted. No specifics.
+ *
+ *

Note: Since it does not create new nodes unlike the + * Document.importNode() method, this method does not raise + * an INVALID_CHARACTER_ERR exception, and applications + * should use the Document.normalizeDocument() method to + * check if an imported name is not an XML name according to the XML + * version in use. + * @param source The node to move into this document. + * @return The adopted node, or null if this operation + * fails, such as when the source node comes from a different + * implementation. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the source node is of type + * DOCUMENT, DOCUMENT_TYPE. + *
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is + * readonly. + * @since DOM Level 3 + */ + public Node adoptNode(Node source) + throws DOMException; + + /** + * The configuration used when Document.normalizeDocument() + * is invoked. + * @since DOM Level 3 + */ + public DOMConfiguration getDomConfig(); + + /** + * This method acts as if the document was going through a save and load + * cycle, putting the document in a "normal" form. As a consequence, + * this method updates the replacement tree of + * EntityReference nodes and normalizes Text + * nodes, as defined in the method Node.normalize(). + *
Otherwise, the actual result depends on the features being set on + * the Document.domConfig object and governing what + * operations actually take place. Noticeably this method could also + * make the document namespace well-formed according to the algorithm + * described in , check the character normalization, remove the + * CDATASection nodes, etc. See + * DOMConfiguration for details. + *

// Keep in the document 
+     * the information defined // in the XML Information Set (Java example) 
+     * DOMConfiguration docConfig = myDocument.getDomConfig(); 
+     * docConfig.setParameter("infoset", Boolean.TRUE); 
+     * myDocument.normalizeDocument();
+ * + *
Mutation events, when supported, are generated to reflect the + * changes occurring on the document. + *
If errors occur during the invocation of this method, such as an + * attempt to update a read-only node or a Node.nodeName + * contains an invalid character according to the XML version in use, + * errors or warnings (DOMError.SEVERITY_ERROR or + * DOMError.SEVERITY_WARNING) will be reported using the + * DOMErrorHandler object associated with the "error-handler + * " parameter. Note this method might also report fatal errors ( + * DOMError.SEVERITY_FATAL_ERROR) if an implementation + * cannot recover from an error. + * @since DOM Level 3 + */ + public void normalizeDocument(); + + /** + * Rename an existing node of type ELEMENT_NODE or + * ATTRIBUTE_NODE. + *
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. + *
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. + *
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. + *
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. + *
In addition, + * + * @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. + * @exception 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. + *
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. + *
WRONG_DOCUMENT_ERR: Raised when the specified node was created + * from a different document than this document. + *
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; + } diff --git a/java/external/src/org/w3c/dom/DocumentFragment.java b/java/external/src/org/w3c/dom/DocumentFragment.java index 6ade30c..8c4531e 100644 --- a/java/external/src/org/w3c/dom/DocumentFragment.java +++ b/java/external/src/org/w3c/dom/DocumentFragment.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -45,8 +45,9 @@ package org.w3c.dom; * useful when the user wishes to create nodes that are siblings; the * DocumentFragment acts as the parent of these nodes so that * the user can use the standard methods from the Node - * interface, such as insertBefore and appendChild. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + * interface, such as Node.insertBefore and + * Node.appendChild. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface DocumentFragment extends Node { } diff --git a/java/external/src/org/w3c/dom/DocumentType.java b/java/external/src/org/w3c/dom/DocumentType.java index 86c312b..6221c7b 100644 --- a/java/external/src/org/w3c/dom/DocumentType.java +++ b/java/external/src/org/w3c/dom/DocumentType.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -19,8 +19,9 @@ package org.w3c.dom; * to the list of entities that are defined for the document, and little * else because the effect of namespaces and the various XML schema efforts * on DTD representation are not clearly understood as of this writing. - *

The DOM Level 2 doesn't support editing DocumentType nodes. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

DOM Level 3 doesn't support editing DocumentType nodes. + * DocumentType nodes are read-only. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface DocumentType extends Node { /** @@ -62,17 +63,19 @@ public interface DocumentType extends Node { public String getPublicId(); /** - * The system identifier of the external subset. + * The system identifier of the external subset. This may be an absolute + * URI or not. * @since DOM Level 2 */ public String getSystemId(); /** * The internal subset as a string, or null if there is none. - * This is does not contain the delimiting square brackets.The actual - * content returned depends on how much information is available to the - * implementation. This may vary depending on various parameters, - * including the XML processor used to build the document. + * This is does not contain the delimiting square brackets. + *

Note: The actual content returned depends on how much + * information is available to the implementation. This may vary + * depending on various parameters, including the XML processor used to + * build the document. * @since DOM Level 2 */ public String getInternalSubset(); diff --git a/java/external/src/org/w3c/dom/Element.java b/java/external/src/org/w3c/dom/Element.java index 614ca87..6a7f7e3 100644 --- a/java/external/src/org/w3c/dom/Element.java +++ b/java/external/src/org/w3c/dom/Element.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -24,22 +24,23 @@ package org.w3c.dom; * Attr object should be retrieved to examine the possibly * fairly complex sub-tree representing the attribute value. On the other * hand, in HTML, where all attributes have simple string values, methods to - * directly access an attribute value can safely be used as a convenience.In - * DOM Level 2, the method normalize is inherited from the - * Node interface where it was moved. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + * directly access an attribute value can safely be used as a convenience. + *

Note: In DOM Level 2, the method normalize is + * inherited from the Node interface where it was moved. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Element extends Node { /** - * The name of the element. For example, in: - *

 <elementExample 
-     * id="demo"> ... </elementExample> , 
- * tagName has - * the value "elementExample". Note that this is - * case-preserving in XML, as are all of the operations of the DOM. The - * HTML DOM returns the tagName of an HTML element in the - * canonical uppercase form, regardless of the case in the source HTML - * document. + * The name of the element. If Node.localName is different + * from null, this attribute is a qualified name. For + * example, in: + *
 <elementExample id="demo"> ... 
+     * </elementExample> , 
+ * tagName has the value + * "elementExample". Note that this is case-preserving in + * XML, as are all of the operations of the DOM. The HTML DOM returns + * the tagName of an HTML element in the canonical + * uppercase form, regardless of the case in the source HTML document. */ public String getTagName(); @@ -68,8 +69,9 @@ public interface Element extends Node { * @param name The name of the attribute to create or alter. * @param value Value to set in string form. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified name contains an - * illegal character. + * INVALID_CHARACTER_ERR: Raised if the specified name is not an XML + * name according to the XML version in use specified in the + * Document.xmlVersion attribute. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. */ public void setAttribute(String name, @@ -77,10 +79,14 @@ public interface Element extends Node { throws DOMException; /** - * Removes an attribute by name. If the removed attribute is known to have - * a default value, an attribute immediately appears containing the - * default value as well as the corresponding namespace URI, local name, - * and prefix when applicable. + * Removes an attribute by name. If a default value for the removed + * attribute is defined in the DTD, a new attribute immediately appears + * with the default value as well as the corresponding namespace URI, + * local name, and prefix when applicable. The implementation may handle + * default values from other schemas similarly but applications should + * use Document.normalizeDocument() to guarantee this + * information is up-to-date. + *
If no attribute with this name is found, this method has no effect. *
To remove an attribute by local name and namespace URI, use the * removeAttributeNS method. * @param name The name of the attribute to remove. @@ -105,7 +111,8 @@ public interface Element extends Node { /** * Adds a new attribute node. If an attribute with that name ( * nodeName) is already present in the element, it is - * replaced by the new one. + * replaced by the new one. Replacing an attribute node by itself has no + * effect. *
To add a new attribute node with a qualified name and namespace * URI, use the setAttributeNodeNS method. * @param newAttr The Attr node to add to the attribute list. @@ -125,10 +132,14 @@ public interface Element extends Node { throws DOMException; /** - * Removes the specified attribute node. If the removed Attr - * has a default value it is immediately replaced. The replacing - * attribute has the same namespace URI and local name, as well as the - * original prefix, when applicable. + * Removes the specified attribute node. If a default value for the + * removed Attr node is defined in the DTD, a new node + * immediately appears with the default value as well as the + * corresponding namespace URI, local name, and prefix when applicable. + * The implementation may handle default values from other schemas + * similarly but applications should use + * Document.normalizeDocument() to guarantee this + * information is up-to-date. * @param oldAttr The Attr node to remove from the attribute * list. * @return The Attr node that was removed. @@ -142,8 +153,7 @@ public interface Element extends Node { /** * Returns a NodeList of all descendant Elements - * with a given tag name, in the order in which they are encountered in - * a preorder traversal of this Element tree. + * with a given tag name, in document order. * @param name The name of the tag to match on. The special value "*" * matches all tags. * @return A list of matching Element nodes. @@ -152,18 +162,23 @@ public interface Element extends Node { /** * Retrieves an attribute value by local name and namespace URI. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param namespaceURI The namespace URI of the attribute to retrieve. * @param localName The local name of the attribute to retrieve. * @return The Attr value as a string, or the empty string * if that attribute does not have a specified or default value. + * @exception DOMException + * NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public String getAttributeNS(String namespaceURI, - String localName); + String localName) + throws DOMException; /** * Adds a new attribute. If an attribute with the same local name and @@ -180,28 +195,31 @@ public interface Element extends Node { * and use setAttributeNodeNS or * setAttributeNode to assign it as the value of an * attribute. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param namespaceURI The namespace URI of the attribute to create or * alter. * @param qualifiedName The qualified name of the attribute to create or * alter. * @param value The value to set in string form. * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified qualified name - * contains an illegal character, per the XML 1.0 specification . + * INVALID_CHARACTER_ERR: Raised if the specified qualified name is not + * an XML name according to the XML version in use specified in the + * Document.xmlVersion attribute. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NAMESPACE_ERR: Raised if the qualifiedName is * malformed per the Namespaces in XML specification, if the * qualifiedName has a prefix and the * namespaceURI is null, if the * qualifiedName has a prefix that is "xml" and the - * namespaceURI is different from " - * http://www.w3.org/XML/1998/namespace", or if the - * qualifiedName, or its prefix, is "xmlns" and the - * namespaceURI is different from " - * http://www.w3.org/2000/xmlns/". - *
NOT_SUPPORTED_ERR: Always thrown if the current document does not - * support the "XML" feature, since namespaces were - * defined by XML. + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace", if the qualifiedName or its prefix is "xmlns" and the + * namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the qualifiedName nor its prefix is "xmlns". + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public void setAttributeNS(String namespaceURI, @@ -210,18 +228,27 @@ public interface Element extends Node { throws DOMException; /** - * Removes an attribute by local name and namespace URI. If the removed - * attribute has a default value it is immediately replaced. The - * replacing attribute has the same namespace URI and local name, as - * well as the original prefix. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + * Removes an attribute by local name and namespace URI. If a default + * value for the removed attribute is defined in the DTD, a new + * attribute immediately appears with the default value as well as the + * corresponding namespace URI, local name, and prefix when applicable. + * The implementation may handle default values from other schemas + * similarly but applications should use + * Document.normalizeDocument() to guarantee this + * information is up-to-date. + *
If no attribute with this local name and namespace URI is found, + * this method has no effect. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param namespaceURI The namespace URI of the attribute to remove. * @param localName The local name of the attribute to remove. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public void removeAttributeNS(String namespaceURI, @@ -230,24 +257,33 @@ public interface Element extends Node { /** * Retrieves an Attr node by local name and namespace URI. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param namespaceURI The namespace URI of the attribute to retrieve. * @param localName The local name of the attribute to retrieve. * @return The Attr node with the specified attribute local * name and namespace URI or null if there is no such * attribute. + * @exception DOMException + * NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public Attr getAttributeNodeNS(String namespaceURI, - String localName); + String localName) + throws DOMException; /** * Adds a new attribute. If an attribute with that local name and that * namespace URI is already present in the element, it is replaced by - * the new one. + * the new one. Replacing an attribute node by itself has no effect. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param newAttr The Attr node to add to the attribute list. * @return If the newAttr attribute replaces an existing * attribute with the same local name and namespace URI, the replaced @@ -261,9 +297,9 @@ public interface Element extends Node { * attribute of another Element object. The DOM user must * explicitly clone Attr nodes to re-use them in other * elements. - *
NOT_SUPPORTED_ERR: Always thrown if the current document does not - * support the "XML" feature, since namespaces were - * defined by XML. + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public Attr setAttributeNodeNS(Attr newAttr) @@ -272,22 +308,22 @@ public interface Element extends Node { /** * Returns a NodeList of all the descendant * Elements with a given local name and namespace URI in - * the order in which they are encountered in a preorder traversal of - * this Element tree. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + * document order. * @param namespaceURI The namespace URI of the elements to match on. The * special value "*" matches all namespaces. * @param localName The local name of the elements to match on. The * special value "*" matches all local names. * @return A new NodeList object containing all the matched * Elements. + * @exception DOMException + * NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public NodeList getElementsByTagNameNS(String namespaceURI, - String localName); + String localName) + throws DOMException; /** * Returns true when an attribute with a given name is @@ -305,18 +341,99 @@ public interface Element extends Node { * Returns true when an attribute with a given local name and * namespace URI is specified on this element or has a default value, * false otherwise. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + *
Per [XML Namespaces] + * , applications must use the value null as the + * namespaceURI parameter for methods if they wish to have + * no namespace. * @param namespaceURI The namespace URI of the attribute to look for. * @param localName The local name of the attribute to look for. * @return true if an attribute with the given local name * and namespace URI is specified or has a default value on this * element, false otherwise. + * @exception DOMException + * NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed + * through the Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public boolean hasAttributeNS(String namespaceURI, - String localName); + String localName) + throws DOMException; + + /** + * The type information associated with this element. + * @since DOM Level 3 + */ + public TypeInfo getSchemaTypeInfo(); + + /** + * If the parameter isId is true, this method + * declares the specified attribute to be a user-determined ID attribute + * . This affects the value of Attr.isId and the behavior + * of Document.getElementById, but does not change any + * schema that may be in use, in particular this does not affect the + * Attr.schemaTypeInfo of the specified Attr + * node. Use the value false for the parameter + * isId to undeclare an attribute for being a + * user-determined ID attribute. + *
To specify an attribute by local name and namespace URI, use the + * setIdAttributeNS method. + * @param name The name of the attribute. + * @param isId Whether the attribute is a of type ID. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NOT_FOUND_ERR: Raised if the specified node is not an attribute + * of this element. + * @since DOM Level 3 + */ + public void setIdAttribute(String name, + boolean isId) + throws DOMException; + + /** + * If the parameter isId is true, this method + * declares the specified attribute to be a user-determined ID attribute + * . This affects the value of Attr.isId and the behavior + * of Document.getElementById, but does not change any + * schema that may be in use, in particular this does not affect the + * Attr.schemaTypeInfo of the specified Attr + * node. Use the value false for the parameter + * isId to undeclare an attribute for being a + * user-determined ID attribute. + * @param namespaceURI The namespace URI of the attribute. + * @param localName The local name of the attribute. + * @param isId Whether the attribute is a of type ID. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NOT_FOUND_ERR: Raised if the specified node is not an attribute + * of this element. + * @since DOM Level 3 + */ + public void setIdAttributeNS(String namespaceURI, + String localName, + boolean isId) + throws DOMException; + + /** + * If the parameter isId is true, this method + * declares the specified attribute to be a user-determined ID attribute + * . This affects the value of Attr.isId and the behavior + * of Document.getElementById, but does not change any + * schema that may be in use, in particular this does not affect the + * Attr.schemaTypeInfo of the specified Attr + * node. Use the value false for the parameter + * isId to undeclare an attribute for being a + * user-determined ID attribute. + * @param idAttr The attribute node. + * @param isId Whether the attribute is a of type ID. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NOT_FOUND_ERR: Raised if the specified node is not an attribute + * of this element. + * @since DOM Level 3 + */ + public void setIdAttributeNode(Attr idAttr, + boolean isId) + throws DOMException; } diff --git a/java/external/src/org/w3c/dom/Entity.java b/java/external/src/org/w3c/dom/Entity.java index 11bd0df..f621c33 100644 --- a/java/external/src/org/w3c/dom/Entity.java +++ b/java/external/src/org/w3c/dom/Entity.java @@ -1,22 +1,20 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; /** - * This interface represents an entity, either parsed or unparsed, in an XML - * document. Note that this models the entity itself not the entity - * declaration. Entity declaration modeling has been left for a - * later Level of the DOM specification. + * This interface represents a known entity, either parsed or unparsed, in an + * XML document. Note that this models the entity itself not the entity declaration. *

The nodeName attribute that is inherited from * Node contains the name of the entity. *

An XML processor may choose to completely expand entities before the @@ -24,38 +22,37 @@ package org.w3c.dom; * EntityReference nodes in the document tree. *

XML does not mandate that a non-validating XML processor read and * process entity declarations made in the external subset or declared in - * external parameter entities. This means that parsed entities declared in - * the external subset need not be expanded by some classes of applications, - * and that the replacement value of the entity may not be available. When - * the replacement value is available, the corresponding Entity - * node's child list represents the structure of that replacement text. - * Otherwise, the child list is empty. - *

The DOM Level 2 does not support editing Entity nodes; if a + * parameter entities. This means that parsed entities declared in the + * external subset need not be expanded by some classes of applications, and + * that the replacement text of the entity may not be available. When the + * replacement text is available, the corresponding Entity node's child list + * represents the structure of that replacement value. Otherwise, the child + * list is empty. + *

DOM Level 3 does not support editing Entity nodes; if a * user wants to make changes to the contents of an Entity, * every related EntityReference node has to be replaced in the * structure model by a clone of the Entity's contents, and * then the desired changes must be made to each of those clones instead. * Entity nodes and all their descendants are readonly. - *

An Entity node does not have any parent.If the entity - * contains an unbound namespace prefix, the namespaceURI of - * the corresponding node in the Entity node subtree is - * null. The same is true for EntityReference - * nodes that refer to this entity, when they are created using the - * createEntityReference method of the Document - * interface. The DOM Level 2 does not support any mechanism to resolve - * namespace prefixes. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

An Entity node does not have any parent. + *

Note: If the entity contains an unbound namespace prefix, the + * namespaceURI of the corresponding node in the + * Entity node subtree is null. The same is true + * for EntityReference nodes that refer to this entity, when + * they are created using the createEntityReference method of + * the Document interface. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Entity extends Node { /** - * The public identifier associated with the entity, if specified. If the - * public identifier was not specified, this is null. + * The public identifier associated with the entity if specified, and + * null otherwise. */ public String getPublicId(); /** - * The system identifier associated with the entity, if specified. If the - * system identifier was not specified, this is null. + * The system identifier associated with the entity if specified, and + * null otherwise. This may be an absolute URI or not. */ public String getSystemId(); @@ -65,4 +62,29 @@ public interface Entity extends Node { */ public String getNotationName(); + /** + * An attribute specifying the encoding used for this entity at the time + * of parsing, when it is an external parsed entity. This is + * null if it an entity from the internal subset or if it + * is not known. + * @since DOM Level 3 + */ + public String getInputEncoding(); + + /** + * An attribute specifying, as part of the text declaration, the encoding + * of this entity, when it is an external parsed entity. This is + * null otherwise. + * @since DOM Level 3 + */ + public String getXmlEncoding(); + + /** + * An attribute specifying, as part of the text declaration, the version + * number of this entity, when it is an external parsed entity. This is + * null otherwise. + * @since DOM Level 3 + */ + public String getXmlVersion(); + } diff --git a/java/external/src/org/w3c/dom/EntityReference.java b/java/external/src/org/w3c/dom/EntityReference.java index ff3cf9d..b42b091 100644 --- a/java/external/src/org/w3c/dom/EntityReference.java +++ b/java/external/src/org/w3c/dom/EntityReference.java @@ -1,39 +1,43 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; /** - * EntityReference objects may be inserted into the structure - * model when an entity reference is in the source document, or when the - * user wishes to insert an entity reference. Note that character references - * and references to predefined entities are considered to be expanded by - * the HTML or XML processor so that characters are represented by their - * Unicode equivalent rather than by an entity reference. Moreover, the XML - * processor may completely expand references to entities while building the - * structure model, instead of providing EntityReference - * objects. If it does provide such objects, then for a given - * EntityReference node, it may be that there is no - * Entity node representing the referenced entity. If such an - * Entity exists, then the subtree of the - * EntityReference node is in general a copy of the - * Entity node subtree. However, this may not be true when an - * entity contains an unbound namespace prefix. In such a case, because the - * namespace prefix resolution depends on where the entity reference is, the - * descendants of the EntityReference node may be bound to - * different namespace URIs. + * EntityReference nodes may be used to represent an entity + * reference in the tree. Note that character references and references to + * predefined entities are considered to be expanded by the HTML or XML + * processor so that characters are represented by their Unicode equivalent + * rather than by an entity reference. Moreover, the XML processor may + * completely expand references to entities while building the + * Document, instead of providing EntityReference + * nodes. If it does provide such nodes, then for an + * EntityReference node that represents a reference to a known + * entity an Entity exists, and the subtree of the + * EntityReference node is a copy of the Entity + * node subtree. However, the latter may not be true when an entity contains + * an unbound namespace prefix. In such a case, because the namespace prefix + * resolution depends on where the entity reference is, the descendants of + * the EntityReference node may be bound to different namespace + * URIs. When an EntityReference node represents a reference to + * an unknown entity, the node has no children and its replacement value, + * when used by Attr.value for example, is empty. *

As for Entity nodes, EntityReference nodes and * all their descendants are readonly. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

Note: EntityReference nodes may cause element + * content and attribute value normalization problems when, such as in XML + * 1.0 and XML Schema, the normalization is performed after entity reference + * are expanded. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface EntityReference extends Node { } diff --git a/java/external/src/org/w3c/dom/NameList.java b/java/external/src/org/w3c/dom/NameList.java new file mode 100644 index 0000000..10caa90 --- /dev/null +++ b/java/external/src/org/w3c/dom/NameList.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * The NameList interface provides the abstraction of an ordered + * collection of parallel pairs of name and namespace values (which could be + * null values), without defining or constraining how this collection is + * implemented. The items in the NameList are accessible via an + * integral index, starting from 0. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface NameList { + /** + * Returns the indexth name item in the collection. + * @param index Index into the collection. + * @return The name at the indexth position in the + * NameList, or null if there is no name for + * the specified index or if the index is out of range. + */ + public String getName(int index); + + /** + * Returns the indexth namespaceURI item in the collection. + * @param index Index into the collection. + * @return The namespace URI at the indexth position in the + * NameList, or null if there is no name for + * the specified index or if the index is out of range. + */ + public String getNamespaceURI(int index); + + /** + * The number of pairs (name and namespaceURI) in the list. The range of + * valid child node indices is 0 to length-1 inclusive. + */ + public int getLength(); + + /** + * Test if a name is part of this NameList. + * @param str The name to look for. + * @return true if the name has been found, + * false otherwise. + */ + public boolean contains(String str); + + /** + * Test if the pair namespaceURI/name is part of this + * NameList. + * @param namespaceURI The namespace URI to look for. + * @param name The name to look for. + * @return true if the pair namespaceURI/name has been + * found, false otherwise. + */ + public boolean containsNS(String namespaceURI, + String name); + +} diff --git a/java/external/src/org/w3c/dom/NamedNodeMap.java b/java/external/src/org/w3c/dom/NamedNodeMap.java index 8437366..ad1e67b 100644 --- a/java/external/src/org/w3c/dom/NamedNodeMap.java +++ b/java/external/src/org/w3c/dom/NamedNodeMap.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -22,7 +22,7 @@ package org.w3c.dom; * convenient enumeration of the contents of a NamedNodeMap, * and does not imply that the DOM specifies an order to these Nodes. *

NamedNodeMap objects in the DOM are live. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface NamedNodeMap { /** @@ -37,7 +37,7 @@ public interface NamedNodeMap { /** * Adds a node using its nodeName attribute. If a node with * that name is already present in this map, it is replaced by the new - * one. + * one. Replacing a node by itself has no effect. *
As the nodeName attribute is used to derive the name * which the node must be stored under, multiple nodes of certain types * (those that have a "special" string value) cannot be stored as the @@ -100,25 +100,32 @@ public interface NamedNodeMap { /** * Retrieves a node specified by local name and namespace URI. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + *
Per [XML Namespaces] + * , applications must use the value null as the namespaceURI parameter + * for methods if they wish to have no namespace. * @param namespaceURI The namespace URI of the node to retrieve. * @param localName The local name of the node to retrieve. * @return A Node (of any type) with the specified local * name and namespace URI, or null if they do not * identify any node in this map. + * @exception DOMException + * NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed through the + * Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public Node getNamedItemNS(String namespaceURI, - String localName); + String localName) + throws DOMException; /** * Adds a node using its namespaceURI and * localName. If a node with that namespace URI and that * local name is already present in this map, it is replaced by the new - * one. + * one. Replacing a node by itself has no effect. + *
Per [XML Namespaces] + * , applications must use the value null as the namespaceURI parameter + * for methods if they wish to have no namespace. * @param arg A node to store in this map. The node will later be * accessible using the value of its namespaceURI and * localName attributes. @@ -138,9 +145,9 @@ public interface NamedNodeMap { * to insert something other than an Attr node into an Element's map * of attributes, or a non-Entity node into the DocumentType's map of * Entities. - *
NOT_SUPPORTED_ERR: Always thrown if the current document does not - * support the "XML" feature, since namespaces were - * defined by XML. + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed through the + * Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public Node setNamedItemNS(Node arg) @@ -153,10 +160,9 @@ public interface NamedNodeMap { * attribute of the Node interface. If so, an attribute * immediately appears containing the default value as well as the * corresponding namespace URI, local name, and prefix when applicable. - *
Documents which do not support the "XML" feature will permit only - * the DOM Level 1 calls for creating/setting elements and attributes. - * Hence, if you specify a non-null namespace URI, these DOMs will never - * find a matching node. + *
Per [XML Namespaces] + * , applications must use the value null as the namespaceURI parameter + * for methods if they wish to have no namespace. * @param namespaceURI The namespace URI of the node to remove. * @param localName The local name of the node to remove. * @return The node removed from this map if a node with such a local @@ -165,6 +171,9 @@ public interface NamedNodeMap { * NOT_FOUND_ERR: Raised if there is no node with the specified * namespaceURI and localName in this map. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + *
NOT_SUPPORTED_ERR: May be raised if the implementation does not + * support the feature "XML" and the language exposed through the + * Document does not support XML Namespaces (such as [HTML 4.01]). * @since DOM Level 2 */ public Node removeNamedItemNS(String namespaceURI, diff --git a/java/external/src/org/w3c/dom/Node.java b/java/external/src/org/w3c/dom/Node.java index 78987cb..989d49a 100644 --- a/java/external/src/org/w3c/dom/Node.java +++ b/java/external/src/org/w3c/dom/Node.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -32,7 +32,7 @@ package org.w3c.dom; *

The values of nodeName, * nodeValue, and attributes vary according to the * node type as follows: - * + *
* * * @@ -40,87 +40,98 @@ package org.w3c.dom; * * * - * - * - * - * + * + * + * + * * * - * - * + * * + * - * + * * * - * - * - * - * - * - * - * - * - * - * - * - * - * + * * - * - * + * "#comment" + * + * * * - * - * + * * - * + * "#document" + * + * * * - * - * - * - * + * + * + * + * * * - * + * + * + * + * + * + * + * + * + * + * + * + * + * * - * - * + * + * * * - * + * * - * - * - * - * - * - * - * * + * null + * * * - * - * - * - * + * + * + * + * * * - * + * + * + * + * + * + * + * * - * - * + * + * * *
InterfacenodeNameattributes
Attrname of - * attributevalue of attributenull + * Attrsame as Attr.namesame as + * Attr.valuenull
CDATASection"#cdata-section"CDATASection + * "#cdata-section"same as CharacterData.data, the * content of the CDATA Sectionnullnull
Comment"#comment"content of - * the commentnull
Document"#document"nullnull
DocumentFragmentComment - * "#document-fragment"nullnullsame as CharacterData.data, the + * content of the commentnull
DocumentTypedocument type nameDocument - * nullnullnullnull
Elementtag namenullNamedNodeMap + * DocumentFragment"#document-fragment" + * nullnull
EntityDocumentTypesame as + * DocumentType.namenullnull
+ * Elementsame as Element.tagNamenull + * NamedNodeMap
Entityentity namenullnullnull + * null
- * EntityReferenceEntityReferencename of entity referencednullnull
Notationnotation namenull - * nullnull
ProcessingInstructiontargetentire content excluding the targetnullNotationnotation name + * nullnull
TextProcessingInstructionsame + * as ProcessingInstruction.targetsame as + * ProcessingInstruction.datanull
Text * "#text"content of the text nodenullsame as CharacterData.data, the content + * of the text nodenull
- *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Node { // NodeType @@ -180,28 +191,25 @@ public interface Node { /** * The value of this node, depending on its type; see the table above. - * When it is defined to be null, setting it has no effect. - * @exception DOMException - * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * When it is defined to be null, setting it has no effect, + * including if the node is read-only. * @exception DOMException * DOMSTRING_SIZE_ERR: Raised when it would return more characters than * fit in a DOMString variable on the implementation * platform. */ public String getNodeValue() - throws DOMException; + throws DOMException; /** * The value of this node, depending on its type; see the table above. - * When it is defined to be null, setting it has no effect. + * When it is defined to be null, setting it has no effect, + * including if the node is read-only. * @exception DOMException - * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. - * @exception DOMException - * DOMSTRING_SIZE_ERR: Raised when it would return more characters than - * fit in a DOMString variable on the implementation - * platform. + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if + * it is not defined to be null. */ public void setNodeValue(String nodeValue) - throws DOMException; + throws DOMException; /** * A code representing the type of the underlying object, as defined above. @@ -214,7 +222,7 @@ public interface Node { * Entity, and Notation may have a parent. * However, if a node has just been created and not yet added to the * tree, or if it has been removed from the tree, this is - * null. + * null. */ public Node getParentNode(); @@ -261,7 +269,7 @@ public interface Node { * this node is a Document or a DocumentType * which is not used with any Document yet, this is * null. - * @since DOM Level 2 + * @version DOM Level 2 */ public Document getOwnerDocument(); @@ -273,6 +281,8 @@ public interface Node { * all of its children are inserted, in the same order, before * refChild. If the newChild is already in the * tree, it is first removed. + *

Note: Inserting a node before itself is implementation + * dependent. * @param newChild The node to insert. * @param refChild The reference node, i.e., the node before which the * new node must be inserted. @@ -281,13 +291,20 @@ public interface Node { * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not * allow children of the type of the newChild node, or if * the node to insert is one of this node's ancestors or this node - * itself. + * itself, or if this node is of type Document and the + * DOM application attempts to insert a second + * DocumentType or Element node. *
WRONG_DOCUMENT_ERR: Raised if newChild was created * from a different document than the one that created this node. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or * if the parent of the node being inserted is readonly. *
NOT_FOUND_ERR: Raised if refChild is not a child of * this node. + *
NOT_SUPPORTED_ERR: if this node is of type Document, + * this exception might be raised if the DOM implementation doesn't + * support the insertion of a DocumentType or + * Element node. + * @version DOM Level 3 */ public Node insertBefore(Node newChild, Node refChild) @@ -301,6 +318,8 @@ public interface Node { * DocumentFragment children, which are inserted in the * same order. If the newChild is already in the tree, it * is first removed. + *

Note: Replacing a node with itself is implementation + * dependent. * @param newChild The new node to put in the child list. * @param oldChild The node being replaced in the list. * @return The node replaced. @@ -308,13 +327,21 @@ public interface Node { * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not * allow children of the type of the newChild node, or if * the node to put in is one of this node's ancestors or this node - * itself. + * itself, or if this node is of type Document and the + * result of the replacement operation would add a second + * DocumentType or Element on the + * Document node. *
WRONG_DOCUMENT_ERR: Raised if newChild was created * from a different document than the one that created this node. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of * the new node is readonly. *
NOT_FOUND_ERR: Raised if oldChild is not a child of * this node. + *
NOT_SUPPORTED_ERR: if this node is of type Document, + * this exception might be raised if the DOM implementation doesn't + * support the replacement of the DocumentType child or + * Element child. + * @version DOM Level 3 */ public Node replaceChild(Node newChild, Node oldChild) @@ -329,6 +356,11 @@ public interface Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if oldChild is not a child of * this node. + *
NOT_SUPPORTED_ERR: if this node is of type Document, + * this exception might be raised if the DOM implementation doesn't + * support the removal of the DocumentType child or the + * Element child. + * @version DOM Level 3 */ public Node removeChild(Node oldChild) throws DOMException; @@ -345,35 +377,52 @@ public interface Node { * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not * allow children of the type of the newChild node, or if * the node to append is one of this node's ancestors or this node - * itself. + * itself, or if this node is of type Document and the + * DOM application attempts to append a second + * DocumentType or Element node. *
WRONG_DOCUMENT_ERR: Raised if newChild was created * from a different document than the one that created this node. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or * if the previous parent of the node being inserted is readonly. + *
NOT_SUPPORTED_ERR: if the newChild node is a child + * of the Document node, this exception might be raised + * if the DOM implementation doesn't support the removal of the + * DocumentType child or Element child. + * @version DOM Level 3 */ public Node appendChild(Node newChild) throws DOMException; /** * Returns whether this node has any children. - * @return true if this node has any children, + * @return Returns true if this node has any children, * false otherwise. */ public boolean hasChildNodes(); /** * Returns a duplicate of this node, i.e., serves as a generic copy - * constructor for nodes. The duplicate node has no parent; ( - * parentNode is null.). + * constructor for nodes. The duplicate node has no parent ( + * parentNode is null) and no user data. User + * data associated to the imported node is not carried over. However, if + * any UserDataHandlers has been specified along with the + * associated data these handlers will be called with the appropriate + * parameters before this method returns. *
Cloning an Element copies all attributes and their * values, including those generated by the XML processor to represent - * defaulted attributes, but this method does not copy any text it - * contains unless it is a deep clone, since the text is contained in a - * child Text node. Cloning an Attribute - * directly, as opposed to be cloned as part of an Element - * cloning operation, returns a specified attribute ( - * specified is true). Cloning any other type - * of node simply returns a copy of this node. + * defaulted attributes, but this method does not copy any children it + * contains unless it is a deep clone. This includes text contained in + * an the Element since the text is contained in a child + * Text node. Cloning an Attr directly, as + * opposed to be cloned as part of an Element cloning + * operation, returns a specified attribute (specified is + * true). Cloning an Attr always clones its + * children, since they represent its value, no matter whether this is a + * deep clone or not. Cloning an EntityReference + * automatically constructs its subtree if a corresponding + * Entity is available, no matter whether this is a deep + * clone or not. Cloning any other type of node simply returns a copy of + * this node. *
Note that cloning an immutable subtree results in a mutable copy, * but the children of an EntityReference clone are readonly * . In addition, clones of unspecified Attr nodes are @@ -388,7 +437,7 @@ public interface Node { public Node cloneNode(boolean deep); /** - * Puts all Text nodes in the full depth of the sub-tree + * Puts all Text nodes in the full depth of the sub-tree * underneath this Node, including attribute nodes, into a * "normal" form where only structure (e.g., elements, comments, * processing instructions, CDATA sections, and entity references) @@ -396,25 +445,26 @@ public interface Node { * Text nodes nor empty Text nodes. This can * be used to ensure that the DOM view of a document is the same as if * it were saved and re-loaded, and is useful when operations (such as - * XPointer lookups) that depend on a particular document tree - * structure are to be used.In cases where the document contains + * XPointer [XPointer] + * lookups) that depend on a particular document tree structure are to + * be used. If the parameter "normalize-characters" of the + * DOMConfiguration object attached to the + * Node.ownerDocument is true, this method + * will also fully normalize the characters of the Text + * nodes. + *

Note: In cases where the document contains * CDATASections, the normalize operation alone may not be * sufficient, since XPointers do not differentiate between * Text nodes and CDATASection nodes. - * @since DOM Level 2 + * @version DOM Level 3 */ public void normalize(); /** - * Tests whether the DOM implementation implements a specific feature and - * that feature is supported by this node. - * @param feature The name of the feature to test. This is the same name - * which can be passed to the method hasFeature on - * DOMImplementation. - * @param version This is the version number of the feature to test. In - * Level 2, version 1, this is the string "2.0". If the version is not - * specified, supporting any version of the feature will cause the - * method to return true. + * Tests whether the DOM implementation implements a specific feature and + * that feature is supported by this node, as specified in . + * @param feature The name of the feature to test. + * @param version This is the version number of the feature to test. * @return Returns true if the specified feature is * supported on this node, false otherwise. * @since DOM Level 2 @@ -424,29 +474,33 @@ public interface Node { /** * The namespace URI of this node, or null if it is - * unspecified. + * unspecified (see ). *
This is not a computed value that is the result of a namespace * lookup based on an examination of the namespace declarations in * scope. It is merely the namespace URI given at creation time. *
For nodes of any type other than ELEMENT_NODE and * ATTRIBUTE_NODE and nodes created with a DOM Level 1 - * method, such as createElement from the - * Document interface, this is always null.Per - * the Namespaces in XML Specification an attribute does not inherit - * its namespace from the element it is attached to. If an attribute is - * not explicitly given a namespace, it simply has no namespace. + * method, such as Document.createElement(), this is always + * null. + *

Note: Per the Namespaces in XML Specification [XML Namespaces] + * an attribute does not inherit its namespace from the element it is + * attached to. If an attribute is not explicitly given a namespace, it + * simply has no namespace. * @since DOM Level 2 */ public String getNamespaceURI(); /** * The namespace prefix of this node, or null if it is - * unspecified. + * unspecified. When it is defined to be null, setting it + * has no effect, including if the node is read-only. *
Note that setting this attribute, when permitted, changes the * nodeName attribute, which holds the qualified name, as * well as the tagName and name attributes of * the Element and Attr interfaces, when * applicable. + *
Setting the prefix to null makes it unspecified, + * setting it to an empty string is implementation dependent. *
Note also that changing the prefix of an attribute that is known to * have a default value, does not make a new attribute with the default * value and the original prefix appear, since the @@ -455,30 +509,20 @@ public interface Node { * ATTRIBUTE_NODE and nodes created with a DOM Level 1 * method, such as createElement from the * Document interface, this is always null. - * @exception DOMException - * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an - * illegal character, per the XML 1.0 specification . - *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. - *
NAMESPACE_ERR: Raised if the specified prefix is - * malformed per the Namespaces in XML specification, if the - * namespaceURI of this node is null, if the - * specified prefix is "xml" and the namespaceURI of this - * node is different from "http://www.w3.org/XML/1998/namespace", if - * this node is an attribute and the specified prefix is "xmlns" and - * the namespaceURI of this node is different from " - * http://www.w3.org/2000/xmlns/", or if this node is an attribute and - * the qualifiedName of this node is "xmlns" . * @since DOM Level 2 */ public String getPrefix(); /** * The namespace prefix of this node, or null if it is - * unspecified. + * unspecified. When it is defined to be null, setting it + * has no effect, including if the node is read-only. *
Note that setting this attribute, when permitted, changes the * nodeName attribute, which holds the qualified name, as * well as the tagName and name attributes of * the Element and Attr interfaces, when * applicable. + *
Setting the prefix to null makes it unspecified, + * setting it to an empty string is implementation dependent. *
Note also that changing the prefix of an attribute that is known to * have a default value, does not make a new attribute with the default * value and the original prefix appear, since the @@ -489,17 +533,18 @@ public interface Node { * Document interface, this is always null. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an - * illegal character, per the XML 1.0 specification . + * illegal character according to the XML version in use specified in + * the Document.xmlVersion attribute. *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NAMESPACE_ERR: Raised if the specified prefix is * malformed per the Namespaces in XML specification, if the * namespaceURI of this node is null, if the * specified prefix is "xml" and the namespaceURI of this - * node is different from "http://www.w3.org/XML/1998/namespace", if - * this node is an attribute and the specified prefix is "xmlns" and - * the namespaceURI of this node is different from " - * http://www.w3.org/2000/xmlns/", or if this node is an attribute and - * the qualifiedName of this node is "xmlns" . + * node is different from " + * http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and + * the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of + * this node is "xmlns" [XML Namespaces] + * . * @since DOM Level 2 */ public void setPrefix(String prefix) @@ -509,18 +554,347 @@ public interface Node { * Returns the local part of the qualified name of this node. *
For nodes of any type other than ELEMENT_NODE and * ATTRIBUTE_NODE and nodes created with a DOM Level 1 - * method, such as createElement from the - * Document interface, this is always null. + * method, such as Document.createElement(), this is always + * null. * @since DOM Level 2 */ public String getLocalName(); /** * Returns whether this node (if it is an element) has any attributes. - * @return true if this node has any attributes, + * @return Returns true if this node has any attributes, * false otherwise. * @since DOM Level 2 */ public boolean hasAttributes(); + /** + * The absolute base URI of this node or null if the + * implementation wasn't able to obtain an absolute URI. This value is + * computed as described in . However, when the Document + * supports the feature "HTML" [DOM Level 2 HTML] + * , the base URI is computed using first the value of the href + * attribute of the HTML BASE element if any, and the value of the + * documentURI attribute from the Document + * interface otherwise. + * @since DOM Level 3 + */ + public String getBaseURI(); + + // DocumentPosition + /** + * 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; + + /** + * 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. + * @exception 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; + + /** + * This attribute returns the text content of this node and its + * descendants. 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. + *
On getting, 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). Similarly, on setting, + * no parsing is performed either, the input string is taken as pure + * textual content. + *
The string returned is made of the text content of this node + * depending on its type, as defined below: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Node typeContent
+ * ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, + * DOCUMENT_FRAGMENT_NODEconcatenation 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.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, + * PROCESSING_INSTRUCTION_NODEnodeValue
DOCUMENT_NODE, + * DOCUMENT_TYPE_NODE, NOTATION_NODEnull
+ * @exception DOMException + * DOMSTRING_SIZE_ERR: Raised when it would return more characters than + * fit in a DOMString variable on the implementation + * platform. + * @since DOM Level 3 + */ + public String getTextContent() + throws DOMException; + /** + * This attribute returns the text content of this node and its + * descendants. 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. + *
On getting, 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). Similarly, on setting, + * no parsing is performed either, the input string is taken as pure + * textual content. + *
The string returned is made of the text content of this node + * depending on its type, as defined below: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Node typeContent
+ * ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, + * DOCUMENT_FRAGMENT_NODEconcatenation 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.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, + * PROCESSING_INSTRUCTION_NODEnodeValue
DOCUMENT_NODE, + * DOCUMENT_TYPE_NODE, NOTATION_NODEnull
+ * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * @since DOM Level 3 + */ + public void setTextContent(String textContent) + throws DOMException; + + /** + * Returns whether this node is the same node as the given one. + *
This method provides a way to determine whether two + * Node references returned by the implementation reference + * the same object. When two Node references are references + * to the same object, even if through a proxy, the references may be + * used completely interchangeably, such that all attributes have the + * same values and calling the same DOM method on either reference + * always has exactly the same effect. + * @param other The node to test against. + * @return Returns true if the nodes are the same, + * false otherwise. + * @since DOM Level 3 + */ + public boolean isSameNode(Node other); + + /** + * Look up the prefix associated to the given namespace URI, starting from + * this node. The default namespace declarations are ignored by this + * method. + *
See for details on the algorithm used by this method. + * @param namespaceURI The namespace URI to look for. + * @return Returns an associated namespace prefix if found or + * null if none is found. If more than one prefix are + * associated to the namespace prefix, the returned namespace prefix + * is implementation dependent. + * @since DOM Level 3 + */ + public String lookupPrefix(String namespaceURI); + + /** + * This method checks if the specified namespaceURI is the + * default namespace or not. + * @param namespaceURI The namespace URI to look for. + * @return Returns true if the specified + * namespaceURI is the default namespace, + * false otherwise. + * @since DOM Level 3 + */ + public boolean isDefaultNamespace(String namespaceURI); + + /** + * Look up the namespace URI associated to the given prefix, starting from + * this node. + *
See for details on the algorithm used by this method. + * @param prefix The prefix to look for. If this parameter is + * null, the method will return the default namespace URI + * if any. + * @return Returns the associated namespace URI or null if + * none is found. + * @since DOM Level 3 + */ + public String lookupNamespaceURI(String prefix); + + /** + * 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 Node.isSameNode(). All nodes that are the + * same will also be equal, though the reverse may not be true. + *
Two nodes are equal if and only if the following conditions are + * satisfied: + *

+ *
For two DocumentType nodes to be equal, the following + * conditions must also be satisfied: + * + *
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. + *

Note: As a general rule, anything not mentioned in the + * description above is not significant in consideration of equality + * checking. Note that future versions of this specification may take + * into account more attributes and implementations conform to this + * specification are expected to be updated accordingly. + * @param arg The node to compare equality with. + * @return Returns true if the nodes are equal, + * false otherwise. + * @since DOM Level 3 + */ + public boolean isEqualNode(Node arg); + + /** + * This method returns a specialized object which implements the + * specialized APIs of the specified feature and version, as specified + * in . The specialized object may also be obtained by using + * binding-specific casting methods but is not necessarily expected to, + * as discussed in . This method also allow the implementation to + * provide specialized objects which do not support the Node + * interface. + * @param feature The name of the feature requested. Note that any plus + * sign "+" prepended to the name of the feature will be ignored since + * it is not significant in the context of this method. + * @param version This is the version number of the feature to test. + * @return Returns an object which implements the specialized APIs of + * the specified feature and version, if any, or null if + * there is no object which implements interfaces associated with that + * feature. If the DOMObject returned by this method + * implements the Node interface, it must delegate to the + * primary core Node and not return results inconsistent + * with the primary core Node such as attributes, + * childNodes, etc. + * @since DOM Level 3 + */ + public Object getFeature(String feature, + String version); + + /** + * Associate an object to a key on this node. The object can later be + * retrieved from this node by calling getUserData with the + * same key. + * @param key The key to associate the object to. + * @param data The object to associate to the given key, or + * null to remove any existing association to that key. + * @param handler The handler to associate to that key, or + * null. + * @return Returns the DOMUserData previously associated to + * the given key on this node, or null if there was none. + * @since DOM Level 3 + */ + public Object setUserData(String key, + Object data, + UserDataHandler handler); + + /** + * Retrieves the object associated to a key on a this node. The object + * must first have been set to this node by calling + * setUserData with the same key. + * @param key The key the object is associated to. + * @return Returns the DOMUserData associated to the given + * key on this node, or null if there was none. + * @since DOM Level 3 + */ + public Object getUserData(String key); + } diff --git a/java/external/src/org/w3c/dom/NodeList.java b/java/external/src/org/w3c/dom/NodeList.java index a90b4fd..e4204ec 100644 --- a/java/external/src/org/w3c/dom/NodeList.java +++ b/java/external/src/org/w3c/dom/NodeList.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -18,7 +18,7 @@ package org.w3c.dom; * is implemented. NodeList objects in the DOM are live. *

The items in the NodeList are accessible via an integral * index, starting from 0. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface NodeList { /** diff --git a/java/external/src/org/w3c/dom/Notation.java b/java/external/src/org/w3c/dom/Notation.java index 186836d..3739f92 100644 --- a/java/external/src/org/w3c/dom/Notation.java +++ b/java/external/src/org/w3c/dom/Notation.java @@ -1,28 +1,27 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; /** * This interface represents a notation declared in the DTD. A notation either - * declares, by name, the format of an unparsed entity (see section 4.7 of - * the XML 1.0 specification ), or is used for formal declaration of - * processing instruction targets (see section 2.6 of the XML 1.0 - * specification ). The nodeName attribute inherited from - * Node is set to the declared name of the notation. - *

The DOM Level 1 does not support editing Notation nodes; - * they are therefore readonly. + * declares, by name, the format of an unparsed entity (see section 4.7 of the XML 1.0 specification [XML 1.0]), or is + * used for formal declaration of processing instruction targets (see section 2.6 of the XML 1.0 specification [XML 1.0]). The + * nodeName attribute inherited from Node is set + * to the declared name of the notation. + *

The DOM Core does not support editing Notation nodes; they + * are therefore readonly. *

A Notation node does not have any parent. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Notation extends Node { /** @@ -33,7 +32,8 @@ public interface Notation extends Node { /** * The system identifier of this notation. If the system identifier was - * not specified, this is null. + * not specified, this is null. This may be an absolute URI + * or not. */ public String getSystemId(); diff --git a/java/external/src/org/w3c/dom/ProcessingInstruction.java b/java/external/src/org/w3c/dom/ProcessingInstruction.java index fe447b5..0b6825f 100644 --- a/java/external/src/org/w3c/dom/ProcessingInstruction.java +++ b/java/external/src/org/w3c/dom/ProcessingInstruction.java @@ -1,13 +1,13 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; @@ -16,7 +16,13 @@ package org.w3c.dom; * The ProcessingInstruction interface represents a "processing * instruction", used in XML as a way to keep processor-specific information * in the text of the document. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + *

No lexical check is done on the content of a processing instruction and + * it is therefore possible to have the character sequence + * "?>" in the content, which is illegal a processing + * instruction per section 2.6 of [XML 1.0]. The + * presence of this character sequence must generate a fatal error during + * serialization. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface ProcessingInstruction extends Node { /** @@ -30,8 +36,6 @@ public interface ProcessingInstruction extends Node { * The content of this processing instruction. This is from the first non * white space character after the target to the character immediately * preceding the ?>. - * @exception DOMException - * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. */ public String getData(); /** @@ -42,6 +46,6 @@ public interface ProcessingInstruction extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. */ public void setData(String data) - throws DOMException; + throws DOMException; } diff --git a/java/external/src/org/w3c/dom/Text.java b/java/external/src/org/w3c/dom/Text.java index 842a973..9c294a4 100644 --- a/java/external/src/org/w3c/dom/Text.java +++ b/java/external/src/org/w3c/dom/Text.java @@ -1,36 +1,41 @@ /* - * Copyright (c) 2000 World Wide Web Consortium, - * (Massachusetts Institute of Technology, Institut National de - * Recherche en Informatique et en Automatique, Keio University). All - * Rights Reserved. This program is distributed under the W3C's Software - * Intellectual Property License. This program is distributed in the - * hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. - * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 */ package org.w3c.dom; /** * The Text interface inherits from CharacterData - * and represents the textual content (termed character data in XML) of an - * Element or Attr. If there is no markup inside - * an element's content, the text is contained in a single object - * implementing the Text interface that is the only child of - * the element. If there is markup, it is parsed into the information items - * (elements, comments, etc.) and Text nodes that form the list - * of children of the element. + * and represents the textual content (termed character data in XML) of an Element or Attr. If there is no + * markup inside an element's content, the text is contained in a single + * object implementing the Text interface that is the only + * child of the element. If there is markup, it is parsed into the + * information items (elements, comments, etc.) and Text nodes + * that form the list of children of the element. *

When a document is first made available via the DOM, there is only one * Text node for each block of text. Users may create adjacent * Text nodes that represent the contents of a given element * without any intervening markup, but should be aware that there is no way * to represent the separations between these nodes in XML or HTML, so they * will not (in general) persist between DOM editing sessions. The - * normalize() method on Node merges any such - * adjacent Text objects into a single node for each block of - * text. - *

See also the Document Object Model (DOM) Level 2 Core Specification. + * Node.normalize() method merges any such adjacent + * Text objects into a single node for each block of text. + *

No lexical check is done on the content of a Text node + * and, depending on its position in the document, some characters must be + * escaped during serialization using character references; e.g. the + * characters "<&" if the textual content is part of an element or of + * an attribute, the character sequence "]]>" when part of an element, + * the quotation mark character " or the apostrophe character ' when part of + * an attribute. + *

See also the Document Object Model (DOM) Level 3 Core Specification. */ public interface Text extends CharacterData { /** @@ -53,4 +58,69 @@ public interface Text extends CharacterData { public Text splitText(int offset) throws DOMException; + /** + * Returns whether this text node contains + * element content whitespace, often abusively called "ignorable whitespace". The text node is + * determined to contain whitespace in element content during the load + * of the document or if validation occurs while using + * Document.normalizeDocument(). + * @since DOM Level 3 + */ + public boolean isElementContentWhitespace(); + + /** + * Returns all text of Text nodes logically-adjacent text + * nodes to this node, concatenated in document order. + *
For instance, in the example below wholeText on the + * Text node that contains "bar" returns "barfoo", while on + * the Text node that contains "foo" it returns "barfoo". + * @since DOM Level 3 + */ + public String getWholeText(); + + /** + * Replaces the text of the current node and all logically-adjacent text + * nodes with the specified text. All logically-adjacent text nodes are + * removed including the current node unless it was the recipient of the + * replacement text. + *
This method returns the node which received the replacement text. + * The returned node is: + *

+ *
For instance, in the above example calling + * replaceWholeText on the Text node that + * contains "bar" with "yo" in argument results in the following: + *
Where the nodes to be removed are read-only descendants of an + * EntityReference, the EntityReference must + * be removed instead of the read-only nodes. If any + * EntityReference to be removed has descendants that are + * not EntityReference, Text, or + * CDATASection nodes, the replaceWholeText + * method must fail before performing any modification of the document, + * raising a DOMException with the code + * NO_MODIFICATION_ALLOWED_ERR. + *
For instance, in the example below calling + * replaceWholeText on the Text node that + * contains "bar" fails, because the EntityReference node + * "ent" contains an Element node which cannot be removed. + * @param content The content of the replacing Text node. + * @return The Text node created with the specified content. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text + * nodes being replaced is readonly. + * @since DOM Level 3 + */ + public Text replaceWholeText(String content) + throws DOMException; + } diff --git a/java/external/src/org/w3c/dom/TypeInfo.java b/java/external/src/org/w3c/dom/TypeInfo.java new file mode 100644 index 0000000..054f990 --- /dev/null +++ b/java/external/src/org/w3c/dom/TypeInfo.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * The TypeInfo interface represents a type referenced from + * Element or Attr 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. + *

If the document's schema is an XML DTD [XML 1.0], the values + * are computed as follows: + *

+ *

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): + *

+ *

Note: Other schema languages are outside the scope of the W3C + * and therefore should define how to represent their type systems using + * TypeInfo. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface TypeInfo { + /** + * 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 null if the element does not have + * declaration or if no namespace information is available. + */ + public String getTypeNamespace(); + + // DerivationMethods + /** + * 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. + *
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. + *
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. + *
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. + *
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; + + /** + * 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 + * . 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); + +} diff --git a/java/external/src/org/w3c/dom/UserDataHandler.java b/java/external/src/org/w3c/dom/UserDataHandler.java new file mode 100644 index 0000000..a16ea73 --- /dev/null +++ b/java/external/src/org/w3c/dom/UserDataHandler.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom; + +/** + * 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. + *

See also the Document Object Model (DOM) Level 3 Core Specification. + * @since DOM Level 3 + */ +public interface UserDataHandler { + // OperationType + /** + * 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. + *

Note: This may not be supported or may not be reliable in + * certain environments, such as Java, where the implementation has no + * real control over when objects are actually 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; + + /** + * This method is called whenever the node for which this handler is + * registered is imported or cloned. + *
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); + +} diff --git a/java/external/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java b/java/external/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java new file mode 100644 index 0000000..ba8d5f0 --- /dev/null +++ b/java/external/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + + +package org.w3c.dom.bootstrap; + +import java.util.StringTokenizer; +import java.util.Vector; +import org.w3c.dom.DOMImplementationSource; +import org.w3c.dom.DOMImplementationList; +import org.w3c.dom.DOMImplementation; +import java.io.InputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.security.AccessController; +import java.security.PrivilegedAction; + +/** + * A factory that enables applications to obtain instances of + * DOMImplementation. + * + *

+ * Example: + *

+ * + *
+ *  // get an instance of the DOMImplementation registry
+ *  DOMImplementationRegistry registry =
+ *       DOMImplementationRegistry.newInstance();
+ *  // get a DOM implementation the Level 3 XML module
+ *  DOMImplementation domImpl =
+ *       registry.getDOMImplementation("XML 3.0");
+ * 
+ * + *

+ * This provides an application with an implementation-independent starting + * point. DOM implementations may modify this class to meet new security + * standards or to provide *additional* fallbacks for the list of + * DOMImplementationSources. + *

+ * + * @see DOMImplementation + * @see DOMImplementationSource + * @since DOM Level 3 + */ +public final class DOMImplementationRegistry { + /** + * The system property to specify the + * DOMImplementationSource class names. + */ + public static final String PROPERTY = + "org.w3c.dom.DOMImplementationSourceList"; + + /** + * Default columns per line. + */ + private static final int DEFAULT_LINE_LENGTH = 80; + + /** + * The list of DOMImplementationSources. + */ + private Vector sources; + + /** + * Private constructor. + * @param srcs Vector List of DOMImplementationSources + */ + private DOMImplementationRegistry(final Vector srcs) { + sources = srcs; + } + + /** + * Obtain a new instance of a DOMImplementationRegistry. + * + + * The DOMImplementationRegistry is initialized by the + * application or the implementation, depending on the context, by + * first checking the value of the Java system property + * org.w3c.dom.DOMImplementationSourceList and + * the the service provider whose contents are at + * "META_INF/services/org.w3c.dom.DOMImplementationSourceList" + * The value of this property is a white-space separated list of + * names of availables classes implementing the + * DOMImplementationSource interface. Each class listed + * in the class name list is instantiated and any exceptions + * encountered are thrown to the application. + * + * @return an initialized instance of DOMImplementationRegistry + * @throws ClassNotFoundException + * If any specified class can not be found + * @throws InstantiationException + * If any specified class is an interface or abstract class + * @throws IllegalAccessException + * If the default constructor of a specified class is not accessible + * @throws ClassCastException + * If any specified class does not implement + * DOMImplementationSource + */ + public static DOMImplementationRegistry newInstance() + throws + ClassNotFoundException, + InstantiationException, + IllegalAccessException, + ClassCastException { + Vector sources = new Vector(); + + ClassLoader classLoader = getClassLoader(); + // fetch system property: + String p = getSystemProperty(PROPERTY); + + // + // if property is not specified then use contents of + // META_INF/org.w3c.dom.DOMImplementationSourceList from classpath + if (p == null) { + p = getServiceValue(classLoader); + } + if (p == null) { + // + // DOM Implementations can modify here to add *additional* fallback + // mechanisms to access a list of default DOMImplementationSources. + + } + if (p != null) { + StringTokenizer st = new StringTokenizer(p); + while (st.hasMoreTokens()) { + String sourceName = st.nextToken(); + // Use context class loader, falling back to Class.forName + // if and only if this fails... + Class sourceClass = null; + if (classLoader != null) { + sourceClass = classLoader.loadClass(sourceName); + } else { + sourceClass = Class.forName(sourceName); + } + DOMImplementationSource source = + (DOMImplementationSource) sourceClass.newInstance(); + sources.addElement(source); + } + } + return new DOMImplementationRegistry(sources); + } + + /** + * Return the first implementation that has the desired + * features, or null if none is found. + * + * @param features + * A string that specifies which features are required. This is + * a space separated list in which each feature is specified by + * its name optionally followed by a space and a version number. + * This is something like: "XML 1.0 Traversal +Events 2.0" + * @return An implementation that has the desired features, + * or null if none found. + */ + public DOMImplementation getDOMImplementation(final String features) { + int size = sources.size(); + String name = null; + for (int i = 0; i < size; i++) { + DOMImplementationSource source = + (DOMImplementationSource) sources.elementAt(i); + DOMImplementation impl = source.getDOMImplementation(features); + if (impl != null) { + return impl; + } + } + return null; + } + + /** + * Return a list of implementations that support the + * desired features. + * + * @param features + * A string that specifies which features are required. This is + * a space separated list in which each feature is specified by + * its name optionally followed by a space and a version number. + * This is something like: "XML 1.0 Traversal +Events 2.0" + * @return A list of DOMImplementations that support the desired features. + */ + public DOMImplementationList getDOMImplementationList(final String features) { + final Vector implementations = new Vector(); + int size = sources.size(); + for (int i = 0; i < size; i++) { + DOMImplementationSource source = + (DOMImplementationSource) sources.elementAt(i); + DOMImplementationList impls = + source.getDOMImplementationList(features); + for (int j = 0; j < impls.getLength(); j++) { + DOMImplementation impl = impls.item(j); + implementations.addElement(impl); + } + } + return new DOMImplementationList() { + public DOMImplementation item(final int index) { + if (index >= 0 && index < implementations.size()) { + try { + return (DOMImplementation) + implementations.elementAt(index); + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + return null; + } + + public int getLength() { + return implementations.size(); + } + }; + } + + /** + * Register an implementation. + * + * @param s The source to be registered, may not be null + */ + public void addSource(final DOMImplementationSource s) { + if (s == null) { + throw new NullPointerException(); + } + if (!sources.contains(s)) { + sources.addElement(s); + } + } + + /** + * + * Gets a class loader. + * + * @return A class loader, possibly null + */ + private static ClassLoader getClassLoader() { + try { + ClassLoader contextClassLoader = getContextClassLoader(); + + if (contextClassLoader != null) { + return contextClassLoader; + } + } catch (Exception e) { + // Assume that the DOM application is in a JRE 1.1, use the + // current ClassLoader + return DOMImplementationRegistry.class.getClassLoader(); + } + return DOMImplementationRegistry.class.getClassLoader(); + } + + /** + * This method attempts to return the first line of the resource + * META_INF/services/org.w3c.dom.DOMImplementationSourceList + * from the provided ClassLoader. + * + * @param classLoader classLoader, may not be null. + * @return first line of resource, or null + */ + private static String getServiceValue(final ClassLoader classLoader) { + String serviceId = "META-INF/services/" + PROPERTY; + // try to find services in CLASSPATH + try { + InputStream is = getResourceAsStream(classLoader, serviceId); + + if (is != null) { + BufferedReader rd; + try { + rd = + new BufferedReader(new InputStreamReader(is, "UTF-8"), + DEFAULT_LINE_LENGTH); + } catch (java.io.UnsupportedEncodingException e) { + rd = + new BufferedReader(new InputStreamReader(is), + DEFAULT_LINE_LENGTH); + } + String serviceValue = rd.readLine(); + rd.close(); + if (serviceValue != null && serviceValue.length() > 0) { + return serviceValue; + } + } + } catch (Exception ex) { + return null; + } + return null; + } + + /** + * A simple JRE (Java Runtime Environment) 1.1 test + * + * @return true if JRE 1.1 + */ + private static boolean isJRE11() { + try { + Class c = Class.forName("java.security.AccessController"); + // java.security.AccessController existed since 1.2 so, if no + // exception was thrown, the DOM application is running in a JRE + // 1.2 or higher + return false; + } catch (Exception ex) { + // ignore + } + return true; + } + + /** + * This method returns the ContextClassLoader or null if + * running in a JRE 1.1 + * + * @return The Context Classloader + */ + private static ClassLoader getContextClassLoader() { + return isJRE11() + ? null + : (ClassLoader) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ClassLoader classLoader = null; + try { + classLoader = + Thread.currentThread().getContextClassLoader(); + } catch (SecurityException ex) { + } + return classLoader; + } + }); + } + + /** + * This method returns the system property indicated by the specified name + * after checking access control privileges. For a JRE 1.1, this check is + * not done. + * + * @param name the name of the system property + * @return the system property + */ + private static String getSystemProperty(final String name) { + return isJRE11() + ? (String) System.getProperty(name) + : (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(name); + } + }); + } + + /** + * This method returns an Inputstream for the reading resource + * META_INF/services/org.w3c.dom.DOMImplementationSourceList after checking + * access control privileges. For a JRE 1.1, this check is not done. + * + * @param classLoader classLoader + * @param name the resource + * @return an Inputstream for the resource specified + */ + private static InputStream getResourceAsStream(final ClassLoader classLoader, + final String name) { + if (isJRE11()) { + InputStream ris; + if (classLoader == null) { + ris = ClassLoader.getSystemResourceAsStream(name); + } else { + ris = classLoader.getResourceAsStream(name); + } + return ris; + } else { + return (InputStream) + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + InputStream ris; + if (classLoader == null) { + ris = + ClassLoader.getSystemResourceAsStream(name); + } else { + ris = classLoader.getResourceAsStream(name); + } + return ris; + } + }); + } + } +} diff --git a/java/external/src/org/w3c/dom/events/MutationEvent.java b/java/external/src/org/w3c/dom/events/MutationEvent.java index 351f77b..3db4003 100644 --- a/java/external/src/org/w3c/dom/events/MutationEvent.java +++ b/java/external/src/org/w3c/dom/events/MutationEvent.java @@ -50,14 +50,14 @@ public interface MutationEvent extends Event { /** * prevValue indicates the previous value of the * Attr node in DOMAttrModified events, and of the - * CharacterData node in DOMCharDataModified events. + * CharacterData node in DOMCharacterDataModified events. */ public String getPrevValue(); /** * newValue indicates the new value of the Attr * node in DOMAttrModified events, and of the CharacterData - * node in DOMCharDataModified events. + * node in DOMCharacterDataModified events. */ public String getNewValue(); diff --git a/java/external/src/org/w3c/dom/ls/DOMImplementationLS.java b/java/external/src/org/w3c/dom/ls/DOMImplementationLS.java new file mode 100644 index 0000000..c94fc8e --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/DOMImplementationLS.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.DOMException; + +/** + * DOMImplementationLS contains the factory methods for creating + * Load and Save objects. + *

The expectation is that an instance of the + * DOMImplementationLS interface can be obtained by using + * binding-specific casting methods on an instance of the + * DOMImplementation interface or, if the Document + * supports the feature "Core" version "3.0" + * defined in [DOM Level 3 Core] + * , by using the method DOMImplementation.getFeature with + * parameter values "LS" (or "LS-Async") and + * "3.0" (respectively). + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface DOMImplementationLS { + // DOMImplementationLSMode + /** + * Create a synchronous LSParser. + */ + public static final short MODE_SYNCHRONOUS = 1; + /** + * Create an asynchronous LSParser. + */ + public static final short MODE_ASYNCHRONOUS = 2; + + /** + * Create a new LSParser. The newly constructed parser may + * then be configured by means of its DOMConfiguration + * object, and used to parse documents by means of its parse + * method. + * @param mode The mode argument is either + * MODE_SYNCHRONOUS or MODE_ASYNCHRONOUS, if + * mode is MODE_SYNCHRONOUS then the + * LSParser that is created will operate in synchronous + * mode, if it's MODE_ASYNCHRONOUS then the + * LSParser that is created will operate in asynchronous + * mode. + * @param schemaType An absolute URI representing the type of the schema + * language used during the load of a Document using the + * newly created LSParser. Note that no lexical checking + * is done on the absolute URI. In order to create a + * LSParser for any kind of schema types (i.e. the + * LSParser will be free to use any schema found), use the value + * null. + *

Note: For W3C 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. + * @return The newly created LSParser object. This + * LSParser is either synchronous or asynchronous + * depending on the value of the mode argument. + *

Note: By default, the newly created LSParser + * does not contain a DOMErrorHandler, i.e. the value of + * the " + * error-handler" configuration parameter is null. However, implementations + * may provide a default error handler at creation time. In that case, + * the initial value of the "error-handler" configuration + * parameter on the new LSParser object contains a + * reference to the default error handler. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the requested mode or schema type is + * not supported. + */ + public LSParser createLSParser(short mode, + String schemaType) + throws DOMException; + + /** + * Create a new LSSerializer object. + * @return The newly created LSSerializer object. + *

Note: By default, the newly created + * LSSerializer has no DOMErrorHandler, i.e. + * the value of the "error-handler" configuration + * parameter is null. However, implementations may + * provide a default error handler at creation time. In that case, the + * initial value of the "error-handler" configuration + * parameter on the new LSSerializer object contains a + * reference to the default error handler. + */ + public LSSerializer createLSSerializer(); + + /** + * Create a new empty input source object where + * LSInput.characterStream, LSInput.byteStream + * , LSInput.stringData LSInput.systemId, + * LSInput.publicId, LSInput.baseURI, and + * LSInput.encoding are null, and + * LSInput.certifiedText is false. + * @return The newly created input object. + */ + public LSInput createLSInput(); + + /** + * Create a new empty output destination object where + * LSOutput.characterStream, + * LSOutput.byteStream, LSOutput.systemId, + * LSOutput.encoding are null. + * @return The newly created output object. + */ + public LSOutput createLSOutput(); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSException.java b/java/external/src/org/w3c/dom/ls/LSException.java new file mode 100644 index 0000000..65a83f0 --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSException.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +/** + * Parser or write operations may throw an LSException if the + * processing is stopped. The processing can be stopped due to a + * DOMError with a severity of + * DOMError.SEVERITY_FATAL_ERROR or a non recovered + * DOMError.SEVERITY_ERROR, or if + * DOMErrorHandler.handleError() returned false. + *

Note: As suggested in the definition of the constants in the + * DOMError interface, a DOM implementation may choose to + * continue after a fatal error, but the resulting DOM tree is then + * implementation dependent. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public class LSException extends RuntimeException { + public LSException(short code, String message) { + super(message); + this.code = code; + } + public short code; + // LSExceptionCode + /** + * If an attempt was made to load a document, or an XML Fragment, using + * LSParser and the processing has been stopped. + */ + public static final short PARSE_ERR = 81; + /** + * If an attempt was made to serialize a Node using + * LSSerializer and the processing has been stopped. + */ + public static final short SERIALIZE_ERR = 82; + +} diff --git a/java/external/src/org/w3c/dom/ls/LSInput.java b/java/external/src/org/w3c/dom/ls/LSInput.java new file mode 100644 index 0000000..862bf77 --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSInput.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +/** + * This interface represents an input source for data. + *

This interface allows an application to encapsulate information about + * an input source in a single object, which may include a public + * identifier, a system identifier, a byte stream (possibly with a specified + * encoding), a base URI, and/or a character stream. + *

The exact definitions of a byte stream and a character stream are + * binding dependent. + *

The application is expected to provide objects that implement this + * interface whenever such objects are needed. The application can either + * provide its own objects that implement this interface, or it can use the + * generic factory method DOMImplementationLS.createLSInput() + * to create objects that implement this interface. + *

The LSParser will use the LSInput object to + * determine how to read data. The LSParser will look at the + * different inputs specified in the LSInput in the following + * order to know which one to read from, the first one that is not null and + * not an empty string will be used: + *

    + *
  1. LSInput.characterStream + *
  2. + *
  3. + * LSInput.byteStream + *
  4. + *
  5. LSInput.stringData + *
  6. + *
  7. + * LSInput.systemId + *
  8. + *
  9. LSInput.publicId + *
  10. + *
+ *

If all inputs are null, the LSParser will report a + * DOMError with its DOMError.type set to + * "no-input-specified" and its DOMError.severity + * set to DOMError.SEVERITY_FATAL_ERROR. + *

LSInput objects belong to the application. The DOM + * implementation will never modify them (though it may make copies and + * modify the copies, if necessary). + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSInput { + /** + * An attribute of a language and binding dependent type that represents + * a stream of 16-bit units. The application must encode the stream + * using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when + * using character streams. If an XML declaration is present, the value + * of the encoding attribute will be ignored. + */ + public java.io.Reader getCharacterStream(); + /** + * An attribute of a language and binding dependent type that represents + * a stream of 16-bit units. The application must encode the stream + * using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when + * using character streams. If an XML declaration is present, the value + * of the encoding attribute will be ignored. + */ + public void setCharacterStream(java.io.Reader characterStream); + + /** + * An attribute of a language and binding dependent type that represents + * a stream of bytes. + *
If the application knows the character encoding of the byte + * stream, it should set the encoding attribute. Setting the encoding in + * this way will override any encoding specified in an XML declaration + * in the data. + */ + public java.io.InputStream getByteStream(); + /** + * An attribute of a language and binding dependent type that represents + * a stream of bytes. + *
If the application knows the character encoding of the byte + * stream, it should set the encoding attribute. Setting the encoding in + * this way will override any encoding specified in an XML declaration + * in the data. + */ + public void setByteStream(java.io.InputStream byteStream); + + /** + * String data to parse. If provided, this will always be treated as a + * sequence of 16-bit units (UTF-16 encoded characters). It is not a + * requirement to have an XML declaration when using + * stringData. If an XML declaration is present, the value + * of the encoding attribute will be ignored. + */ + public String getStringData(); + /** + * String data to parse. If provided, this will always be treated as a + * sequence of 16-bit units (UTF-16 encoded characters). It is not a + * requirement to have an XML declaration when using + * stringData. If an XML declaration is present, the value + * of the encoding attribute will be ignored. + */ + public void setStringData(String stringData); + + /** + * The system identifier, a URI reference [IETF RFC 2396], for this + * input source. The system identifier is optional if there is a byte + * stream, a character stream, or string data. It is still useful to + * provide one, since the application will use it to resolve any + * relative URIs and can include it in error messages and warnings. (The + * LSParser will only attempt to fetch the resource identified by the + * URI reference if there is no other input available in the input + * source.) + *
If the application knows the character encoding of the object + * pointed to by the system identifier, it can set the encoding using + * the encoding attribute. + *
If the specified system ID is a relative URI reference (see + * section 5 in [IETF RFC 2396]), the DOM + * implementation will attempt to resolve the relative URI with the + * baseURI as the base, if that fails, the behavior is + * implementation dependent. + */ + public String getSystemId(); + /** + * The system identifier, a URI reference [IETF RFC 2396], for this + * input source. The system identifier is optional if there is a byte + * stream, a character stream, or string data. It is still useful to + * provide one, since the application will use it to resolve any + * relative URIs and can include it in error messages and warnings. (The + * LSParser will only attempt to fetch the resource identified by the + * URI reference if there is no other input available in the input + * source.) + *
If the application knows the character encoding of the object + * pointed to by the system identifier, it can set the encoding using + * the encoding attribute. + *
If the specified system ID is a relative URI reference (see + * section 5 in [IETF RFC 2396]), the DOM + * implementation will attempt to resolve the relative URI with the + * baseURI as the base, if that fails, the behavior is + * implementation dependent. + */ + public void setSystemId(String systemId); + + /** + * The public identifier for this input source. This may be mapped to an + * input source using an implementation dependent mechanism (such as + * catalogues or other mappings). The public identifier, if specified, + * may also be reported as part of the location information when errors + * are reported. + */ + public String getPublicId(); + /** + * The public identifier for this input source. This may be mapped to an + * input source using an implementation dependent mechanism (such as + * catalogues or other mappings). The public identifier, if specified, + * may also be reported as part of the location information when errors + * are reported. + */ + public void setPublicId(String publicId); + + /** + * The base URI to be used (see section 5.1.4 in [IETF RFC 2396]) for + * resolving a relative systemId to an absolute URI. + *
If, when used, the base URI is itself a relative URI, an empty + * string, or null, the behavior is implementation dependent. + */ + public String getBaseURI(); + /** + * The base URI to be used (see section 5.1.4 in [IETF RFC 2396]) for + * resolving a relative systemId to an absolute URI. + *
If, when used, the base URI is itself a relative URI, an empty + * string, or null, the behavior is implementation dependent. + */ + public void setBaseURI(String baseURI); + + /** + * The character encoding, if known. The encoding must be a string + * acceptable for an XML encoding declaration ([XML 1.0] section + * 4.3.3 "Character Encoding in Entities"). + *
This attribute has no effect when the application provides a + * character stream or string data. For other sources of input, an + * encoding specified by means of this attribute will override any + * encoding specified in the XML declaration or the Text declaration, or + * an encoding obtained from a higher level protocol, such as HTTP [IETF RFC 2616]. + */ + public String getEncoding(); + /** + * The character encoding, if known. The encoding must be a string + * acceptable for an XML encoding declaration ([XML 1.0] section + * 4.3.3 "Character Encoding in Entities"). + *
This attribute has no effect when the application provides a + * character stream or string data. For other sources of input, an + * encoding specified by means of this attribute will override any + * encoding specified in the XML declaration or the Text declaration, or + * an encoding obtained from a higher level protocol, such as HTTP [IETF RFC 2616]. + */ + public void setEncoding(String encoding); + + /** + * If set to true, assume that the input is certified (see section 2.13 + * in [XML 1.1]) when + * parsing [XML 1.1]. + */ + public boolean getCertifiedText(); + /** + * If set to true, assume that the input is certified (see section 2.13 + * in [XML 1.1]) when + * parsing [XML 1.1]. + */ + public void setCertifiedText(boolean certifiedText); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSLoadEvent.java b/java/external/src/org/w3c/dom/ls/LSLoadEvent.java new file mode 100644 index 0000000..601a5be --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSLoadEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.Document; +import org.w3c.dom.events.Event; + +/** + * This interface represents a load event object that signals the completion + * of a document load. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSLoadEvent extends Event { + /** + * The document that finished loading. + */ + public Document getNewDocument(); + + /** + * The input source that was parsed. + */ + public LSInput getInput(); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSOutput.java b/java/external/src/org/w3c/dom/ls/LSOutput.java new file mode 100644 index 0000000..2f8675c --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSOutput.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +/** + * This interface represents an output destination for data. + *

This interface allows an application to encapsulate information about + * an output destination in a single object, which may include a URI, a byte + * stream (possibly with a specified encoding), a base URI, and/or a + * character stream. + *

The exact definitions of a byte stream and a character stream are + * binding dependent. + *

The application is expected to provide objects that implement this + * interface whenever such objects are needed. The application can either + * provide its own objects that implement this interface, or it can use the + * generic factory method DOMImplementationLS.createLSOutput() + * to create objects that implement this interface. + *

The LSSerializer will use the LSOutput object + * to determine where to serialize the output to. The + * LSSerializer will look at the different outputs specified in + * the LSOutput in the following order to know which one to + * output to, the first one that is not null and not an empty string will be + * used: + *

    + *
  1. LSOutput.characterStream + *
  2. + *
  3. + * LSOutput.byteStream + *
  4. + *
  5. LSOutput.systemId + *
  6. + *
+ *

LSOutput objects belong to the application. The DOM + * implementation will never modify them (though it may make copies and + * modify the copies, if necessary). + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSOutput { + /** + * An attribute of a language and binding dependent type that represents + * a writable stream to which 16-bit units can be output. + */ + public java.io.Writer getCharacterStream(); + /** + * An attribute of a language and binding dependent type that represents + * a writable stream to which 16-bit units can be output. + */ + public void setCharacterStream(java.io.Writer characterStream); + + /** + * An attribute of a language and binding dependent type that represents + * a writable stream of bytes. + */ + public java.io.OutputStream getByteStream(); + /** + * An attribute of a language and binding dependent type that represents + * a writable stream of bytes. + */ + public void setByteStream(java.io.OutputStream byteStream); + + /** + * The system identifier, a URI reference [IETF RFC 2396], for this + * output destination. + *
If the system ID is a relative URI reference (see section 5 in [IETF RFC 2396]), the + * behavior is implementation dependent. + */ + public String getSystemId(); + /** + * The system identifier, a URI reference [IETF RFC 2396], for this + * output destination. + *
If the system ID is a relative URI reference (see section 5 in [IETF RFC 2396]), the + * behavior is implementation dependent. + */ + public void setSystemId(String systemId); + + /** + * The character encoding to use for the output. The encoding must be a + * string acceptable for an XML encoding declaration ([XML 1.0] section + * 4.3.3 "Character Encoding in Entities"), it is recommended that + * character encodings registered (as charsets) with the Internet + * Assigned Numbers Authority [IANA-CHARSETS] + * should be referred to using their registered names. + */ + public String getEncoding(); + /** + * The character encoding to use for the output. The encoding must be a + * string acceptable for an XML encoding declaration ([XML 1.0] section + * 4.3.3 "Character Encoding in Entities"), it is recommended that + * character encodings registered (as charsets) with the Internet + * Assigned Numbers Authority [IANA-CHARSETS] + * should be referred to using their registered names. + */ + public void setEncoding(String encoding); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSParser.java b/java/external/src/org/w3c/dom/ls/LSParser.java new file mode 100644 index 0000000..ee918e0 --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSParser.java @@ -0,0 +1,466 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.Document; +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.Node; +import org.w3c.dom.DOMException; + +/** + * An interface to an object that is able to build, or augment, a DOM tree + * from various input sources. + *

LSParser provides an API for parsing XML and building the + * corresponding DOM document structure. A LSParser instance + * can be obtained by invoking the + * DOMImplementationLS.createLSParser() method. + *

As specified in [DOM Level 3 Core] + * , when a document is first made available via the LSParser: + *

+ *

Asynchronous LSParser objects are expected to also + * implement the events::EventTarget interface so that event + * listeners can be registered on asynchronous LSParser + * objects. + *

Events supported by asynchronous LSParser objects are: + *

+ *
load
+ *
+ * The LSParser finishes to load the document. See also the + * definition of the LSLoadEvent interface.
+ *
progress
+ *
The + * LSParser signals progress as data is parsed. This + * specification does not attempt to define exactly when progress events + * should be dispatched. That is intentionally left as + * implementation-dependent. Here is one example of how an application might + * dispatch progress events: Once the parser starts receiving data, a + * progress event is dispatched to indicate that the parsing starts. From + * there on, a progress event is dispatched for every 4096 bytes of data + * that is received and processed. This is only one example, though, and + * implementations can choose to dispatch progress events at any time while + * parsing, or not dispatch them at all. See also the definition of the + * LSProgressEvent interface.
+ *
+ *

Note: All events defined in this specification use the + * namespace URI "http://www.w3.org/2002/DOMLS". + *

While parsing an input source, errors are reported to the application + * through the error handler (LSParser.domConfig's " + * error-handler" parameter). This specification does in no way try to define all possible + * errors that can occur while parsing XML, or any other markup, but some + * common error cases are defined. The types (DOMError.type) of + * errors and warnings defined by this specification are: + *

+ *
+ * "check-character-normalization-failure" [error]
+ *
Raised if + * the parameter " + * check-character-normalization" is set to true and a string is encountered that fails normalization + * checking.
+ *
"doctype-not-allowed" [fatal]
+ *
Raised if the + * configuration parameter "disallow-doctype" is set to true + * and a doctype is encountered.
+ *
"no-input-specified" [fatal]
+ *
+ * Raised when loading a document and no input is specified in the + * LSInput object.
+ *
+ * "pi-base-uri-not-preserved" [warning]
+ *
Raised if a processing + * instruction is encountered in a location where the base URI of the + * processing instruction can not be preserved. One example of a case where + * this warning will be raised is if the configuration parameter " + * entities" is set to false and the following XML file is parsed: + *
+ * <!DOCTYPE root [ <!ENTITY e SYSTEM 'subdir/myentity.ent' ]> 
+ * <root> &e; </root>
+ * And subdir/myentity.ent + * contains: + *
<one> <two/> </one> <?pi 3.14159?> 
+ * <more/>
+ *
+ *
"unbound-prefix-in-entity" [warning]
+ *
An + * implementation dependent warning that may be raised if the configuration + * parameter " + * namespaces" is set to true and an unbound namespace prefix is + * encountered in an entity's replacement text. Raising this warning is not + * enforced since some existing parsers may not recognize unbound namespace + * prefixes in the replacement text of entities.
+ *
+ * "unknown-character-denormalization" [fatal]
+ *
Raised if the + * configuration parameter "ignore-unknown-character-denormalizations" is + * set to false and a character is encountered for which the + * processor cannot determine the normalization properties.
+ *
+ * "unsupported-encoding" [fatal]
+ *
Raised if an unsupported + * encoding is encountered.
+ *
"unsupported-media-type" [fatal]
+ *
+ * Raised if the configuration parameter "supported-media-types-only" is set + * to true and an unsupported media type is encountered.
+ *
+ *

In addition to raising the defined errors and warnings, implementations + * are expected to raise implementation specific errors and warnings for any + * other error and warning cases such as IO errors (file not found, + * permission denied,...), XML well-formedness errors, and so on. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSParser { + /** + * The DOMConfiguration object used when parsing an input + * source. This DOMConfiguration is specific to the parse + * operation. No parameter values from this DOMConfiguration + * object are passed automatically to the DOMConfiguration + * object on the Document that is created, or used, by the + * parse operation. The DOM application is responsible for passing any + * needed parameter values from this DOMConfiguration + * object to the DOMConfiguration object referenced by the + * Document object. + *
In addition to the parameters recognized in on the + * DOMConfiguration interface defined in [DOM Level 3 Core] + * , the DOMConfiguration objects for LSParser + * add or modify the following parameters: + *

+ *
+ * "charset-overrides-xml-encoding"
+ *
+ *
+ *
true
+ *
[optional] (default) If a higher level protocol such as HTTP [IETF RFC 2616] provides an + * indication of the character encoding of the input stream being + * processed, that will override any encoding specified in the XML + * declaration or the Text declaration (see also section 4.3.3, + * "Character Encoding in Entities", in [XML 1.0]). + * Explicitly setting an encoding in the LSInput overrides + * any encoding from the protocol.
+ *
false
+ *
[required] The parser ignores any character set encoding information from + * higher-level protocols.
+ *
+ *
"disallow-doctype"
+ *
+ *
+ *
+ * true
+ *
[optional] Throw a fatal "doctype-not-allowed" error if a doctype node is found while parsing the document. This is + * useful when dealing with things like SOAP envelopes where doctype + * nodes are not allowed.
+ *
false
+ *
[required] (default) Allow doctype nodes in the document.
+ *
+ *
+ * "ignore-unknown-character-denormalizations"
+ *
+ *
+ *
+ * true
+ *
[required] (default) If, while verifying full normalization when [XML 1.1] is + * supported, a processor encounters characters for which it cannot + * determine the normalization properties, then the processor will + * ignore any possible denormalizations caused by these characters. + * This parameter is ignored for [XML 1.0].
+ *
+ * false
+ *
[optional] Report an fatal "unknown-character-denormalization" error if a character is encountered for which the processor cannot + * determine the normalization properties.
+ *
+ *
"infoset"
+ *
See + * the definition of DOMConfiguration for a description of + * this parameter. Unlike in [DOM Level 3 Core] + * , this parameter will default to true for + * LSParser.
+ *
"namespaces"
+ *
+ *
+ *
true
+ *
[required] (default) Perform the namespace processing as defined in [XML Namespaces] + * and [XML Namespaces 1.1] + * .
+ *
false
+ *
[optional] Do not perform the namespace processing.
+ *
+ *
+ * "resource-resolver"
+ *
[required] A reference to a LSResourceResolver object, or null. If + * the value of this parameter is not null when an external resource + * (such as an external XML entity or an XML schema location) is + * encountered, the implementation will request that the + * LSResourceResolver referenced in this parameter resolves + * the resource.
+ *
"supported-media-types-only"
+ *
+ *
+ *
+ * true
+ *
[optional] Check that the media type of the parsed resource is a supported media + * type. If an unsupported media type is encountered, a fatal error of + * type "unsupported-media-type" will be raised. The media types defined in [IETF RFC 3023] must always + * be accepted.
+ *
false
+ *
[required] (default) Accept any media type.
+ *
+ *
"validate"
+ *
See the definition of + * DOMConfiguration for a description of this parameter. + * Unlike in [DOM Level 3 Core] + * , the processing of the internal subset is always accomplished, even + * if this parameter is set to false.
+ *
+ * "validate-if-schema"
+ *
See the definition of + * DOMConfiguration for a description of this parameter. + * Unlike in [DOM Level 3 Core] + * , the processing of the internal subset is always accomplished, even + * if this parameter is set to false.
+ *
+ * "well-formed"
+ *
See the definition of + * DOMConfiguration for a description of this parameter. + * Unlike in [DOM Level 3 Core] + * , this parameter cannot be set to false.
+ *
+ */ + public DOMConfiguration getDomConfig(); + + /** + * When a filter is provided, the implementation will call out to the + * filter as it is constructing the DOM tree structure. The filter can + * choose to remove elements from the document being constructed, or to + * terminate the parsing early. + *
The filter is invoked after the operations requested by the + * DOMConfiguration parameters have been applied. For + * example, if " + * validate" is set to true, the validation is done before invoking the + * filter. + */ + public LSParserFilter getFilter(); + /** + * When a filter is provided, the implementation will call out to the + * filter as it is constructing the DOM tree structure. The filter can + * choose to remove elements from the document being constructed, or to + * terminate the parsing early. + *
The filter is invoked after the operations requested by the + * DOMConfiguration parameters have been applied. For + * example, if " + * validate" is set to true, the validation is done before invoking the + * filter. + */ + public void setFilter(LSParserFilter filter); + + /** + * true if the LSParser is asynchronous, + * false if it is synchronous. + */ + public boolean getAsync(); + + /** + * true if the LSParser is currently busy + * loading a document, otherwise false. + */ + public boolean getBusy(); + + /** + * Parse an XML document from a resource identified by a + * LSInput. + * @param input The LSInput from which the source of the + * document is to be read. + * @return If the LSParser is a synchronous + * LSParser, the newly created and populated + * Document is returned. If the LSParser is + * asynchronous, null is returned since the document + * object may not yet be constructed when this method returns. + * @exception DOMException + * INVALID_STATE_ERR: Raised if the LSParser's + * LSParser.busy attribute is true. + * @exception LSException + * PARSE_ERR: Raised if the LSParser was unable to load + * the XML document. DOM applications should attach a + * DOMErrorHandler using the parameter " + * error-handler" if they wish to get details on the error. + */ + public Document parse(LSInput input) + throws DOMException, LSException; + + /** + * Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. If the URI + * contains a fragment identifier (see section 4.1 in [IETF RFC 2396]), the + * behavior is not defined by this specification, future versions of + * this specification may define the behavior. + * @param uri The location of the XML document to be read. + * @return If the LSParser is a synchronous + * LSParser, the newly created and populated + * Document is returned, or null if an error + * occured. If the LSParser is asynchronous, + * null is returned since the document object may not yet + * be constructed when this method returns. + * @exception DOMException + * INVALID_STATE_ERR: Raised if the LSParser.busy + * attribute is true. + * @exception LSException + * PARSE_ERR: Raised if the LSParser was unable to load + * the XML document. DOM applications should attach a + * DOMErrorHandler using the parameter " + * error-handler" if they wish to get details on the error. + */ + public Document parseURI(String uri) + throws DOMException, LSException; + + // ACTION_TYPES + /** + * Append the result of the parse operation as children of the context + * node. For this action to work, the context node must be an + * Element or a DocumentFragment. + */ + public static final short ACTION_APPEND_AS_CHILDREN = 1; + /** + * Replace all the children of the context node with the result of the + * parse operation. For this action to work, the context node must be an + * Element, a Document, or a + * DocumentFragment. + */ + public static final short ACTION_REPLACE_CHILDREN = 2; + /** + * Insert the result of the parse operation as the immediately preceding + * sibling of the context node. For this action to work the context + * node's parent must be an Element or a + * DocumentFragment. + */ + public static final short ACTION_INSERT_BEFORE = 3; + /** + * Insert the result of the parse operation as the immediately following + * sibling of the context node. For this action to work the context + * node's parent must be an Element or a + * DocumentFragment. + */ + public static final short ACTION_INSERT_AFTER = 4; + /** + * Replace the context node with the result of the parse operation. For + * this action to work, the context node must have a parent, and the + * parent must be an Element or a + * DocumentFragment. + */ + public static final short ACTION_REPLACE = 5; + + /** + * Parse an XML fragment from a resource identified by a + * LSInput and insert the content into an existing document + * at the position specified with the context and + * action arguments. When parsing the input stream, the + * context node (or its parent, depending on where the result will be + * inserted) is used for resolving unbound namespace prefixes. The + * context node's ownerDocument node (or the node itself if + * the node of type DOCUMENT_NODE) is used to resolve + * default attributes and entity references. + *
As the new data is inserted into the document, at least one + * mutation event is fired per new immediate child or sibling of the + * context node. + *
If the context node is a Document node and the action + * is ACTION_REPLACE_CHILDREN, then the document that is + * passed as the context node will be changed such that its + * xmlEncoding, documentURI, + * xmlVersion, inputEncoding, + * xmlStandalone, and all other such attributes are set to + * what they would be set to if the input source was parsed using + * LSParser.parse(). + *
This method is always synchronous, even if the + * LSParser is asynchronous (LSParser.async is + * true). + *
If an error occurs while parsing, the caller is notified through + * the ErrorHandler instance associated with the " + * error-handler" parameter of the DOMConfiguration. + *
When calling parseWithContext, the values of the + * following configuration parameters will be ignored and their default + * values will always be used instead: " + * validate", " + * validate-if-schema", and " + * element-content-whitespace". Other parameters will be treated normally, and the parser is expected + * to call the LSParserFilter just as if a whole document + * was parsed. + * @param input The LSInput from which the source document + * is to be read. The source document must be an XML fragment, i.e. + * anything except a complete XML document (except in the case where + * the context node of type DOCUMENT_NODE, and the action + * is ACTION_REPLACE_CHILDREN), a DOCTYPE (internal + * subset), entity declaration(s), notation declaration(s), or XML or + * text declaration(s). + * @param contextArg The node that is used as the context for the data + * that is being parsed. This node must be a Document + * node, a DocumentFragment node, or a node of a type + * that is allowed as a child of an Element node, e.g. it + * cannot be an Attribute node. + * @param action This parameter describes which action should be taken + * between the new set of nodes being inserted and the existing + * children of the context node. The set of possible actions is + * defined in ACTION_TYPES above. + * @return Return the node that is the result of the parse operation. If + * the result is more than one top-level node, the first one is + * returned. + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if the content cannot replace, be + * inserted before, after, or as a child of the context node (see also + * Node.insertBefore or Node.replaceChild in [DOM Level 3 Core] + * ). + *
NOT_SUPPORTED_ERR: Raised if the LSParser doesn't + * support this method, or if the context node is of type + * Document and the DOM implementation doesn't support + * the replacement of the DocumentType child or + * Element child. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is a + * read only node and the content is being appended to its child list, + * or if the parent node of the context node is read only node and the + * content is being inserted in its child list. + *
INVALID_STATE_ERR: Raised if the LSParser.busy + * attribute is true. + * @exception LSException + * PARSE_ERR: Raised if the LSParser was unable to load + * the XML fragment. DOM applications should attach a + * DOMErrorHandler using the parameter " + * error-handler" if they wish to get details on the error. + */ + public Node parseWithContext(LSInput input, + Node contextArg, + short action) + throws DOMException, LSException; + + /** + * Abort the loading of the document that is currently being loaded by + * the LSParser. If the LSParser is currently + * not busy, a call to this method does nothing. + */ + public void abort(); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSParserFilter.java b/java/external/src/org/w3c/dom/ls/LSParserFilter.java new file mode 100644 index 0000000..4e61294 --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSParserFilter.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.Node; +import org.w3c.dom.Element; + +/** + * LSParserFilters provide applications the ability to examine + * nodes as they are being constructed while parsing. As each node is + * examined, it may be modified or removed, or the entire parse may be + * terminated early. + *

At the time any of the filter methods are called by the parser, the + * owner Document and DOMImplementation objects exist and are accessible. + * The document element is never passed to the LSParserFilter + * methods, i.e. it is not possible to filter out the document element. + * Document, DocumentType, Notation, + * Entity, and Attr nodes are never passed to the + * acceptNode method on the filter. The child nodes of an + * EntityReference node are passed to the filter if the + * parameter " + * entities" is set to false. Note that, as described by the parameter " + * entities", unexpanded entity reference nodes are never discarded and are always + * passed to the filter. + *

All validity checking while parsing a document occurs on the source + * document as it appears on the input stream, not on the DOM document as it + * is built in memory. With filters, the document in memory may be a subset + * of the document on the stream, and its validity may have been affected by + * the filtering. + *

All default attributes must be present on elements when the elements + * are passed to the filter methods. All other default content must be + * passed to the filter methods. + *

DOM applications must not raise exceptions in a filter. The effect of + * throwing exceptions from a filter is DOM implementation dependent. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSParserFilter { + // Constants returned by startElement and acceptNode + /** + * Accept the node. + */ + public static final short FILTER_ACCEPT = 1; + /** + * Reject the node and its children. + */ + public static final short FILTER_REJECT = 2; + /** + * Skip this single node. The children of this node will still be + * considered. + */ + public static final short FILTER_SKIP = 3; + /** + * Interrupt the normal processing of the document. + */ + public static final short FILTER_INTERRUPT = 4; + + /** + * The parser will call this method after each Element start + * tag has been scanned, but before the remainder of the + * Element is processed. The intent is to allow the + * element, including any children, to be efficiently skipped. Note that + * only element nodes are passed to the startElement + * function. + *
The element node passed to startElement for filtering + * will include all of the Element's attributes, but none of the + * children nodes. The Element may not yet be in place in the document + * being constructed (it may not have a parent node.) + *
A startElement filter function may access or change + * the attributes for the Element. Changing Namespace declarations will + * have no effect on namespace resolution by the parser. + *
For efficiency, the Element node passed to the filter may not be + * the same one as is actually placed in the tree if the node is + * accepted. And the actual node (node object identity) may be reused + * during the process of reading in and filtering a document. + * @param elementArg The newly encountered element. At the time this + * method is called, the element is incomplete - it will have its + * attributes, but no children. + * @return + *

Returning + * any other values will result in unspecified behavior. + */ + public short startElement(Element elementArg); + + /** + * This method will be called by the parser at the completion of the + * parsing of each node. The node and all of its descendants will exist + * and be complete. The parent node will also exist, although it may be + * incomplete, i.e. it may have additional children that have not yet + * been parsed. Attribute nodes are never passed to this function. + *
From within this method, the new node may be freely modified - + * children may be added or removed, text nodes modified, etc. The state + * of the rest of the document outside this node is not defined, and the + * affect of any attempt to navigate to, or to modify any other part of + * the document is undefined. + *
For validating parsers, the checks are made on the original + * document, before any modification by the filter. No validity checks + * are made on any document modifications made by the filter. + *
If this new node is rejected, the parser might reuse the new node + * and any of its descendants. + * @param nodeArg The newly constructed element. At the time this method + * is called, the element is complete - it has all of its children + * (and their children, recursively) and attributes, and is attached + * as a child to its parent. + * @return + * + */ + public short acceptNode(Node nodeArg); + + /** + * Tells the LSParser what types of nodes to show to the + * method LSParserFilter.acceptNode. If a node is not shown + * to the filter using this attribute, it is automatically included in + * the DOM document being built. See NodeFilter for + * definition of the constants. The constants SHOW_ATTRIBUTE + * , SHOW_DOCUMENT, SHOW_DOCUMENT_TYPE, + * SHOW_NOTATION, SHOW_ENTITY, and + * SHOW_DOCUMENT_FRAGMENT are meaningless here. Those nodes + * will never be passed to LSParserFilter.acceptNode. + *
The constants used here are defined in [DOM Level 2 Traversal and Range] + * . + */ + public int getWhatToShow(); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSProgressEvent.java b/java/external/src/org/w3c/dom/ls/LSProgressEvent.java new file mode 100644 index 0000000..da98e14 --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSProgressEvent.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.events.Event; + +/** + * This interface represents a progress event object that notifies the + * application about progress as a document is parsed. It extends the + * Event interface defined in [DOM Level 3 Events] + * . + *

The units used for the attributes position and + * totalSize are not specified and can be implementation and + * input dependent. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSProgressEvent extends Event { + /** + * The input source that is being parsed. + */ + public LSInput getInput(); + + /** + * The current position in the input source, including all external + * entities and other resources that have been read. + */ + public int getPosition(); + + /** + * The total size of the document including all external resources, this + * number might change as a document is being parsed if references to + * more external resources are seen. A value of 0 is + * returned if the total size cannot be determined or estimated. + */ + public int getTotalSize(); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSResourceResolver.java b/java/external/src/org/w3c/dom/ls/LSResourceResolver.java new file mode 100644 index 0000000..c0c523c --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSResourceResolver.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +/** + * LSResourceResolver provides a way for applications to + * redirect references to external resources. + *

Applications needing to implement custom handling for external + * resources can implement this interface and register their implementation + * by setting the "resource-resolver" parameter of + * DOMConfiguration objects attached to LSParser + * and LSSerializer. It can also be register on + * DOMConfiguration objects attached to Document + * if the "LS" feature is supported. + *

The LSParser will then allow the application to intercept + * any external entities, including the external DTD subset and external + * parameter entities, before including them. The top-level document entity + * is never passed to the resolveResource method. + *

Many DOM applications will not need to implement this interface, but it + * will be especially useful for applications that build XML documents from + * databases or other specialized input sources, or for applications that + * use URNs. + *

Note: LSResourceResolver is based on the SAX2 [SAX] EntityResolver + * interface. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSResourceResolver { + /** + * Allow the application to resolve external resources. + *
The LSParser will call this method before opening any + * external resource, including the external DTD subset, external + * entities referenced within the DTD, and external entities referenced + * within the document element (however, the top-level document entity + * is not passed to this method). The application may then request that + * the LSParser resolve the external resource itself, that + * it use an alternative URI, or that it use an entirely different input + * source. + *
Application writers can use this method to redirect external + * system identifiers to secure and/or local URI, to look up public + * identifiers in a catalogue, or to read an entity from a database or + * other input source (including, for example, a dialog box). + * @param type The type of the resource being resolved. For XML [XML 1.0] resources + * (i.e. entities), applications must use the value + * "http://www.w3.org/TR/REC-xml". For XML Schema [XML Schema Part 1] + * , applications must use the value + * "http://www.w3.org/2001/XMLSchema". Other types of + * resources are outside the scope of this specification and therefore + * should recommend an absolute URI in order to use this method. + * @param namespaceURI The namespace of the resource being resolved, + * e.g. the target namespace of the XML Schema [XML Schema Part 1] + * when resolving XML Schema resources. + * @param publicId The public identifier of the external entity being + * referenced, or null if no public identifier was + * supplied or if the resource is not an entity. + * @param systemId The system identifier, a URI reference [IETF RFC 2396], of the + * external resource being referenced, or null if no + * system identifier was supplied. + * @param baseURI The absolute base URI of the resource being parsed, or + * null if there is no base URI. + * @return A LSInput object describing the new input + * source, or null to request that the parser open a + * regular URI connection to the resource. + */ + public LSInput resolveResource(String type, + String namespaceURI, + String publicId, + String systemId, + String baseURI); + +} diff --git a/java/external/src/org/w3c/dom/ls/LSSerializer.java b/java/external/src/org/w3c/dom/ls/LSSerializer.java new file mode 100644 index 0000000..e7b6350 --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSSerializer.java @@ -0,0 +1,436 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.Node; +import org.w3c.dom.DOMException; + +/** + * A LSSerializer provides an API for serializing (writing) a + * DOM document out into XML. The XML data is written to a string or an + * output stream. Any changes or fixups made during the serialization affect + * only the serialized data. The Document object and its + * children are never altered by the serialization operation. + *

During serialization of XML data, namespace fixup is done as defined in [DOM Level 3 Core] + * , Appendix B. [DOM Level 2 Core] + * allows empty strings as a real namespace URI. If the + * namespaceURI of a Node is empty string, the + * serialization will treat them as null, ignoring the prefix + * if any. + *

LSSerializer accepts any node type for serialization. For + * nodes of type Document or Entity, well-formed + * XML will be created when possible (well-formedness is guaranteed if the + * document or entity comes from a parse operation and is unchanged since it + * was created). The serialized output for these node types is either as a + * XML document or an External XML Entity, respectively, and is acceptable + * input for an XML parser. For all other types of nodes the serialized form + * is implementation dependent. + *

Within a Document, DocumentFragment, or + * Entity being serialized, Nodes are processed as + * follows + *

+ *

Note: The serialization of a Node does not always + * generate a well-formed XML document, i.e. a LSParser might + * throw fatal errors when parsing the resulting serialization. + *

Within the character data of a document (outside of markup), any + * characters that cannot be represented directly are replaced with + * character references. Occurrences of '<' and '&' are replaced by + * the predefined entities &lt; and &amp;. The other predefined + * entities (&gt;, &apos;, and &quot;) might not be used, except + * where needed (e.g. using &gt; in cases such as ']]>'). Any + * characters that cannot be represented directly in the output character + * encoding are serialized as numeric character references (and since + * character encoding standards commonly use hexadecimal representations of + * characters, using the hexadecimal representation when serializing + * character references is encouraged). + *

To allow attribute values to contain both single and double quotes, the + * apostrophe or single-quote character (') may be represented as + * "&apos;", and the double-quote character (") as "&quot;". New + * line characters and other characters that cannot be represented directly + * in attribute values in the output character encoding are serialized as a + * numeric character reference. + *

Within markup, but outside of attributes, any occurrence of a character + * that cannot be represented in the output character encoding is reported + * as a DOMError fatal error. An example would be serializing + * the element <LaCa\u00f1ada/> with encoding="us-ascii". + * This will result with a generation of a DOMError + * "wf-invalid-character-in-node-name" (as proposed in " + * well-formed"). + *

When requested by setting the parameter " + * normalize-characters" on LSSerializer to true, character normalization is + * performed according to the definition of fully + * normalized characters included in appendix E of [XML 1.1] on all + * data to be serialized, both markup and character data. The character + * normalization process affects only the data as it is being written; it + * does not alter the DOM's view of the document after serialization has + * completed. + *

Implementations are required to support the encodings "UTF-8", + * "UTF-16", "UTF-16BE", and "UTF-16LE" to guarantee that data is + * serializable in all encodings that are required to be supported by all + * XML parsers. When the encoding is UTF-8, whether or not a byte order mark + * is serialized, or if the output is big-endian or little-endian, is + * implementation dependent. When the encoding is UTF-16, whether or not the + * output is big-endian or little-endian is implementation dependent, but a + * Byte Order Mark must be generated for non-character outputs, such as + * LSOutput.byteStream or LSOutput.systemId. If + * the Byte Order Mark is not generated, a "byte-order-mark-needed" warning + * is reported. When the encoding is UTF-16LE or UTF-16BE, the output is + * big-endian (UTF-16BE) or little-endian (UTF-16LE) and the Byte Order Mark + * is not be generated. In all cases, the encoding declaration, if + * generated, will correspond to the encoding used during the serialization + * (e.g. encoding="UTF-16" will appear if UTF-16 was + * requested). + *

Namespaces are fixed up during serialization, the serialization process + * will verify that namespace declarations, namespace prefixes and the + * namespace URI associated with elements and attributes are consistent. If + * inconsistencies are found, the serialized form of the document will be + * altered to remove them. The method used for doing the namespace fixup + * while serializing a document is the algorithm defined in Appendix B.1, + * "Namespace normalization", of [DOM Level 3 Core] + * . + *

While serializing a document, the parameter "discard-default-content" + * controls whether or not non-specified data is serialized. + *

While serializing, errors and warnings are reported to the application + * through the error handler (LSSerializer.domConfig's " + * error-handler" parameter). This specification does in no way try to define all possible + * errors and warnings that can occur while serializing a DOM node, but some + * common error and warning cases are defined. The types ( + * DOMError.type) of errors and warnings defined by this + * specification are: + *

+ *
"no-output-specified" [fatal]
+ *
Raised when + * writing to a LSOutput if no output is specified in the + * LSOutput.
+ *
+ * "unbound-prefix-in-entity-reference" [fatal]
+ *
Raised if the + * configuration parameter " + * namespaces" is set to true and an entity whose replacement text + * contains unbound namespace prefixes is referenced in a location where + * there are no bindings for the namespace prefixes.
+ *
+ * "unsupported-encoding" [fatal]
+ *
Raised if an unsupported + * encoding is encountered.
+ *
+ *

In addition to raising the defined errors and warnings, implementations + * are expected to raise implementation specific errors and warnings for any + * other error and warning cases such as IO errors (file not found, + * permission denied,...) and so on. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSSerializer { + /** + * The DOMConfiguration object used by the + * LSSerializer when serializing a DOM node. + *
In addition to the parameters recognized by the + * DOMConfiguration interface defined in [DOM Level 3 Core] + * , the DOMConfiguration objects for + * LSSerializer adds, or modifies, the following + * parameters: + *

+ *
"canonical-form"
+ *
+ *
+ *
true
+ *
[optional] Writes the document according to the rules specified in [Canonical XML]. + * In addition to the behavior described in " + * canonical-form" [DOM Level 3 Core] + * , setting this parameter to true will set the parameters + * "format-pretty-print", "discard-default-content", and "xml-declaration + * ", to false. Setting one of those parameters to + * true will set this parameter to false. + * Serializing an XML 1.1 document when "canonical-form" is + * true will generate a fatal error.
+ *
false
+ *
[required] (default) Do not canonicalize the output.
+ *
+ *
"discard-default-content"
+ *
+ *
+ *
+ * true
+ *
[required] (default) Use the Attr.specified attribute to decide what attributes + * should be discarded. Note that some implementations might use + * whatever information available to the implementation (i.e. XML + * schema, DTD, the Attr.specified attribute, and so on) to + * determine what attributes and content to discard if this parameter is + * set to true.
+ *
false
+ *
[required]Keep all attributes and all content.
+ *
+ *
"format-pretty-print"
+ *
+ *
+ *
+ * true
+ *
[optional] Formatting the output by adding whitespace to produce a pretty-printed, + * indented, human-readable form. The exact form of the transformations + * is not specified by this specification. Pretty-printing changes the + * content of the document and may affect the validity of the document, + * validating implementations should preserve validity.
+ *
+ * false
+ *
[required] (default) Don't pretty-print the result.
+ *
+ *
+ * "ignore-unknown-character-denormalizations"
+ *
+ *
+ *
+ * true
+ *
[required] (default) If, while verifying full normalization when [XML 1.1] is + * supported, a character is encountered for which the normalization + * properties cannot be determined, then raise a + * "unknown-character-denormalization" warning (instead of + * raising an error, if this parameter is not set) and ignore any + * possible denormalizations caused by these characters.
+ *
+ * false
+ *
[optional] Report a fatal error if a character is encountered for which the + * processor cannot determine the normalization properties.
+ *
+ *
+ * "normalize-characters"
+ *
This parameter is equivalent to + * the one defined by DOMConfiguration in [DOM Level 3 Core] + * . Unlike in the Core, the default value for this parameter is + * true. While DOM implementations are not required to + * support fully + * normalizing the characters in the document according to appendix E of [XML 1.1], this + * parameter must be activated by default if supported.
+ *
+ * "xml-declaration"
+ *
+ *
+ *
true
+ *
[required] (default) If a Document, Element, or Entity + * node is serialized, the XML declaration, or text declaration, should + * be included. The version (Document.xmlVersion if the + * document is a Level 3 document and the version is non-null, otherwise + * use the value "1.0"), and the output encoding (see + * LSSerializer.write for details on how to find the output + * encoding) are specified in the serialized XML declaration.
+ *
+ * false
+ *
[required] Do not serialize the XML and text declarations. Report a + * "xml-declaration-needed" warning if this will cause + * problems (i.e. the serialized data is of an XML version other than [XML 1.0], or an + * encoding would be needed to be able to re-parse the serialized data).
+ *
+ *
+ */ + public DOMConfiguration getDomConfig(); + + /** + * The end-of-line sequence of characters to be used in the XML being + * written out. Any string is supported, but XML treats only a certain + * set of characters sequence as end-of-line (See section 2.11, + * "End-of-Line Handling" in [XML 1.0], if the + * serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" + * in [XML 1.1], if the + * serialized content is XML 1.1). Using other character sequences than + * the recommended ones can result in a document that is either not + * serializable or not well-formed). + *
On retrieval, the default value of this attribute is the + * implementation specific default end-of-line sequence. DOM + * implementations should choose the default to match the usual + * convention for text files in the environment being used. + * Implementations must choose a default sequence that matches one of + * those allowed by XML 1.0 or XML 1.1, depending on the serialized + * content. Setting this attribute to null will reset its + * value to the default value. + *
+ */ + public String getNewLine(); + /** + * The end-of-line sequence of characters to be used in the XML being + * written out. Any string is supported, but XML treats only a certain + * set of characters sequence as end-of-line (See section 2.11, + * "End-of-Line Handling" in [XML 1.0], if the + * serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" + * in [XML 1.1], if the + * serialized content is XML 1.1). Using other character sequences than + * the recommended ones can result in a document that is either not + * serializable or not well-formed). + *
On retrieval, the default value of this attribute is the + * implementation specific default end-of-line sequence. DOM + * implementations should choose the default to match the usual + * convention for text files in the environment being used. + * Implementations must choose a default sequence that matches one of + * those allowed by XML 1.0 or XML 1.1, depending on the serialized + * content. Setting this attribute to null will reset its + * value to the default value. + *
+ */ + public void setNewLine(String newLine); + + /** + * When the application provides a filter, the serializer will call out + * to the filter before serializing each Node. The filter implementation + * can choose to remove the node from the stream or to terminate the + * serialization early. + *
The filter is invoked after the operations requested by the + * DOMConfiguration parameters have been applied. For + * example, CDATA sections won't be passed to the filter if " + * cdata-sections" is set to false. + */ + public LSSerializerFilter getFilter(); + /** + * When the application provides a filter, the serializer will call out + * to the filter before serializing each Node. The filter implementation + * can choose to remove the node from the stream or to terminate the + * serialization early. + *
The filter is invoked after the operations requested by the + * DOMConfiguration parameters have been applied. For + * example, CDATA sections won't be passed to the filter if " + * cdata-sections" is set to false. + */ + public void setFilter(LSSerializerFilter filter); + + /** + * Serialize the specified node as described above in the general + * description of the LSSerializer interface. The output is + * written to the supplied LSOutput. + *
When writing to a LSOutput, the encoding is found by + * looking at the encoding information that is reachable through the + * LSOutput and the item to be written (or its owner + * document) in this order: + *
    + *
  1. LSOutput.encoding, + *
  2. + *
  3. + * Document.inputEncoding, + *
  4. + *
  5. + * Document.xmlEncoding. + *
  6. + *
+ *
If no encoding is reachable through the above properties, a + * default encoding of "UTF-8" will be used. If the specified encoding + * is not supported an "unsupported-encoding" fatal error is raised. + *
If no output is specified in the LSOutput, a + * "no-output-specified" fatal error is raised. + *
The implementation is responsible of associating the appropriate + * media type with the serialized data. + *
When writing to a HTTP URI, a HTTP PUT is performed. When writing + * to other types of URIs, the mechanism for writing the data to the URI + * is implementation dependent. + * @param nodeArg The node to serialize. + * @param destination The destination for the serialized DOM. + * @return Returns true if node was + * successfully serialized. Return false in case the + * normal processing stopped but the implementation kept serializing + * the document; the result of the serialization being implementation + * dependent then. + * @exception LSException + * SERIALIZE_ERR: Raised if the LSSerializer was unable to + * serialize the node. DOM applications should attach a + * DOMErrorHandler using the parameter " + * error-handler" if they wish to get details on the error. + */ + public boolean write(Node nodeArg, + LSOutput destination) + throws LSException; + + /** + * A convenience method that acts as if LSSerializer.write + * was called with a LSOutput with no encoding specified + * and LSOutput.systemId set to the uri + * argument. + * @param nodeArg The node to serialize. + * @param uri The URI to write to. + * @return Returns true if node was + * successfully serialized. Return false in case the + * normal processing stopped but the implementation kept serializing + * the document; the result of the serialization being implementation + * dependent then. + * @exception LSException + * SERIALIZE_ERR: Raised if the LSSerializer was unable to + * serialize the node. DOM applications should attach a + * DOMErrorHandler using the parameter " + * error-handler" if they wish to get details on the error. + */ + public boolean writeToURI(Node nodeArg, + String uri) + throws LSException; + + /** + * Serialize the specified node as described above in the general + * description of the LSSerializer interface. The output is + * written to a DOMString that is returned to the caller. + * The encoding used is the encoding of the DOMString type, + * i.e. UTF-16. Note that no Byte Order Mark is generated in a + * DOMString object. + * @param nodeArg The node to serialize. + * @return Returns the serialized data. + * @exception DOMException + * DOMSTRING_SIZE_ERR: Raised if the resulting string is too long to + * fit in a DOMString. + * @exception LSException + * SERIALIZE_ERR: Raised if the LSSerializer was unable to + * serialize the node. DOM applications should attach a + * DOMErrorHandler using the parameter " + * error-handler" if they wish to get details on the error. + */ + public String writeToString(Node nodeArg) + throws DOMException, LSException; + +} diff --git a/java/external/src/org/w3c/dom/ls/LSSerializerFilter.java b/java/external/src/org/w3c/dom/ls/LSSerializerFilter.java new file mode 100644 index 0000000..049459c --- /dev/null +++ b/java/external/src/org/w3c/dom/ls/LSSerializerFilter.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2004 World Wide Web Consortium, + * + * (Massachusetts Institute of Technology, European Research Consortium for + * Informatics and Mathematics, Keio University). All Rights Reserved. This + * work is distributed under the W3C(r) Software License [1] in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + */ + +package org.w3c.dom.ls; + +import org.w3c.dom.traversal.NodeFilter; + +/** + * LSSerializerFilters provide applications the ability to + * examine nodes as they are being serialized and decide what nodes should + * be serialized or not. The LSSerializerFilter interface is + * based on the NodeFilter interface defined in [DOM Level 2 Traversal and Range] + * . + *

Document, DocumentType, + * DocumentFragment, Notation, Entity + * , and children of Attr nodes are not passed to the filter. + * The child nodes of an EntityReference node are only passed + * to the filter if the EntityReference node is skipped by the + * method LSParserFilter.acceptNode(). + *

When serializing an Element, the element is passed to the + * filter before any of its attributes are passed to the filter. Namespace + * declaration attributes, and default attributes (except in the case when " + * discard-default-content" is set to false), are never passed + * to the filter. + *

The result of any attempt to modify a node passed to a + * LSSerializerFilter is implementation dependent. + *

DOM applications must not raise exceptions in a filter. The effect of + * throwing exceptions from a filter is DOM implementation dependent. + *

For efficiency, a node passed to the filter may not be the same as the + * one that is actually in the tree. And the actual node (node object + * identity) may be reused during the process of filtering and serializing a + * document. + *

See also the Document Object Model (DOM) Level 3 Load +and Save Specification. + */ +public interface LSSerializerFilter extends NodeFilter { + /** + * Tells the LSSerializer what types of nodes to show to the + * filter. If a node is not shown to the filter using this attribute, it + * is automatically serialized. See NodeFilter for + * definition of the constants. The constants SHOW_DOCUMENT + * , SHOW_DOCUMENT_TYPE, SHOW_DOCUMENT_FRAGMENT + * , SHOW_NOTATION, and SHOW_ENTITY are + * meaningless here, such nodes will never be passed to a + * LSSerializerFilter. + *
Unlike [DOM Level 2 Traversal and Range] + * , the SHOW_ATTRIBUTE constant indicates that the + * Attr nodes are shown and passed to the filter. + *
The constants used here are defined in [DOM Level 2 Traversal and Range] + * . + */ + public int getWhatToShow(); + +} diff --git a/java/external/src/org/w3c/dom/traversal/DocumentTraversal.java b/java/external/src/org/w3c/dom/traversal/DocumentTraversal.java index 103cde0..bc45ad9 100644 --- a/java/external/src/org/w3c/dom/traversal/DocumentTraversal.java +++ b/java/external/src/org/w3c/dom/traversal/DocumentTraversal.java @@ -41,7 +41,8 @@ public interface DocumentTraversal { * NodeFilter for the set of possible SHOW_ * values.These flags can be combined using OR. * @param filter The NodeFilter to be used with this - * TreeWalker, or null to indicate no filter. + * NodeIterator, or null to indicate no + * filter. * @param entityReferenceExpansion The value of this flag determines * whether entity reference nodes are expanded. * @return The newly created NodeIterator. diff --git a/java/external/src/org/w3c/dom/traversal/TreeWalker.java b/java/external/src/org/w3c/dom/traversal/TreeWalker.java index e90da06..f5fff86 100644 --- a/java/external/src/org/w3c/dom/traversal/TreeWalker.java +++ b/java/external/src/org/w3c/dom/traversal/TreeWalker.java @@ -83,9 +83,6 @@ public interface TreeWalker { * currentNode even if it is not part of the current view, * by applying the filters in the requested direction; if no traversal * is possible, currentNode is not changed. - * @exception DOMException - * NOT_SUPPORTED_ERR: Raised if an attempt is made to set - * currentNode to null. */ public Node getCurrentNode(); /** diff --git a/java/external/src/org/xml/sax/AttributeList.java b/java/external/src/org/xml/sax/AttributeList.java index 2391b50..0e82bce 100644 --- a/java/external/src/org/xml/sax/AttributeList.java +++ b/java/external/src/org/xml/sax/AttributeList.java @@ -181,7 +181,7 @@ public interface AttributeList { *

If the attribute name has a namespace prefix in the document, * the application must include the prefix here.

* - * @param i The index of the attribute in the list. + * @param name the name of the attribute to return * @return The attribute value as a string, or null if * no such attribute exists. * @see #getValue(int) diff --git a/java/external/src/org/xml/sax/Attributes.java b/java/external/src/org/xml/sax/Attributes.java index 8e4f27c..39c891a 100644 --- a/java/external/src/org/xml/sax/Attributes.java +++ b/java/external/src/org/xml/sax/Attributes.java @@ -2,10 +2,8 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the public domain. - // $Id$ - package org.xml.sax; @@ -34,18 +32,25 @@ package org.xml.sax; * the http://xml.org/sax/features/namespace-prefixes * feature is set to true (it is false by * default). - * Because SAX2 conforms to the "Namespaces in XML" specification, - * it does not give namespace declaration attributes a namespace URI. - * Some other W3C specifications are in conflict with that, expecting - * these declarations to be in a namespace. - * Handler code may need to resolve that conflict. + * Because SAX2 conforms to the original "Namespaces in XML" + * recommendation, it normally does not + * give namespace declaration attributes a namespace URI. *

* - *

If the namespace-prefixes feature (see above) is false, - * access by qualified name may not be available; if the - * http://xml.org/sax/features/namespaces - * feature is false, access by Namespace-qualified names - * may not be available.

+ *

Some SAX2 parsers may support using an optional feature flag + * (http://xml.org/sax/features/xmlns-uris) to request + * that those attributes be given URIs, conforming to a later + * backwards-incompatible revision of that recommendation. (The + * attribute's "local name" will be the prefix, or "xmlns" when + * defining a default element namespace.) For portability, handler + * code should always resolve that conflict, rather than requiring + * parsers that can change the setting of that feature flag.

+ * + *

If the namespace-prefixes feature (see above) is + * false, access by qualified name may not be available; if + * the http://xml.org/sax/features/namespaces feature is + * false, access by Namespace-qualified names may not be + * available.

* *

This interface replaces the now-deprecated SAX1 {@link * org.xml.sax.AttributeList AttributeList} interface, which does not @@ -111,10 +116,10 @@ public interface Attributes /** - * Look up an attribute's XML 1.0 qualified name by index. + * Look up an attribute's XML qualified (prefixed) name by index. * * @param index The attribute index (zero-based). - * @return The XML 1.0 qualified name, or the empty string + * @return The XML qualified name, or the empty string * if none is available, or null if the index * is out of range. * @see #getLength @@ -131,7 +136,7 @@ public interface Attributes * *

If the parser has not read a declaration for the attribute, * or if the parser does not report attribute types, then it must - * return the value "CDATA" as stated in the XML 1.0 Recommentation + * return the value "CDATA" as stated in the XML 1.0 Recommendation * (clause 3.3.3, "Attribute-Value Normalization").

* *

For an enumerated attribute that is not a notation, the @@ -180,7 +185,7 @@ public interface Attributes /** - * Look up the index of an attribute by XML 1.0 qualified name. + * Look up the index of an attribute by XML qualified (prefixed) name. * * @param qName The qualified (prefixed) name. * @return The index of the attribute, or -1 if it does not @@ -206,12 +211,12 @@ public interface Attributes /** - * Look up an attribute's type by XML 1.0 qualified name. + * Look up an attribute's type by XML qualified (prefixed) name. * *

See {@link #getType(int) getType(int)} for a description * of the possible types.

* - * @param qName The XML 1.0 qualified name. + * @param qName The XML qualified name. * @return The attribute type as a string, or null if the * attribute is not in the list or if qualified names * are not available. @@ -235,12 +240,12 @@ public interface Attributes /** - * Look up an attribute's value by XML 1.0 qualified name. + * Look up an attribute's value by XML qualified (prefixed) name. * *

See {@link #getValue(int) getValue(int)} for a description * of the possible values.

* - * @param qName The XML 1.0 qualified name. + * @param qName The XML qualified name. * @return The attribute value as a string, or null if the * attribute is not in the list or if qualified names * are not available. diff --git a/java/external/src/org/xml/sax/ContentHandler.java b/java/external/src/org/xml/sax/ContentHandler.java index 4f74805..56b6152 100644 --- a/java/external/src/org/xml/sax/ContentHandler.java +++ b/java/external/src/org/xml/sax/ContentHandler.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the public domain. - // $Id$ package org.xml.sax; @@ -37,14 +36,13 @@ package org.xml.sax; * and for reporting skipped entities (in non-validating XML * processors).

* - *

Implementors should note that there is also a Java class - * {@link java.net.ContentHandler ContentHandler} in the java.net + *

Implementors should note that there is also a + * ContentHandler class in the java.net * package; that means that it's probably a bad idea to do

* - *
- * import java.net.*; + *
import java.net.*;
  * import org.xml.sax.*;
- * 
+ * * *

In fact, "import ...*" is usually a sign of sloppy programming * anyway, so the user should consider this a feature rather than a @@ -52,7 +50,7 @@ package org.xml.sax; * * @since SAX 2.0 * @author David Megginson - * @version 2.0.1 (sax2r2) + * @version 2.0.1+ (sax2r3pre1) * @see org.xml.sax.XMLReader * @see org.xml.sax.DTDHandler * @see org.xml.sax.ErrorHandler @@ -78,11 +76,13 @@ public interface ContentHandler * is probably not sufficient for use with a search engine.

* *

Note that the locator will return correct information only - * during the invocation of the events in this interface. The + * during the invocation SAX event callbacks after + * {@link #startDocument startDocument} returns and before + * {@link #endDocument endDocument} is called. The * application should not attempt to use it at any other time.

* - * @param locator An object that can return the location of - * any SAX document event. + * @param locator an object that can return the location of + * any SAX document event * @see org.xml.sax.Locator */ public void setDocumentLocator (Locator locator); @@ -95,8 +95,8 @@ public interface ContentHandler * other event callbacks (except for {@link #setDocumentLocator * setDocumentLocator}).

* - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception * @see #endDocument */ public void startDocument () @@ -106,14 +106,22 @@ public interface ContentHandler /** * Receive notification of the end of a document. * + *

There is an apparent contradiction between the + * documentation for this method and the documentation for {@link + * org.xml.sax.ErrorHandler#fatalError}. Until this ambiguity is + * resolved in a future major release, clients should make no + * assumptions about whether endDocument() will or will not be + * invoked when the parser has reported a fatalError() or thrown + * an exception.

+ * *

The SAX parser will invoke this method only once, and it will * be the last method invoked during the parse. The parser shall * not invoke this method until it has either abandoned parsing * (because of an unrecoverable error) or reached the end of * input.

* - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception * @see #startDocument */ public void endDocument() @@ -149,12 +157,12 @@ public interface ContentHandler *

There should never be start/endPrefixMapping events for the * "xml" prefix, since it is predeclared and immutable.

* - * @param prefix The Namespace prefix being declared. + * @param prefix the Namespace prefix being declared. * An empty string is used for the default element namespace, * which has no prefix. - * @param uri The Namespace URI the prefix is mapped to. - * @exception org.xml.sax.SAXException The client may throw - * an exception during processing. + * @param uri the Namespace URI the prefix is mapped to + * @throws org.xml.sax.SAXException the client may throw + * an exception during processing * @see #endPrefixMapping * @see #startElement */ @@ -171,10 +179,10 @@ public interface ContentHandler * {@link #endPrefixMapping endPrefixMapping} events is not otherwise * guaranteed.

* - * @param prefix The prefix that was being mapping. + * @param prefix the prefix that was being mapped. * This is the empty string when a default mapping scope ends. - * @exception org.xml.sax.SAXException The client may throw - * an exception during processing. + * @throws org.xml.sax.SAXException the client may throw + * an exception during processing * @see #startPrefixMapping * @see #endElement */ @@ -228,21 +236,23 @@ public interface ContentHandler *

Like {@link #characters characters()}, attribute values may have * characters that need more than one char value.

* - * @param uri The Namespace URI, or the empty string if the + * @param uri the Namespace URI, or the empty string if the * element has no Namespace URI or if Namespace - * processing is not being performed. - * @param localName The local name (without prefix), or the + * processing is not being performed + * @param localName the local name (without prefix), or the * empty string if Namespace processing is not being - * performed. - * @param qName The qualified name (with prefix), or the - * empty string if qualified names are not available. - * @param atts The attributes attached to the element. If + * performed + * @param qName the qualified name (with prefix), or the + * empty string if qualified names are not available + * @param atts the attributes attached to the element. If * there are no attributes, it shall be an empty - * Attributes object. - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * Attributes object. The value of this object after + * startElement returns is undefined + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception * @see #endElement * @see org.xml.sax.Attributes + * @see org.xml.sax.helpers.AttributesImpl */ public void startElement (String uri, String localName, String qName, Attributes atts) @@ -259,16 +269,16 @@ public interface ContentHandler * *

For information on the names, see startElement.

* - * @param uri The Namespace URI, or the empty string if the + * @param uri the Namespace URI, or the empty string if the * element has no Namespace URI or if Namespace - * processing is not being performed. - * @param localName The local name (without prefix), or the + * processing is not being performed + * @param localName the local name (without prefix), or the * empty string if Namespace processing is not being - * performed. - * @param qName The qualified XML 1.0 name (with prefix), or the - * empty string if qualified names are not available. - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * performed + * @param qName the qualified XML name (with prefix), or the + * empty string if qualified names are not available + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception */ public void endElement (String uri, String localName, String qName) @@ -310,11 +320,11 @@ public interface ContentHandler * method rather than this one (validating parsers must * do so).

* - * @param ch The characters from the XML document. - * @param start The start position in the array. - * @param length The number of characters to read from the array. - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * @param ch the characters from the XML document + * @param start the start position in the array + * @param length the number of characters to read from the array + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception * @see #ignorableWhitespace * @see org.xml.sax.Locator */ @@ -326,9 +336,10 @@ public interface ContentHandler * Receive notification of ignorable whitespace in element content. * *

Validating Parsers must use this method to report each chunk - * of whitespace in element content (see the W3C XML 1.0 recommendation, - * section 2.10): non-validating parsers may also use this method - * if they are capable of parsing and using content models.

+ * of whitespace in element content (see the W3C XML 1.0 + * recommendation, section 2.10): non-validating parsers may also + * use this method if they are capable of parsing and using + * content models.

* *

SAX parsers may return all contiguous whitespace in a single * chunk, or they may split it into several chunks; however, all of @@ -339,11 +350,11 @@ public interface ContentHandler *

The application must not attempt to read from the array * outside of the specified range.

* - * @param ch The characters from the XML document. - * @param start The start position in the array. - * @param length The number of characters to read from the array. - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * @param ch the characters from the XML document + * @param start the start position in the array + * @param length the number of characters to read from the array + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception * @see #characters */ public void ignorableWhitespace (char ch[], int start, int length) @@ -365,12 +376,12 @@ public interface ContentHandler * data may have characters that need more than one char * value.

* - * @param target The processing instruction target. - * @param data The processing instruction data, or null if + * @param target the processing instruction target + * @param data the processing instruction data, or null if * none was supplied. The data does not include any - * whitespace separating it from the target. - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * whitespace separating it from the target + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception */ public void processingInstruction (String target, String data) throws SAXException; @@ -394,12 +405,12 @@ public interface ContentHandler * http://xml.org/sax/features/external-parameter-entities * properties.

* - * @param name The name of the skipped entity. If it is a + * @param name the name of the skipped entity. If it is a * parameter entity, the name will begin with '%', and if * it is the external DTD subset, it will be the string - * "[dtd]". - * @exception org.xml.sax.SAXException Any SAX exception, possibly - * wrapping another exception. + * "[dtd]" + * @throws org.xml.sax.SAXException any SAX exception, possibly + * wrapping another exception */ public void skippedEntity (String name) throws SAXException; diff --git a/java/external/src/org/xml/sax/ErrorHandler.java b/java/external/src/org/xml/sax/ErrorHandler.java index fe5d0d8..20be752 100644 --- a/java/external/src/org/xml/sax/ErrorHandler.java +++ b/java/external/src/org/xml/sax/ErrorHandler.java @@ -24,20 +24,25 @@ package org.xml.sax; * through this interface.

* *

WARNING: If an application does not - * register an ErrorHandler, XML parsing errors will go unreported - * and bizarre behaviour may result.

+ * register an ErrorHandler, XML parsing errors will go unreported, + * except that SAXParseExceptions will be thrown for fatal errors. + * In order to detect validity errors, an ErrorHandler that does something + * with {@link #error error()} calls must be registered.

* *

For XML processing errors, a SAX driver must use this interface - * instead of throwing an exception: it is up to the application + * in preference to throwing an exception: it is up to the application * to decide whether to throw an exception for different types of * errors and warnings. Note, however, that there is no requirement that - * the parser continue to provide useful information after a call to - * {@link #fatalError fatalError} (in other words, a SAX driver class - * could catch an exception and report a fatalError).

+ * the parser continue to report additional errors after a call to + * {@link #fatalError fatalError}. In other words, a SAX driver class + * may throw an exception after reporting any fatalError. + * Also parsers may throw appropriate exceptions for non-XML errors. + * For example, {@link XMLReader#parse XMLReader.parse()} would throw + * an IOException for errors accessing entities or the document.

* * @since SAX 1.0 * @author David Megginson - * @version 2.0.1 (sax2r2) + * @version 2.0.1+ (sax2r3pre1) * @see org.xml.sax.XMLReader#setErrorHandler * @see org.xml.sax.SAXParseException */ @@ -48,8 +53,9 @@ public interface ErrorHandler { * Receive notification of a warning. * *

SAX parsers will use this method to report conditions that - * are not errors or fatal errors as defined by the XML 1.0 - * recommendation. The default behaviour is to take no action.

+ * are not errors or fatal errors as defined by the XML + * recommendation. The default behaviour is to take no + * action.

* *

The SAX parser must continue to provide normal parsing events * after invoking this method: it should still be possible for the @@ -77,12 +83,12 @@ public interface ErrorHandler { * validity constraint. The default behaviour is to take no * action.

* - *

The SAX parser must continue to provide normal parsing events - * after invoking this method: it should still be possible for the - * application to process the document through to the end. If the - * application cannot do so, then the parser should report a fatal - * error even if the XML 1.0 recommendation does not require it to - * do so.

+ *

The SAX parser must continue to provide normal parsing + * events after invoking this method: it should still be possible + * for the application to process the document through to the end. + * If the application cannot do so, then the parser should report + * a fatal error even if the XML recommendation does not require + * it to do so.

* *

Filters may use this method to report other, non-XML errors * as well.

@@ -100,6 +106,14 @@ public interface ErrorHandler { /** * Receive notification of a non-recoverable error. * + *

There is an apparent contradiction between the + * documentation for this method and the documentation for {@link + * org.xml.sax.ContentHandler#endDocument}. Until this ambiguity + * is resolved in a future major release, clients should make no + * assumptions about whether endDocument() will or will not be + * invoked when the parser has reported a fatalError() or thrown + * an exception.

+ * *

This corresponds to the definition of "fatal error" in * section 1.2 of the W3C XML 1.0 Recommendation. For example, a * parser would use this callback to report the violation of a @@ -107,7 +121,7 @@ public interface ErrorHandler { * *

The application must assume that the document is unusable * after the parser has invoked this method, and should continue - * (if at all) only for the sake of collecting addition error + * (if at all) only for the sake of collecting additional error * messages: in fact, SAX parsers are free to stop reporting any * other events once this method has been invoked.

* diff --git a/java/external/src/org/xml/sax/HandlerBase.java b/java/external/src/org/xml/sax/HandlerBase.java index 104abc7..d36065a 100644 --- a/java/external/src/org/xml/sax/HandlerBase.java +++ b/java/external/src/org/xml/sax/HandlerBase.java @@ -213,8 +213,7 @@ public class HandlerBase * each element (such as finalising a tree node or writing * output to a file).

* - * @param name The element type name. - * @param attributes The specified or defaulted attributes. + * @param name the element name * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.DocumentHandler#endElement diff --git a/java/external/src/org/xml/sax/SAXException.java b/java/external/src/org/xml/sax/SAXException.java index 0ffd56e..a3e9d4d 100644 --- a/java/external/src/org/xml/sax/SAXException.java +++ b/java/external/src/org/xml/sax/SAXException.java @@ -148,6 +148,8 @@ public class SAXException extends Exception { */ private Exception exception; + // Added serialVersionUID to preserve binary compatibility + static final long serialVersionUID = 583241635256073760L; } // end of SAXException.java diff --git a/java/external/src/org/xml/sax/SAXNotRecognizedException.java b/java/external/src/org/xml/sax/SAXNotRecognizedException.java index f5afae1..9a8360d 100644 --- a/java/external/src/org/xml/sax/SAXNotRecognizedException.java +++ b/java/external/src/org/xml/sax/SAXNotRecognizedException.java @@ -2,10 +2,8 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the Public Domain. - // $Id$ - package org.xml.sax; @@ -50,6 +48,8 @@ public class SAXNotRecognizedException extends SAXException super(message); } + // Added serialVersionUID to preserve binary compatibility + static final long serialVersionUID = 5440506620509557213L; } // end of SAXNotRecognizedException.java diff --git a/java/external/src/org/xml/sax/SAXNotSupportedException.java b/java/external/src/org/xml/sax/SAXNotSupportedException.java index 3e1654f..50f16fe 100644 --- a/java/external/src/org/xml/sax/SAXNotSupportedException.java +++ b/java/external/src/org/xml/sax/SAXNotSupportedException.java @@ -2,10 +2,8 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the Public Domain. - // $Id$ - package org.xml.sax; /** @@ -50,6 +48,8 @@ public class SAXNotSupportedException extends SAXException super(message); } + // Added serialVersionUID to preserve binary compatibility + static final long serialVersionUID = -1422818934641823846L; } // end of SAXNotSupportedException.java diff --git a/java/external/src/org/xml/sax/SAXParseException.java b/java/external/src/org/xml/sax/SAXParseException.java index b25df30..506fa19 100644 --- a/java/external/src/org/xml/sax/SAXParseException.java +++ b/java/external/src/org/xml/sax/SAXParseException.java @@ -104,9 +104,9 @@ public class SAXParseException extends SAXException { * * * @param message The error or warning message. - * @param publicId The public identifer of the entity that generated + * @param publicId The public identifier of the entity that generated * the error or warning. - * @param systemId The system identifer of the entity that generated + * @param systemId The system identifier of the entity that generated * the error or warning. * @param lineNumber The line number of the end of the text that * caused the error or warning. @@ -135,9 +135,9 @@ public class SAXParseException extends SAXException { * * @param message The error or warning message, or null to use * the message from the embedded exception. - * @param publicId The public identifer of the entity that generated + * @param publicId The public identifier of the entity that generated * the error or warning. - * @param systemId The system identifer of the entity that generated + * @param systemId The system identifier of the entity that generated * the error or warning. * @param lineNumber The line number of the end of the text that * caused the error or warning. @@ -231,7 +231,6 @@ public class SAXParseException extends SAXException { return this.columnNumber; } - ////////////////////////////////////////////////////////////////////// // Internal state. @@ -265,6 +264,8 @@ public class SAXParseException extends SAXException { */ private int columnNumber; + // Added serialVersionUID to preserve binary compatibility + static final long serialVersionUID = -5651165872476709336L; } // end of SAXParseException.java diff --git a/java/external/src/org/xml/sax/XMLFilter.java b/java/external/src/org/xml/sax/XMLFilter.java index ecf9f4e..6a01719 100644 --- a/java/external/src/org/xml/sax/XMLFilter.java +++ b/java/external/src/org/xml/sax/XMLFilter.java @@ -2,10 +2,8 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the Public Domain. - // $Id$ - package org.xml.sax; diff --git a/java/external/src/org/xml/sax/XMLReader.java b/java/external/src/org/xml/sax/XMLReader.java index 62488c1..f36f90d 100644 --- a/java/external/src/org/xml/sax/XMLReader.java +++ b/java/external/src/org/xml/sax/XMLReader.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the Public Domain. - // $Id$ package org.xml.sax; @@ -53,7 +52,7 @@ import java.io.IOException; * * @since SAX 2.0 * @author David Megginson - * @version 2.0.1 (sax2r2) + * @version 2.0.1+ (sax2r3pre1) * @see org.xml.sax.XMLFilter * @see org.xml.sax.helpers.ParserAdapter * @see org.xml.sax.helpers.XMLReaderAdapter @@ -342,7 +341,14 @@ public interface XMLReader * progress (they should create a new XMLReader instead for each * nested XML document). Once a parse is complete, an * application may reuse the same XMLReader object, possibly with a - * different input source.

+ * different input source. + * Configuration of the XMLReader object (such as handler bindings and + * values established for feature flags and properties) is unchanged + * by completion of a parse, unless the definition of that aspect of + * the configuration explicitly specifies other behavior. + * (For example, feature flags or properties exposing + * characteristics of the document being parsed.) + *

* *

During the parse, the XMLReader will provide information * about the XML document through the registered event @@ -352,7 +358,7 @@ public interface XMLReader * has ended. If a client application wants to terminate * parsing early, it should throw an exception.

* - * @param source The input source for the top-level of the + * @param input The input source for the top-level of the * XML document. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. diff --git a/java/external/src/org/xml/sax/ext/Attributes2.java b/java/external/src/org/xml/sax/ext/Attributes2.java new file mode 100644 index 0000000..84e5b45 --- /dev/null +++ b/java/external/src/org/xml/sax/ext/Attributes2.java @@ -0,0 +1,132 @@ +// Attributes2.java - extended Attributes +// http://www.saxproject.org +// Public Domain: no warranty. +// $Id$ + +package org.xml.sax.ext; + +import org.xml.sax.Attributes; + + +/** + * SAX2 extension to augment the per-attribute information + * provided though {@link Attributes}. + * If an implementation supports this extension, the attributes + * provided in {@link org.xml.sax.ContentHandler#startElement + * ContentHandler.startElement() } will implement this interface, + * and the http://xml.org/sax/features/use-attributes2 + * feature flag will have the value true. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

XMLReader implementations are not required to support this + * information, and it is not part of core-only SAX2 distributions.

+ * + *

Note that if an attribute was defaulted (!isSpecified()) + * it will of necessity also have been declared (isDeclared()) + * in the DTD. + * Similarly if an attribute's type is anything except CDATA, then it + * must have been declared. + *

+ * + * @since SAX 2.0 (extensions 1.1 alpha) + * @author David Brownell + * @version TBS + */ +public interface Attributes2 extends Attributes +{ + /** + * Returns false unless the attribute was declared in the DTD. + * This helps distinguish two kinds of attributes that SAX reports + * as CDATA: ones that were declared (and hence are usually valid), + * and those that were not (and which are never valid). + * + * @param index The attribute index (zero-based). + * @return true if the attribute was declared in the DTD, + * false otherwise. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not identify an attribute. + */ + public boolean isDeclared (int index); + + /** + * Returns false unless the attribute was declared in the DTD. + * This helps distinguish two kinds of attributes that SAX reports + * as CDATA: ones that were declared (and hence are usually valid), + * and those that were not (and which are never valid). + * + * @param qName The XML qualified (prefixed) name. + * @return true if the attribute was declared in the DTD, + * false otherwise. + * @exception java.lang.IllegalArgumentException When the + * supplied name does not identify an attribute. + */ + public boolean isDeclared (String qName); + + /** + * Returns false unless the attribute was declared in the DTD. + * This helps distinguish two kinds of attributes that SAX reports + * as CDATA: ones that were declared (and hence are usually valid), + * and those that were not (and which are never valid). + * + *

Remember that since DTDs do not "understand" namespaces, the + * namespace URI associated with an attribute may not have come from + * the DTD. The declaration will have applied to the attribute's + * qName. + * + * @param uri The Namespace URI, or the empty string if + * the name has no Namespace URI. + * @param localName The attribute's local name. + * @return true if the attribute was declared in the DTD, + * false otherwise. + * @exception java.lang.IllegalArgumentException When the + * supplied names do not identify an attribute. + */ + public boolean isDeclared (String uri, String localName); + + /** + * Returns true unless the attribute value was provided + * by DTD defaulting. + * + * @param index The attribute index (zero-based). + * @return true if the value was found in the XML text, + * false if the value was provided by DTD defaulting. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not identify an attribute. + */ + public boolean isSpecified (int index); + + /** + * Returns true unless the attribute value was provided + * by DTD defaulting. + * + *

Remember that since DTDs do not "understand" namespaces, the + * namespace URI associated with an attribute may not have come from + * the DTD. The declaration will have applied to the attribute's + * qName. + * + * @param uri The Namespace URI, or the empty string if + * the name has no Namespace URI. + * @param localName The attribute's local name. + * @return true if the value was found in the XML text, + * false if the value was provided by DTD defaulting. + * @exception java.lang.IllegalArgumentException When the + * supplied names do not identify an attribute. + */ + public boolean isSpecified (String uri, String localName); + + /** + * Returns true unless the attribute value was provided + * by DTD defaulting. + * + * @param qName The XML qualified (prefixed) name. + * @return true if the value was found in the XML text, + * false if the value was provided by DTD defaulting. + * @exception java.lang.IllegalArgumentException When the + * supplied name does not identify an attribute. + */ + public boolean isSpecified (String qName); +} diff --git a/java/external/src/org/xml/sax/ext/Attributes2Impl.java b/java/external/src/org/xml/sax/ext/Attributes2Impl.java new file mode 100644 index 0000000..af4ade0 --- /dev/null +++ b/java/external/src/org/xml/sax/ext/Attributes2Impl.java @@ -0,0 +1,301 @@ +// Attributes2Impl.java - extended AttributesImpl +// http://www.saxproject.org +// Public Domain: no warranty. +// $Id$ + +package org.xml.sax.ext; + +import org.xml.sax.Attributes; +import org.xml.sax.helpers.AttributesImpl; + + +/** + * SAX2 extension helper for additional Attributes information, + * implementing the {@link Attributes2} interface. + * + *

+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This is not part of core-only SAX2 distributions.

+ * + *

The specified flag for each attribute will always + * be true, unless it has been set to false in the copy constructor + * or using {@link #setSpecified}. + * Similarly, the declared flag for each attribute will + * always be false, except for defaulted attributes (specified + * is false), non-CDATA attributes, or when it is set to true using + * {@link #setDeclared}. + * If you change an attribute's type by hand, you may need to modify + * its declared flag to match. + *

+ * + * @since SAX 2.0 (extensions 1.1 alpha) + * @author David Brownell + * @version TBS + */ +public class Attributes2Impl extends AttributesImpl implements Attributes2 +{ + private boolean declared []; + private boolean specified []; + + + /** + * Construct a new, empty Attributes2Impl object. + */ + public Attributes2Impl () { } + + + /** + * Copy an existing Attributes or Attributes2 object. + * If the object implements Attributes2, values of the + * specified and declared flags for each + * attribute are copied. + * Otherwise the flag values are defaulted to assume no DTD was used, + * unless there is evidence to the contrary (such as attributes with + * type other than CDATA, which must have been declared). + * + *

This constructor is especially useful inside a + * {@link org.xml.sax.ContentHandler#startElement startElement} event.

+ * + * @param atts The existing Attributes object. + */ + public Attributes2Impl (Attributes atts) + { + super (atts); + } + + + //////////////////////////////////////////////////////////////////// + // Implementation of Attributes2 + //////////////////////////////////////////////////////////////////// + + + /** + * Returns the current value of the attribute's "declared" flag. + */ + // javadoc mostly from interface + public boolean isDeclared (int index) + { + if (index < 0 || index >= getLength ()) + throw new ArrayIndexOutOfBoundsException ( + "No attribute at index: " + index); + return declared [index]; + } + + + /** + * Returns the current value of the attribute's "declared" flag. + */ + // javadoc mostly from interface + public boolean isDeclared (String uri, String localName) + { + int index = getIndex (uri, localName); + + if (index < 0) + throw new IllegalArgumentException ( + "No such attribute: local=" + localName + + ", namespace=" + uri); + return declared [index]; + } + + + /** + * Returns the current value of the attribute's "declared" flag. + */ + // javadoc mostly from interface + public boolean isDeclared (String qName) + { + int index = getIndex (qName); + + if (index < 0) + throw new IllegalArgumentException ( + "No such attribute: " + qName); + return declared [index]; + } + + + /** + * Returns the current value of an attribute's "specified" flag. + * + * @param index The attribute index (zero-based). + * @return current flag value + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not identify an attribute. + */ + public boolean isSpecified (int index) + { + if (index < 0 || index >= getLength ()) + throw new ArrayIndexOutOfBoundsException ( + "No attribute at index: " + index); + return specified [index]; + } + + + /** + * Returns the current value of an attribute's "specified" flag. + * + * @param uri The Namespace URI, or the empty string if + * the name has no Namespace URI. + * @param localName The attribute's local name. + * @return current flag value + * @exception java.lang.IllegalArgumentException When the + * supplied names do not identify an attribute. + */ + public boolean isSpecified (String uri, String localName) + { + int index = getIndex (uri, localName); + + if (index < 0) + throw new IllegalArgumentException ( + "No such attribute: local=" + localName + + ", namespace=" + uri); + return specified [index]; + } + + + /** + * Returns the current value of an attribute's "specified" flag. + * + * @param qName The XML qualified (prefixed) name. + * @return current flag value + * @exception java.lang.IllegalArgumentException When the + * supplied name does not identify an attribute. + */ + public boolean isSpecified (String qName) + { + int index = getIndex (qName); + + if (index < 0) + throw new IllegalArgumentException ( + "No such attribute: " + qName); + return specified [index]; + } + + + //////////////////////////////////////////////////////////////////// + // Manipulators + //////////////////////////////////////////////////////////////////// + + + /** + * Copy an entire Attributes object. The "specified" flags are + * assigned as true, and "declared" flags as false (except when + * an attribute's type is not CDATA), + * unless the object is an Attributes2 object. + * In that case those flag values are all copied. + * + * @see AttributesImpl#setAttributes + */ + public void setAttributes (Attributes atts) + { + int length = atts.getLength (); + + super.setAttributes (atts); + declared = new boolean [length]; + specified = new boolean [length]; + + if (atts instanceof Attributes2) { + Attributes2 a2 = (Attributes2) atts; + for (int i = 0; i < length; i++) { + declared [i] = a2.isDeclared (i); + specified [i] = a2.isSpecified (i); + } + } else { + for (int i = 0; i < length; i++) { + declared [i] = !"CDATA".equals (atts.getType (i)); + specified [i] = true; + } + } + } + + + /** + * Add an attribute to the end of the list, setting its + * "specified" flag to true. To set that flag's value + * to false, use {@link #setSpecified}. + * + *

Unless the attribute type is CDATA, this attribute + * is marked as being declared in the DTD. To set that flag's value + * to true for CDATA attributes, use {@link #setDeclared}. + * + * @see AttributesImpl#addAttribute + */ + public void addAttribute (String uri, String localName, String qName, + String type, String value) + { + super.addAttribute (uri, localName, qName, type, value); + + int length = getLength (); + + if (length < specified.length) { + boolean newFlags []; + + newFlags = new boolean [length]; + System.arraycopy (declared, 0, newFlags, 0, declared.length); + declared = newFlags; + + newFlags = new boolean [length]; + System.arraycopy (specified, 0, newFlags, 0, specified.length); + specified = newFlags; + } + + specified [length - 1] = true; + declared [length - 1] = !"CDATA".equals (type); + } + + + // javadoc entirely from superclass + public void removeAttribute (int index) + { + int origMax = getLength () - 1; + + super.removeAttribute (index); + if (index != origMax) { + System.arraycopy (declared, index + 1, declared, index, + origMax - index); + System.arraycopy (specified, index + 1, specified, index, + origMax - index); + } + } + + + /** + * Assign a value to the "declared" flag of a specific attribute. + * This is normally needed only for attributes of type CDATA, + * including attributes whose type is changed to or from CDATA. + * + * @param index The index of the attribute (zero-based). + * @param value The desired flag value. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not identify an attribute. + * @see #setType + */ + public void setDeclared (int index, boolean value) + { + if (index < 0 || index >= getLength ()) + throw new ArrayIndexOutOfBoundsException ( + "No attribute at index: " + index); + declared [index] = value; + } + + + /** + * Assign a value to the "specified" flag of a specific attribute. + * This is the only way this flag can be cleared, except clearing + * by initialization with the copy constructor. + * + * @param index The index of the attribute (zero-based). + * @param value The desired flag value. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not identify an attribute. + */ + public void setSpecified (int index, boolean value) + { + if (index < 0 || index >= getLength ()) + throw new ArrayIndexOutOfBoundsException ( + "No attribute at index: " + index); + specified [index] = value; + } +} diff --git a/java/external/src/org/xml/sax/ext/DeclHandler.java b/java/external/src/org/xml/sax/ext/DeclHandler.java index b72d6d3..ce8064a 100644 --- a/java/external/src/org/xml/sax/ext/DeclHandler.java +++ b/java/external/src/org/xml/sax/ext/DeclHandler.java @@ -125,11 +125,14 @@ public interface DeclHandler *

Only the effective (first) declaration for each entity * will be reported.

* + *

If the system identifier is a URL, the parser must resolve it + * fully before passing it to the application.

+ * * @param name The name of the entity. If it is a parameter * entity, the name will begin with '%'. - * @param publicId The declared public identifier of the entity, or - * null if none was declared. - * @param systemId The declared system identifier of the entity. + * @param publicId The entity's public identifier, or null if none + * was given. + * @param systemId The entity's system identifier. * @exception SAXException The application may raise an exception. * @see #internalEntityDecl * @see org.xml.sax.DTDHandler#unparsedEntityDecl diff --git a/java/external/src/org/xml/sax/ext/DefaultHandler2.java b/java/external/src/org/xml/sax/ext/DefaultHandler2.java new file mode 100644 index 0000000..72bdfd8 --- /dev/null +++ b/java/external/src/org/xml/sax/ext/DefaultHandler2.java @@ -0,0 +1,130 @@ +// DefaultHandler2.java - extended DefaultHandler +// http://www.saxproject.org +// Public Domain: no warranty. +// $Id$ + +package org.xml.sax.ext; + +import java.io.IOException; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + + +/** + * This class extends the SAX2 base handler class to support the + * SAX2 {@link LexicalHandler}, {@link DeclHandler}, and + * {@link EntityResolver2} extensions. Except for overriding the + * original SAX1 {@link DefaultHandler#resolveEntity resolveEntity()} + * method the added handler methods just return. Subclassers may + * override everything on a method-by-method basis. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

Note: this class might yet learn that the + * ContentHandler.setDocumentLocator() call might be passed a + * {@link Locator2} object, and that the + * ContentHandler.startElement() call might be passed a + * {@link Attributes2} object. + * + * @since SAX 2.0 (extensions 1.1 alpha) + * @author David Brownell + * @version TBS + */ +public class DefaultHandler2 extends DefaultHandler + implements LexicalHandler, DeclHandler, EntityResolver2 +{ + /** Constructs a handler which ignores all parsing events. */ + public DefaultHandler2 () { } + + + // SAX2 ext-1.0 LexicalHandler + + public void startCDATA () + throws SAXException + {} + + public void endCDATA () + throws SAXException + {} + + public void startDTD (String name, String publicId, String systemId) + throws SAXException + {} + + public void endDTD () + throws SAXException + {} + + public void startEntity (String name) + throws SAXException + {} + + public void endEntity (String name) + throws SAXException + {} + + public void comment (char ch [], int start, int length) + throws SAXException + { } + + + // SAX2 ext-1.0 DeclHandler + + public void attributeDecl (String eName, String aName, + String type, String mode, String value) + throws SAXException + {} + + public void elementDecl (String name, String model) + throws SAXException + {} + + public void externalEntityDecl (String name, + String publicId, String systemId) + throws SAXException + {} + + public void internalEntityDecl (String name, String value) + throws SAXException + {} + + // SAX2 ext-1.1 EntityResolver2 + + /** + * Tells the parser that if no external subset has been declared + * in the document text, none should be used. + */ + public InputSource getExternalSubset (String name, String baseURI) + throws SAXException, IOException + { return null; } + + /** + * Tells the parser to resolve the systemId against the baseURI + * and read the entity text from that resulting absolute URI. + * Note that because the older + * {@link DefaultHandler#resolveEntity DefaultHandler.resolveEntity()}, + * method is overridden to call this one, this method may sometimes + * be invoked with null name and baseURI, and + * with the systemId already absolutized. + */ + public InputSource resolveEntity (String name, String publicId, + String baseURI, String systemId) + throws SAXException, IOException + { return null; } + + // SAX1 EntityResolver + + /** + * Invokes + * {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()} + * with null entity name and base URI. + * You only need to override that method to use this class. + */ + public InputSource resolveEntity (String publicId, String systemId) + throws SAXException, IOException + { return resolveEntity (null, publicId, null, systemId); } +} diff --git a/java/external/src/org/xml/sax/ext/EntityResolver2.java b/java/external/src/org/xml/sax/ext/EntityResolver2.java new file mode 100644 index 0000000..5986ca3 --- /dev/null +++ b/java/external/src/org/xml/sax/ext/EntityResolver2.java @@ -0,0 +1,197 @@ +// EntityResolver2.java - Extended SAX entity resolver. +// http://www.saxproject.org +// No warranty; no copyright -- use this as you will. +// $Id$ + +package org.xml.sax.ext; + +import java.io.IOException; + +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; +import org.xml.sax.SAXException; + + +/** + * Extended interface for mapping external entity references to input + * sources, or providing a missing external subset. The + * {@link XMLReader#setEntityResolver XMLReader.setEntityResolver()} method + * is used to provide implementations of this interface to parsers. + * When a parser uses the methods in this interface, the + * {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()} + * method (in this interface) is used instead of the older (SAX 1.0) + * {@link EntityResolver#resolveEntity EntityResolver.resolveEntity()} method. + * + *

+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

If a SAX application requires the customized handling which this + * interface defines for external entities, it must ensure that it uses + * an XMLReader with the + * http://xml.org/sax/features/use-entity-resolver2 feature flag + * set to true (which is its default value when the feature is + * recognized). If that flag is unrecognized, or its value is false, + * or the resolver does not implement this interface, then only the + * {@link EntityResolver} method will be used. + *

+ * + *

That supports three categories of application that modify entity + * resolution. Old Style applications won't know about this interface; + * they will provide an EntityResolver. + * Transitional Mode provide an EntityResolver2 and automatically + * get the benefit of its methods in any systems (parsers or other tools) + * supporting it, due to polymorphism. + * Both Old Style and Transitional Mode applications will + * work with any SAX2 parser. + * New style applications will fail to run except on SAX2 parsers + * that support this particular feature. + * They will insist that feature flag have a value of "true", and the + * EntityResolver2 implementation they provide might throw an exception + * if the original SAX 1.0 style entity resolution method is invoked. + *

+ * + * @see org.xml.sax.XMLReader#setEntityResolver + * + * @since SAX 2.0 (extensions 1.1 alpha) + * @author David Brownell + * @version TBD + */ +public interface EntityResolver2 extends EntityResolver +{ + /** + * Allows applications to provide an external subset for documents + * that don't explicitly define one. Documents with DOCTYPE declarations + * that omit an external subset can thus augment the declarations + * available for validation, entity processing, and attribute processing + * (normalization, defaulting, and reporting types including ID). + * This augmentation is reported + * through the {@link LexicalHandler#startDTD startDTD()} method as if + * the document text had originally included the external subset; + * this callback is made before any internal subset data or errors + * are reported.

+ * + *

This method can also be used with documents that have no DOCTYPE + * declaration. When the root element is encountered, + * but no DOCTYPE declaration has been seen, this method is + * invoked. If it returns a value for the external subset, that root + * element is declared to be the root element, giving the effect of + * splicing a DOCTYPE declaration at the end the prolog of a document + * that could not otherwise be valid. The sequence of parser callbacks + * in that case logically resembles this:

+ * + *
+     * ... comments and PIs from the prolog (as usual)
+     * startDTD ("rootName", source.getPublicId (), source.getSystemId ());
+     * startEntity ("[dtd]");
+     * ... declarations, comments, and PIs from the external subset
+     * endEntity ("[dtd]");
+     * endDTD ();
+     * ... then the rest of the document (as usual)
+     * startElement (..., "rootName", ...);
+     * 
+ * + *

Note that the InputSource gets no further resolution. + * Implementations of this method may wish to invoke + * {@link #resolveEntity resolveEntity()} to gain benefits such as use + * of local caches of DTD entities. Also, this method will never be + * used by a (non-validating) processor that is not including external + * parameter entities.

+ * + *

Uses for this method include facilitating data validation when + * interoperating with XML processors that would always require + * undesirable network accesses for external entities, or which for + * other reasons adopt a "no DTDs" policy. + * Non-validation motives include forcing documents to include DTDs so + * that attributes are handled consistently. + * For example, an XPath processor needs to know which attibutes have + * type "ID" before it can process a widely used type of reference.

+ * + *

Warning: Returning an external subset modifies + * the input document. By providing definitions for general entities, + * it can make a malformed document appear to be well formed. + *

+ * + * @param name Identifies the document root element. This name comes + * from a DOCTYPE declaration (where available) or from the actual + * root element. + * @param baseURI The document's base URI, serving as an additional + * hint for selecting the external subset. This is always an absolute + * URI, unless it is null because the XMLReader was given an InputSource + * without one. + * + * @return An InputSource object describing the new external subset + * to be used by the parser, or null to indicate that no external + * subset is provided. + * + * @exception SAXException Any SAX exception, possibly wrapping + * another exception. + * @exception IOException Probably indicating a failure to create + * a new InputStream or Reader, or an illegal URL. + */ + public InputSource getExternalSubset (String name, String baseURI) + throws SAXException, IOException; + + /** + * Allows applications to map references to external entities into input + * sources, or tell the parser it should use conventional URI resolution. + * This method is only called for external entities which have been + * properly declared. + * This method provides more flexibility than the {@link EntityResolver} + * interface, supporting implementations of more complex catalogue + * schemes such as the one defined by the OASIS XML Catalogs specification.

+ * + *

Parsers configured to use this resolver method will call it + * to determine the input source to use for any external entity + * being included because of a reference in the XML text. + * That excludes the document entity, and any external entity returned + * by {@link #getExternalSubset getExternalSubset()}. + * When a (non-validating) processor is configured not to include + * a class of entities (parameter or general) through use of feature + * flags, this method is not invoked for such entities.

+ * + *

Note that the entity naming scheme used here is the same one + * used in the {@link LexicalHandler}, or in the {@link + org.xml.sax.ContentHandler#skippedEntity + ContentHandler.skippedEntity()} + * method.

+ * + * @param name Identifies the external entity being resolved. + * Either "[dtd]" for the external subset, or a name starting + * with "%" to indicate a parameter entity, or else the name of + * a general entity. This is never null when invoked by a SAX2 + * parser. + * @param publicId The public identifier of the external entity being + * referenced (normalized as required by the XML specification), or + * null if none was supplied. + * @param baseURI The URI with respect to which relative systemIDs + * are interpreted. This is always an absolute URI, unless it is + * null (likely because the XMLReader was given an InputSource without + * one). This URI is defined by the XML specification to be the one + * associated with the "<" starting the relevant declaration. + * @param systemId The system identifier of the external entity + * being referenced; either a relative or absolute URI. + * This is never null when invoked by a SAX2 parser; only declared + * entities, and any external subset, are resolved by such parsers. + * + * @return An InputSource object describing the new input source to + * be used by the parser. Returning null directs the parser to + * resolve the system ID against the base URI and open a connection + * to resulting URI. + * + * @exception SAXException Any SAX exception, possibly wrapping + * another exception. + * @exception IOException Probably indicating a failure to create + * a new InputStream or Reader, or an illegal URL. + */ + public InputSource resolveEntity ( + String name, + String publicId, + String baseURI, + String systemId + ) throws SAXException, IOException; +} diff --git a/java/external/src/org/xml/sax/ext/Locator2.java b/java/external/src/org/xml/sax/ext/Locator2.java new file mode 100644 index 0000000..040100e --- /dev/null +++ b/java/external/src/org/xml/sax/ext/Locator2.java @@ -0,0 +1,75 @@ +// Locator2.java - extended Locator +// http://www.saxproject.org +// Public Domain: no warranty. +// $Id$ + +package org.xml.sax.ext; + +import org.xml.sax.Locator; + + +/** + * SAX2 extension to augment the entity information provided + * though a {@link Locator}. + * If an implementation supports this extension, the Locator + * provided in {@link org.xml.sax.ContentHandler#setDocumentLocator + * ContentHandler.setDocumentLocator() } will implement this + * interface, and the + * http://xml.org/sax/features/use-locator2 feature + * flag will have the value true. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

XMLReader implementations are not required to support this + * information, and it is not part of core-only SAX2 distributions.

+ * + * @since SAX 2.0 (extensions 1.1 alpha) + * @author David Brownell + * @version TBS + */ +public interface Locator2 extends Locator +{ + /** + * Returns the version of XML used for the entity. This will + * normally be the identifier from the current entity's + * <?xml version='...' ...?> declaration, + * or be defaulted by the parser. + * + * @return Identifier for the XML version being used to interpret + * the entity's text, or null if that information is not yet + * available in the current parsing state. + */ + public String getXMLVersion (); + + /** + * Returns the name of the character encoding for the entity. + * If the encoding was declared externally (for example, in a MIME + * Content-Type header), that will be the name returned. Else if there + * was an <?xml ...encoding='...'?> declaration at + * the start of the document, that encoding name will be returned. + * Otherwise the encoding will been inferred (normally to be UTF-8, or + * some UTF-16 variant), and that inferred name will be returned. + * + *

When an {@link org.xml.sax.InputSource InputSource} is used + * to provide an entity's character stream, this method returns the + * encoding provided in that input stream. + * + *

Note that some recent W3C specifications require that text + * in some encodings be normalized, using Unicode Normalization + * Form C, before processing. Such normalization must be performed + * by applications, and would normally be triggered based on the + * value returned by this method. + * + *

Encoding names may be those used by the underlying JVM, + * and comparisons should be case-insensitive. + * + * @return Name of the character encoding being used to interpret + * * the entity's text, or null if this was not provided for a * + * character stream passed through an InputSource or is otherwise + * not yet available in the current parsing state. + */ + public String getEncoding (); +} diff --git a/java/external/src/org/xml/sax/ext/Locator2Impl.java b/java/external/src/org/xml/sax/ext/Locator2Impl.java new file mode 100644 index 0000000..a1b6179 --- /dev/null +++ b/java/external/src/org/xml/sax/ext/Locator2Impl.java @@ -0,0 +1,101 @@ +// Locator2Impl.java - extended LocatorImpl +// http://www.saxproject.org +// Public Domain: no warranty. +// $Id$ + +package org.xml.sax.ext; + +import org.xml.sax.Locator; +import org.xml.sax.helpers.LocatorImpl; + + +/** + * SAX2 extension helper for holding additional Entity information, + * implementing the {@link Locator2} interface. + * + *

+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This is not part of core-only SAX2 distributions.

+ * + * @since SAX 2.0.2 + * @author David Brownell + * @version TBS + */ +public class Locator2Impl extends LocatorImpl implements Locator2 +{ + private String encoding; + private String version; + + + /** + * Construct a new, empty Locator2Impl object. + * This will not normally be useful, since the main purpose + * of this class is to make a snapshot of an existing Locator. + */ + public Locator2Impl () { } + + /** + * Copy an existing Locator or Locator2 object. + * If the object implements Locator2, values of the + * encoding and versionstrings are copied, + * otherwise they set to null. + * + * @param locator The existing Locator object. + */ + public Locator2Impl (Locator locator) + { + super (locator); + if (locator instanceof Locator2) { + Locator2 l2 = (Locator2) locator; + + version = l2.getXMLVersion (); + encoding = l2.getEncoding (); + } + } + + //////////////////////////////////////////////////////////////////// + // Locator2 method implementations + //////////////////////////////////////////////////////////////////// + + /** + * Returns the current value of the version property. + * + * @see #setXMLVersion + */ + public String getXMLVersion () + { return version; } + + /** + * Returns the current value of the encoding property. + * + * @see #setEncoding + */ + public String getEncoding () + { return encoding; } + + + //////////////////////////////////////////////////////////////////// + // Setters + //////////////////////////////////////////////////////////////////// + + /** + * Assigns the current value of the version property. + * + * @param version the new "version" value + * @see #getXMLVersion + */ + public void setXMLVersion (String version) + { this.version = version; } + + /** + * Assigns the current value of the encoding property. + * + * @param encoding the new "encoding" value + * @see #getEncoding + */ + public void setEncoding (String encoding) + { this.encoding = encoding; } +} diff --git a/java/external/src/org/xml/sax/ext/package.html b/java/external/src/org/xml/sax/ext/package.html index bbb02f9..579f267 100644 --- a/java/external/src/org/xml/sax/ext/package.html +++ b/java/external/src/org/xml/sax/ext/package.html @@ -1,33 +1,36 @@ - +

-This package contains interfaces to optional SAX2 handlers. +This package contains interfaces to SAX2 facilities that +conformant SAX drivers won't necessarily support.

See http://www.saxproject.org for more information about SAX.

-

-The package is independent of the SAX2 core, though the functionality -exposed generally needs to be implemented within a parser. +

This package is independent of the SAX2 core, though the functionality +exposed generally needs to be implemented within a parser core. That independence has several consequences:

@@ -37,13 +40,7 @@ designed both to allow SAX parsers to pass certain types of information to applications, and to serve as a simple model for other SAX2 parser extension packages. Not all such extension packages should need to be recognized directly by parsers, however. -As an example, most schema systems can be cleanly layered on top +As an example, most validation systems can be cleanly layered on top of parsers supporting the standardized SAX2 interfaces.

-

NOTE: this package alone does add any -functionality; it simply provides optional interfaces for SAX2 drivers -to use. You must use a SAX2 driver that recognizes these interfaces if -you actually want to have access to lexical and declaration -information.

- diff --git a/java/external/src/org/xml/sax/helpers/AttributesImpl.java b/java/external/src/org/xml/sax/helpers/AttributesImpl.java index 565b83f..8b6d68a 100644 --- a/java/external/src/org/xml/sax/helpers/AttributesImpl.java +++ b/java/external/src/org/xml/sax/helpers/AttributesImpl.java @@ -2,10 +2,8 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the public domain. - // $Id$ - package org.xml.sax.helpers; import org.xml.sax.Attributes; diff --git a/java/external/src/org/xml/sax/helpers/DefaultHandler.java b/java/external/src/org/xml/sax/helpers/DefaultHandler.java index 5a468ea..4d11762 100644 --- a/java/external/src/org/xml/sax/helpers/DefaultHandler.java +++ b/java/external/src/org/xml/sax/helpers/DefaultHandler.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the public domain. - // $Id$ package org.xml.sax.helpers; @@ -262,7 +261,7 @@ public class DefaultHandler * performed. * @param qName The qualified name (with prefix), or the * empty string if qualified names are not available. - * @param atts The attributes attached to the element. If + * @param attributes The attributes attached to the element. If * there are no attributes, it shall be an empty * Attributes object. * @exception org.xml.sax.SAXException Any SAX exception, possibly diff --git a/java/external/src/org/xml/sax/helpers/NamespaceSupport.java b/java/external/src/org/xml/sax/helpers/NamespaceSupport.java index cff88dd..150bb72 100644 --- a/java/external/src/org/xml/sax/helpers/NamespaceSupport.java +++ b/java/external/src/org/xml/sax/helpers/NamespaceSupport.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // This class is in the Public Domain. NO WARRANTY! - // $Id$ package org.xml.sax.helpers; @@ -24,11 +23,11 @@ import java.util.Vector; * for further information. * * - *

This class encapsulates the logic of Namespace processing: - * it tracks the declarations currently in force for each context - * and automatically processes qualified XML 1.0 names into their - * Namespace parts; it can also be used in reverse for generating - * XML 1.0 from Namespaces.

+ *

This class encapsulates the logic of Namespace processing: it + * tracks the declarations currently in force for each context and + * automatically processes qualified XML names into their Namespace + * parts; it can also be used in reverse for generating XML qnames + * from Namespaces.

* *

Namespace support objects are reusable, but the reset method * must be invoked between each session.

@@ -82,7 +81,7 @@ public class NamespaceSupport /** * The XML Namespace URI as a constant. * The value is http://www.w3.org/XML/1998/namespace - * as defined in the XML Namespaces specification. + * as defined in the "Namespaces in XML" * recommendation. * *

This is the Namespace URI that is automatically mapped * to the "xml" prefix.

@@ -91,6 +90,26 @@ public class NamespaceSupport "http://www.w3.org/XML/1998/namespace"; + /** + * The namespace declaration URI as a constant. + * The value is http://www.w3.org/xmlns/2000/, as defined + * in a backwards-incompatible erratum to the "Namespaces in XML" + * recommendation. Because that erratum postdated SAX2, SAX2 defaults + * to the original recommendation, and does not normally use this URI. + * + * + *

This is the Namespace URI that is optionally applied to + * xmlns and xmlns:* attributes, which are used to + * declare namespaces.

+ * + * @since SAX 2.1alpha + * @see #setNamespaceDeclUris + * @see #isNamespaceDeclUris + */ + public final static String NSDECL = + "http://www.w3.org/xmlns/2000/"; + + /** * An empty enumeration. */ @@ -122,11 +141,17 @@ public class NamespaceSupport * Reset this Namespace support object for reuse. * *

It is necessary to invoke this method before reusing the - * Namespace support object for a new session.

+ * Namespace support object for a new session. If namespace + * declaration URIs are to be supported, that flag must also + * be set to a non-default value. + *

+ * + * @see #setNamespaceDeclUris */ public void reset () { contexts = new Context[32]; + namespaceDeclUris = false; contextPos = 0; contexts[contextPos] = currentContext = new Context(); currentContext.declarePrefix("xml", XMLNS); @@ -173,7 +198,6 @@ public class NamespaceSupport { int max = contexts.length; - contexts [contextPos].declsOK = false; contextPos++; // Extend the array if necessary @@ -242,11 +266,6 @@ public class NamespaceSupport *

To declare the default element Namespace, use the empty string as * the prefix.

* - *

Note that you must not declare a prefix after - * you've pushed and popped another Namespace context, or - * treated the declarations phase as complete by processing - * a prefixed name.

- * *

Note that there is an asymmetry in this library: {@link * #getPrefix getPrefix} will not return the "" prefix, * even if you have declared a default element namespace. @@ -260,9 +279,6 @@ public class NamespaceSupport * the value "xml" or "xmlns". * @param uri The Namespace URI to associate with the prefix. * @return true if the prefix was legal, false otherwise - * @exception IllegalStateException when a prefix is declared - * after looking up a name in the context, or after pushing - * another context on top of it. * * @see #processName * @see #getURI @@ -280,12 +296,13 @@ public class NamespaceSupport /** - * Process a raw XML 1.0 name, after all declarations in the current - * context have been handled by {@link #declarePrefix declarePrefix()}. + * Process a raw XML qualified name, after all declarations in the + * current context have been handled by {@link #declarePrefix + * declarePrefix()}. * - *

This method processes a raw XML 1.0 name in the current - * context by removing the prefix and looking it up among the - * prefixes currently declared. The return value will be the + *

This method processes a raw XML qualified name in the + * current context by removing the prefix and looking it up among + * the prefixes currently declared. The return value will be the * array supplied by the caller, filled in as follows:

* *
@@ -303,18 +320,18 @@ public class NamespaceSupport * the return value will be null.

* *

Note that attribute names are processed differently than - * element names: an unprefixed element name will received the + * element names: an unprefixed element name will receive the * default Namespace (if any), while an unprefixed attribute name * will not.

* - * @param qName The raw XML 1.0 name to be processed. + * @param qName The XML qualified name to be processed. * @param parts An array supplied by the caller, capable of * holding at least three members. * @param isAttribute A flag indicating whether this is an * attribute name (true) or an element name (false). * @return The supplied array holding three internalized strings * representing the Namespace URI (or empty string), the - * local name, and the raw XML 1.0 name; or null if there + * local name, and the XML qualified name; or null if there * is an undeclared prefix. * @see #declarePrefix * @see java.lang.String#intern */ @@ -352,15 +369,16 @@ public class NamespaceSupport /** - * Return an enumeration of all prefixes currently declared. + * Return an enumeration of all prefixes whose declarations are + * active in the current context. + * This includes declarations from parent contexts that have + * not been overridden. * *

Note: if there is a default prefix, it will not be * returned in this enumeration; check for the default prefix * using the {@link #getURI getURI} with an argument of "".

* - * @return An enumeration of all prefixes declared in the - * current context except for the empty (default) - * prefix. + * @return An enumeration of prefixes (never empty). * @see #getDeclaredPrefixes * @see #getURI */ @@ -382,12 +400,10 @@ public class NamespaceSupport * to check for a default prefix, use the {@link #getURI getURI} * method with an argument of "".

* - * @param uri The Namespace URI. - * @param isAttribute true if this prefix is for an attribute - * (and the default Namespace is not allowed). - * @return One of the prefixes currently mapped to the URI supplied, + * @param uri the namespace URI + * @return one of the prefixes currently mapped to the URI supplied, * or null if none is mapped or if the URI is assigned to - * the default Namespace. + * the default namespace * @see #getPrefixes(java.lang.String) * @see #getURI */ @@ -398,7 +414,10 @@ public class NamespaceSupport /** - * Return an enumeration of all prefixes currently declared for a URI. + * Return an enumeration of all prefixes for a given URI whose + * declarations are active in the current context. + * This includes declarations from parent contexts that have + * not been overridden. * *

This method returns prefixes mapped to a specific Namespace * URI. The xml: prefix will be included. If you want only one @@ -412,8 +431,7 @@ public class NamespaceSupport * argument of "".

* * @param uri The Namespace URI. - * @return An enumeration of all prefixes declared in the - * current context. + * @return An enumeration of prefixes (never empty). * @see #getPrefix * @see #getDeclaredPrefixes * @see #getURI @@ -449,6 +467,41 @@ public class NamespaceSupport return currentContext.getDeclaredPrefixes(); } + /** + * Controls whether namespace declaration attributes are placed + * into the {@link #NSDECL NSDECL} namespace + * by {@link #processName processName()}. This may only be + * changed before any contexts have been pushed. + * + * @since SAX 2.1alpha + * + * @exception IllegalStateException when attempting to set this + * after any context has been pushed. + */ + public void setNamespaceDeclUris (boolean value) + { + if (contextPos != 0) + throw new IllegalStateException (); + if (value == namespaceDeclUris) + return; + namespaceDeclUris = value; + if (value) + currentContext.declarePrefix ("xmlns", NSDECL); + else { + contexts[contextPos] = currentContext = new Context(); + currentContext.declarePrefix("xml", XMLNS); + } + } + + /** + * Returns true if namespace declaration attributes are placed into + * a namespace. This behavior is not the default. + * + * @since SAX 2.1alpha + */ + public boolean isNamespaceDeclUris () + { return namespaceDeclUris; } + //////////////////////////////////////////////////////////////////// @@ -458,7 +511,7 @@ public class NamespaceSupport private Context contexts[]; private Context currentContext; private int contextPos; - + private boolean namespaceDeclUris; //////////////////////////////////////////////////////////////////// @@ -505,7 +558,6 @@ public class NamespaceSupport attributeNameTable = parent.attributeNameTable; defaultNS = parent.defaultNS; declSeen = false; - declsOK = true; } /** @@ -535,9 +587,9 @@ public class NamespaceSupport void declarePrefix (String prefix, String uri) { // Lazy processing... - if (!declsOK) - throw new IllegalStateException ( - "can't declare any more prefixes in this context"); +// if (!declsOK) +// throw new IllegalStateException ( +// "can't declare any more prefixes in this context"); if (!declSeen) { copyTables(); } @@ -562,9 +614,9 @@ public class NamespaceSupport /** - * Process a raw XML 1.0 name in this context. + * Process an XML qualified name in this context. * - * @param qName The raw XML 1.0 name. + * @param qName The XML qualified name. * @param isAttribute true if this is an attribute name. * @return An array of three strings containing the * URI part (or empty string), the local part, @@ -577,9 +629,6 @@ public class NamespaceSupport String name[]; Hashtable table; - // detect errors in call sequence - declsOK = false; - // Select the appropriate table. if (isAttribute) { table = attributeNameTable; @@ -606,7 +655,12 @@ public class NamespaceSupport // No prefix. if (index == -1) { - if (isAttribute || defaultNS == null) { + if (isAttribute) { + if (qName == "xmlns" && namespaceDeclUris) + name[0] = NSDECL; + else + name[0] = ""; + } else if (defaultNS == null) { name[0] = ""; } else { name[0] = defaultNS; @@ -624,7 +678,8 @@ public class NamespaceSupport } else { uri = (String)prefixTable.get(prefix); } - if (uri == null) { + if (uri == null + || (!isAttribute && "xmlns".equals (prefix))) { return null; } name[0] = uri; @@ -753,7 +808,6 @@ public class NamespaceSupport Hashtable elementNameTable; Hashtable attributeNameTable; String defaultNS = null; - boolean declsOK = true; diff --git a/java/external/src/org/xml/sax/helpers/NewInstance.java b/java/external/src/org/xml/sax/helpers/NewInstance.java index a5a124b..0e9d583 100644 --- a/java/external/src/org/xml/sax/helpers/NewInstance.java +++ b/java/external/src/org/xml/sax/helpers/NewInstance.java @@ -3,7 +3,6 @@ // Written by Edwin Goei, edwingo@apache.org // and by David Brownell, dbrownell@users.sourceforge.net // NO WARRANTY! This class is in the Public Domain. - // $Id$ package org.xml.sax.helpers; diff --git a/java/external/src/org/xml/sax/helpers/ParserAdapter.java b/java/external/src/org/xml/sax/helpers/ParserAdapter.java index 2a45663..b677e5d 100644 --- a/java/external/src/org/xml/sax/helpers/ParserAdapter.java +++ b/java/external/src/org/xml/sax/helpers/ParserAdapter.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the public domain. - // $Id$ package org.xml.sax.helpers; @@ -159,6 +158,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler private final static String FEATURES = "http://xml.org/sax/features/"; private final static String NAMESPACES = FEATURES + "namespaces"; private final static String NAMESPACE_PREFIXES = FEATURES + "namespace-prefixes"; + private final static String XMLNS_URIs = FEATURES + "xmlns-uris"; /** @@ -190,6 +190,9 @@ public class ParserAdapter implements XMLReader, DocumentHandler if (!prefixes && !namespaces) { namespaces = true; } + } else if (name.equals(XMLNS_URIs)) { + checkNotParsing("feature", name); + uris = value; } else { throw new SAXNotRecognizedException("Feature: " + name); } @@ -217,6 +220,8 @@ public class ParserAdapter implements XMLReader, DocumentHandler return namespaces; } else if (name.equals(NAMESPACE_PREFIXES)) { return prefixes; + } else if (name.equals(XMLNS_URIs)) { + return uris; } else { throw new SAXNotRecognizedException("Feature: " + name); } @@ -290,7 +295,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler /** * Set the DTD handler. * - * @param resolver The new DTD handler. + * @param handler the new DTD handler * @see org.xml.sax.XMLReader#setEntityResolver */ public void setDTDHandler (DTDHandler handler) @@ -302,7 +307,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler /** * Return the current DTD handler. * - * @return The current DTD handler, or null if none was supplied. + * @return the current DTD handler, or null if none was supplied * @see org.xml.sax.XMLReader#getEntityResolver */ public DTDHandler getDTDHandler () @@ -314,7 +319,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler /** * Set the content handler. * - * @param resolver The new content handler. + * @param handler the new content handler * @see org.xml.sax.XMLReader#setEntityResolver */ public void setContentHandler (ContentHandler handler) @@ -338,7 +343,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler /** * Set the error handler. * - * @param resolver The new error handler. + * @param handler The new error handler. * @see org.xml.sax.XMLReader#setEntityResolver */ public void setErrorHandler (ErrorHandler handler) @@ -405,7 +410,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler } - + //////////////////////////////////////////////////////////////////// // Implementation of org.xml.sax.DocumentHandler. //////////////////////////////////////////////////////////////////// @@ -468,7 +473,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler *

If necessary, perform Namespace processing.

* * @param qName The qualified (prefixed) name. - * @param qAtts The XML 1.0 attribute list (with qnames). + * @param qAtts The XML attribute list (with qnames). * @exception SAXException The client may raise a * processing exception. */ @@ -547,13 +552,21 @@ public class ParserAdapter implements XMLReader, DocumentHandler // (and similarly named) attributes ... ignore prefix = null; } else { - prefix = attQName.substring(n+1); + prefix = attQName.substring(6); } // Yes, decl: report or prune if (prefix != null) { - if (prefixes) - atts.addAttribute("", "", attQName.intern(), - type, value); + if (prefixes) { + if (uris) + // note funky case: localname can be null + // when declaring the default prefix, and + // yet the uri isn't null. + atts.addAttribute (nsSupport.XMLNS, prefix, + attQName.intern(), type, value); + else + atts.addAttribute ("", "", + attQName.intern(), type, value); + } continue; } } @@ -691,7 +704,13 @@ public class ParserAdapter implements XMLReader, DocumentHandler */ private void setupParser () { + // catch an illegal "nonsense" state. + if (!prefixes && !namespaces) + throw new IllegalStateException (); + nsSupport.reset(); + if (uris) + nsSupport.setNamespaceDeclUris (true); if (entityResolver != null) { parser.setEntityResolver(entityResolver); @@ -809,6 +828,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler // Features private boolean namespaces = true; private boolean prefixes = false; + private boolean uris = false; // Properties diff --git a/java/external/src/org/xml/sax/helpers/ParserFactory.java b/java/external/src/org/xml/sax/helpers/ParserFactory.java index aaa0312..de726dd 100644 --- a/java/external/src/org/xml/sax/helpers/ParserFactory.java +++ b/java/external/src/org/xml/sax/helpers/ParserFactory.java @@ -5,6 +5,12 @@ package org.xml.sax.helpers; +import java.lang.ClassNotFoundException; +import java.lang.IllegalAccessException; +import java.lang.InstantiationException; +import java.lang.SecurityException; +import java.lang.ClassCastException; + import org.xml.sax.Parser; diff --git a/java/external/src/org/xml/sax/helpers/XMLFilterImpl.java b/java/external/src/org/xml/sax/helpers/XMLFilterImpl.java index 4ebf552..238e110 100644 --- a/java/external/src/org/xml/sax/helpers/XMLFilterImpl.java +++ b/java/external/src/org/xml/sax/helpers/XMLFilterImpl.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the Public Domain. - // $Id$ package org.xml.sax.helpers; @@ -254,7 +253,7 @@ public class XMLFilterImpl /** * Set the DTD event handler. * - * @param resolver The new DTD handler. + * @param handler the new DTD handler */ public void setDTDHandler (DTDHandler handler) { @@ -276,7 +275,7 @@ public class XMLFilterImpl /** * Set the content event handler. * - * @param resolver The new content handler. + * @param handler the new content handler */ public void setContentHandler (ContentHandler handler) { @@ -298,7 +297,7 @@ public class XMLFilterImpl /** * Set the error event handler. * - * @param handle The new error handler. + * @param handler the new error handler */ public void setErrorHandler (ErrorHandler handler) { diff --git a/java/external/src/org/xml/sax/helpers/XMLReaderAdapter.java b/java/external/src/org/xml/sax/helpers/XMLReaderAdapter.java index 44f3c8c..68fa08f 100644 --- a/java/external/src/org/xml/sax/helpers/XMLReaderAdapter.java +++ b/java/external/src/org/xml/sax/helpers/XMLReaderAdapter.java @@ -2,7 +2,6 @@ // http://www.saxproject.org // Written by David Megginson // NO WARRANTY! This class is in the public domain. - // $Id$ package org.xml.sax.helpers; @@ -108,7 +107,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler } - + //////////////////////////////////////////////////////////////////// // Implementation of org.xml.sax.Parser. //////////////////////////////////////////////////////////////////// @@ -120,7 +119,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler *

This is not supported in SAX2, and will always throw * an exception.

* - * @param The locale for error reporting. + * @param locale the locale for error reporting. * @see org.xml.sax.Parser#setLocale * @exception org.xml.sax.SAXException Thrown unless overridden. */ diff --git a/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java b/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java index 2983df4..c3a669f 100644 --- a/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java +++ b/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java @@ -3,7 +3,6 @@ // Written by David Megginson // and by David Brownell // NO WARRANTY! This class is in the Public Domain. - // $Id$ package org.xml.sax.helpers; @@ -110,7 +109,7 @@ final public class XMLReaderFactory // 1. try the JVM-instance-wide system property try { className = System.getProperty (property); } - catch (Exception e) { /* normally fails for applets */ } + catch (RuntimeException e) { /* normally fails for applets */ } // 2. if that fails, try META-INF/services/ if (className == null) { @@ -141,6 +140,7 @@ final public class XMLReaderFactory // EXAMPLE: // className = "com.example.sax.XmlReader"; // or a $JAVA_HOME/jre/lib/*properties setting... + className = "org.apache.xerces.parsers.SAXParser"; // END DISTRIBUTION-SPECIFIC } diff --git a/java/external/src/org/xml/sax/helpers/package.html b/java/external/src/org/xml/sax/helpers/package.html index 155182d..dcd8ca5 100644 --- a/java/external/src/org/xml/sax/helpers/package.html +++ b/java/external/src/org/xml/sax/helpers/package.html @@ -1,7 +1,5 @@ - -

This package contains "helper" classes, including diff --git a/java/external/src/org/xml/sax/package.html b/java/external/src/org/xml/sax/package.html index 1691077..70f50f5 100644 --- a/java/external/src/org/xml/sax/package.html +++ b/java/external/src/org/xml/sax/package.html @@ -1,13 +1,11 @@ - -

This package provides the core SAX APIs. Some SAX1 APIs are deprecated to encourage integration of namespace-awareness into designs of new applications -and into maintainance of existing infrastructure.

+and into maintenance of existing infrastructure.

See http://www.saxproject.org for more information about SAX.

@@ -29,68 +27,194 @@ Currently defined standard feature URIs have the prefix + + + general entities; always true if validating. + + + parameter entities; always true if validating. + + + + + + + + + - + + - + + - + + + + + + + + + - + testing of equality/inequality against string constants, + rather than forcing slower calls to String.equals(). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + +
Feature IDAccess Default Description
external-general-entitiesread/write unspecified Reports whether this parser processes external - general entities; always true if validating
external-parameter-entitiesread/write unspecified Reports whether this parser processes external - parameter entities; always true if validating
is-standalone(parsing) read-only, (not parsing) nonenot applicable May be examined only during a parse, after the + startDocument() callback has been completed; read-only. + The value is true if the document specified standalone="yes" in + its XML declaration, and otherwise is false. +
lexical-handler/parameter-entitiesread/write unspecified true indicates that the LexicalHandler will report the - beginning and end of parameter entities - A value of "true" indicates that the LexicalHandler will report + the beginning and end of parameter entities. +
namespacesread/write true true indicates namespace URIs and unprefixed local names - for element and attribute names will be available A value of "true" indicates namespace URIs and unprefixed local names + for element and attribute names will be available. +
namespace-prefixesread/write false true indicates XML 1.0 names (with prefixes) and attributes - (including xmlns* attributes) will be available A value of "true" indicates that XML qualified names (with prefixes) and + attributes (including xmlns* attributes) will be available. +
resolve-dtd-urisread/writetrue A value of "true" indicates that system IDs in declarations will + be absolutized (relative to their base URIs) before reporting. + (That is the default behavior for all SAX2 XML parsers.) + A value of "false" indicates those IDs will not be absolutized; + parsers will provide the base URI from + Locator.getSystemId(). + This applies to system IDs passed in
    +
  • DTDHandler.notationDecl(), +
  • DTDHandler.unparsedEntityDecl(), and +
  • DeclHandler.externalEntityDecl(). +
+ It does not apply to EntityResolver.resolveEntity(), + which is not used to report declarations, or to + LexicalHandler.startDTD(), which already provides + the non-absolutized URI. +
string-interningread/write unspecified true if all XML names (for elements, prefixes, attributes, - entities, notations, and local names), + Has a value of "true" if all XML names (for elements, prefixes, + attributes, entities, notations, and local names), as well as Namespace URIs, will have been interned using java.lang.String.intern. This supports fast - testing of equality/inequality against string constants.
unicode-normalization-checkingread/writefalse Controls whether the parser reports Unicode normalization + errors as described in section 2.13 and Appendix B of the + XML 1.1 Recommendation. If true, Unicode normalization + errors are reported using the ErrorHandler.error() callback. + Such errors are not fatal in themselves (though, obviously, + other Unicode-related encoding errors may be). +
use-attributes2read-onlynot applicable Returns "true" if the Attributes objects passed by + this parser in ContentHandler.startElement() + implement the org.xml.sax.ext.Attributes2 interface. + That interface exposes additional DTD-related information, + such as whether the attribute was specified in the + source text rather than defaulted. +
use-locator2read-onlynot applicable Returns "true" if the Locator objects passed by + this parser in ContentHandler.setDocumentLocator() + implement the org.xml.sax.ext.Locator2 interface. + That interface exposes additional entity information, + such as the character encoding and XML version used. +
use-entity-resolver2read/writetrue Returns "true" if, when setEntityResolver is given + an object implementing the org.xml.sax.ext.EntityResolver2 interface, + those new methods will be used. + Returns "false" to indicate that those methods will not be used. +
validationread/write unspecified controls whether the parser is reporting all validity - errors; if true, all external entities will be read. Controls whether the parser is reporting all validity + errors; if true, all external entities will be read. +
xmlns-urisread/writefalse Controls whether, when the namespace-prefixes feature + is set, the parser treats namespace declaration attributes as + being in the http://www.w3.org/2000/xmlns/ namespace. + By default, SAX2 conforms to the original "Namespaces in XML" + Recommendation, which explicitly states that such attributes are + not in any namespace. + Setting this optional flag to "true" makes the SAX2 events conform to + a later backwards-incompatible revision of that recommendation, + placing those attributes in a namespace. +
xml-1.1read-onlynot applicable Returns "true" if the parser supports both XML 1.1 and XML 1.0. + Returns "false" if the parser supports only XML 1.0. +

Support for the default values of the namespaces and namespace-prefixes properties is required. +Support for any other feature flags is entirely optional.

For default values not specified by SAX2, @@ -128,6 +252,15 @@ the standard property URIs have the prefix + + document-xml-version + May be examined only during a parse, after the startDocument() + callback has been completed; read-only. This property is a + literal string describing the actual XML version of the document, + such as "1.0" or "1.1". + + + dom-node For "DOM Walker" style parsers, which ignore their @@ -141,7 +274,7 @@ the standard property URIs have the prefix lexical-handler Used to see some syntax events that are essential in some - applications: comments, CDATA delimeters, selected general + applications: comments, CDATA delimiters, selected general entity inclusions, and the start and end of the DTD (and declaration of document element name). The Object must implement - + \ No newline at end of file