Copyright ©2001 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This specification defines the Document Object Model Abstract Schemas and Load and Save Level 3, a platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure and style of documents. The Document Object Model Abstract Schemas and Load and Save Level 3 builds on the Document Object Model Core Level 3.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. The latest status of this document series is maintained at the W3C.
This is a W3C Working Draft for review by W3C members and other interested parties.
It is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". This is work in progress and does not imply endorsement by, or the consensus of, either W3C or members of the DOM working group.
Comments on this document are invited and are to be sent to the public mailing list www-dom@w3.org. An archive is available at http://lists.w3.org/Archives/Public/www-dom/.
This document has been produced as part of the W3C DOM Activity. The authors of this document are the DOM WG members.
A list of current W3C Recommendations and other technical documents can be found at http://www.w3.org/TR.
Copyright © 2001 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
This document is published under the W3C Document Copyright Notice and License. The bindings within this document are published under the W3C Software Copyright Notice and License. The software license requires "Notice of any changes or modifications to the W3C files, including the date changes were made." Consequently, modified versions of the DOM bindings must document that they do not conform to the W3C standard; in the case of the IDL definitions, the pragma prefix can no longer be 'w3c.org'; in the case of the Java language binding, the package names can no longer be in the 'org.w3c' package.
Note: This section is a copy of the W3C Document Notice and License and could be found at http://www.w3.org/Consortium/Legal/copyright-documents-19990405.
Copyright © 1994-2001 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
Public documents on the W3C site are provided by the copyright holders under the following license. The software or Document Type Definitions (DTDs) associated with W3C specifications are governed by the Software Notice. By using and/or copying this document, or the W3C document from which this statement is linked, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
Permission to use, copy, and distribute the contents of this document, or the W3C document from which this statement is linked, in any medium for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the document, or portions thereof, that you use:
When space permits, inclusion of the full text of this NOTICE should be provided. We request that authorship attribution be provided in any software, documents, or other items or products that you create pursuant to the implementation of the contents of this document, or any portion thereof.
No right to create modifications or derivatives of W3C documents is granted pursuant to this license. However, if additional requirements (documented in the Copyright FAQ) are satisfied, the right to create modifications or derivatives is sometimes granted by the W3C to individuals complying with those requirements.
THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to this document or its contents without specific, written prior permission. Title to copyright in this document will at all times remain with copyright holders.
Note: This section is a copy of the W3C Software Copyright Notice and License and could be found at http://www.w3.org/Consortium/Legal/copyright-software-19980720
Copyright © 1994-2001 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
This W3C work (including software, documents, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
Permission to use, copy, and modify this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications, that you make:
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
This chapter describes the optional DOM Level 3 Abstract
Schema (AS) feature. This module provides a
representation for XML abstract schemas, e.g., DTDs and XML
Schemas, together with operations on the abstract schemas, and how
such information within the abstract schemas could be applied to
XML documents used in both the document-editing and AS-editing
worlds. It also provides additional tests for well-formedness of
XML documents, including Namespace well-formedness. A DOM
application can use the hasFeature
method of
theDOMImplementation
interface to determine whether a
given DOM supports these capabilities or not. One feature string
for the AS-editing interfaces listed in this section is "AS-EDIT"
and another feature string for document-editing interfaces is
"AS-DOC".
This chapter interacts strongly with the Load and Save chapter, which is also under development in DOM Level 3. Not only will that code serialize/deserialize abstract schemas, but it may also wind up defining its well-formedness and validity checks in terms of what is defined in this chapter. In addition, the AS and Load/Save functional areas will share a common error-reporting mechanism allowing user-registered error callbacks. Note that this may not imply that the parser actually calls the DOM's validation code -- it may be able to achieve better performance via its own -- but the appearance to the user should probably be "as if" the DOM has been asked to validate the document, and parsers should probably be able to validate newly loaded documents in terms of a previously loaded DOM AS.
Finally, this chapter will have separate sections to address the needs of the document-editing and AS-editing worlds, along with a section that details overlapping areas such as validation. In this manner, the document-editing world's focuses on editing aspects and usage of information in the AS are made distinct from the AS-editing world's focuses on defining and manipulating the information in the AS.
In the October 9, 1997 DOM requirements document, the following appeared: "There will be a way to determine the presence of a DTD. There will be a way to add, remove, and change declarations in the underlying DTD (if available). There will be a way to test conformance of all or part of the given document against a DTD (if available)." In later discussions, the following was added, "There will be a way to query element/attribute (and maybe other) declarations in the underlying DTD (if available)," supplementing the primitive support for these in Level 1.
That work was deferred past Level 2, in the hope that XML Schemas would be addressed as well. It is anticipated that lowest common denominator general APIs generated in this chapter can support both DTDs and XML Schemas, and other XML abstract schemas down the road.
The kinds of information that an Abstract Schema must make available are mostly self-evident from the definitions of Infoset, DTDs, and XML Schemas. Note that some kinds of information on which the DOM already relies, e.g., default values for attributes, will finally be given a visible representation here, however.
The abstract schema referenced in these use cases/requirements is an abstraction and does not refer solely to DTDs or XML Schemas.
For the AS-editing and document-editing worlds, the following use cases and requirements are common to both and could be labeled as the "Validation and Other Common Functionality" section:
Use Cases:
Requirements:
Specific to the AS-editing world, the following are use cases and requirements and could be labeled as the "AS-editing" section:
Use Cases:
Requirements:
Specific to the document-editing world, the following are use cases and requirements and could be labeled as the "Document-editing" section:
Use Cases:
Requirements:
General Issues:
QName
, e.g.,
foo:bar
, whereas the latter will report its namespace
and local name, e.g., {http://my.namespace}bar
. We
have added the isNamespaceAware
attribute to the
generic AS object to help applications determine which of these
fields are important, but we are still analyzing this
challenge.A list of the proposed Abstract Schema data structures and functions follow, starting off with the data structures and "AS-editing" methods.
ASModel
is an abstract object that could map to a
DTD, an XML Schema, a database schema, etc. It's a generalized
abstract schema object, that has both an internal and external
subset. The internal subset would always exist, even if empty, with
the external subset (if present) being represented as by an
"active" ASExternalModel
.
Many ASExternalModel
s
could exist, but only one can be specified as "active"; it is also
possible that none are "active". The issue of multiple abstract
schemas is misleading since in this architecture, only one
ASModel
exists, with an internal subset that
references the external subset. If the external subset changes to
another "acitve" ASExternalModel
,
the internal subset is "fixed up." The ASModel also contains the
factory methods needed to create a various types of ASNodes like ASElementDeclaration
,
ASAttributeDeclaration
, etc.
interface ASModel : ASNode { readonly attribute boolean isNamespaceAware; attribute ASElementDeclaration rootElementDecl; attribute DOMString systemId; attribute DOMString publicId; ASNodeList getASNodes(); boolean removeNode(in ASNode node); boolean insertBefore(in ASNode newNode, in ASNode refNode); boolean validate(); ASElementDeclaration createASElementDeclaration(inout DOMString namespaceURI, in DOMString qualifiedElementName) raises(DOMException); ASAttributeDeclaration createASAttributeDeclaration(inout DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); ASNotationDeclaration createASNotationDeclaration(inout DOMString namespaceURI, in DOMString qualifiedElementName, in DOMString systemIdentifier, inout DOMString publicIdentifier) raises(DOMException); ASEntityDeclaration createASEntityDeclaration(in DOMString name) raises(DOMException); ASChildren createASChildren(in unsigned long minOccurs, in unsigned long maxOccurs, inout unsigned short operator) raises(DOMException); };
isNamespaceAware
of type boolean
, readonlyQNames
.publicId
of type
DOMString
rootElementDecl
of type ASElementDeclaration
systemId
of type
DOMString
createASAttributeDeclaration
namespaceURI
of type
DOMString
qualifiedName
of type
DOMString
A new ASAttributeDeclaration object with
|
|
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createASChildren
minOccurs
of type
unsigned long
maxOccurs
of type
unsigned long
operator
of type
unsigned short
A new ASChildren object. |
|
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createASElementDeclaration
namespaceURI
of type
DOMString
qualifiedElementName
of
type DOMString
A new ASElementDeclaration object with |
|
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. DUPLICATE_NAME_ERR:Raised if an element declaration already exists with the same name for a given ASModel. |
createASEntityDeclaration
name
of type
DOMString
A new ASNotationDeclaration object with |
|
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createASNotationDeclaration
namespaceURI
of type
DOMString
qualifiedElementName
of
type DOMString
systemIdentifier
of type
DOMString
publicIdentifier
of type
DOMString
A new ASNotationDeclaration object with
|
|
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. DUPLICATE_NAME_ERR:Raised if a notation declaration already exists with the same name for a given ASModel. |
getASNodes
insertBefore
ASNode
in front of a reference node. If the referenced node is
null
the new node is inserted in the back of the list
of nodes maintaoned by the ASModel.
|
|
removeNode
validate
|
Is the AS valid? |
ASExternalModel
is an abstract object that could
map to a DTD, an XML Schema, a database schema, etc. It's a
generalized abstract schema object that is not bound to a
particular XML document.
interface ASExternalModel : ASModel { };
ASNode
is analogous to a Node
in the
Core DOM, e.g., an element declaration. This can exist for both ASExternalModel
and ASModel
.
It must be able to handle constructs such as comments and
processing instructions.
Opaque.
interface ASNode { const unsigned short AS_ELEMENT_DECLARATION = 1; const unsigned short AS_ATTRIBUTE_DECLARATION = 2; const unsigned short AS_NOTATION_DECLARATION = 3; const unsigned short AS_ENTITY_DECLARATION = 4; const unsigned short AS_CHILDREN = 5; const unsigned short AS_MODEL = 6; const unsigned short AS_EXTERNALMODEL = 7; readonly attribute unsigned short cmNodeType; attribute ASModel ownerASModel; attribute DOMString nodeName; attribute DOMString prefix; attribute DOMString localName; attribute DOMString namespaceURI; ASNode cloneASNode(); };
ASElementDeclaration
.ASAttributeDeclaration
.ASNotationDeclaration
.
ASEntityDeclaration
.ASChildren
.ASModel
.ASExternalModel
.cmNodeType
of type unsigned
short
, readonlylocalName
of type
DOMString
qualified name
of
this ASNode.namespaceURI
of type
DOMString
nodeName
of type
DOMString
qualified name
of this ASNode depending on the
ASNode type.ownerASModel
of type ASModel
ASModel
object associated with this ASNode. For a node of type
AS_MODEL
, this is null
.prefix
of type
DOMString
ASNodeList
is the AS analogue to
NodeList
; the document order is meaningful, as opposed
to ASNamedNodeMap
.
ASNodeList
objects in the DOM AS are live.
interface ASNodeList { readonly attribute int length; ASNode item(in int index); };
length
of type
int
, readonlylength-1
inclusive.item
index
th item in the
collection. The index starts at 0. If index
is greater
than or equal to the number of nodes in the list, this returns
null
.
index
of type
int
The ASNode at the |
ASDOMStringList
represents a collection of
DOMStrings.
interface ASDOMStringList { readonly attribute int length; DOMString item(in int index); };
length
of type
int
, readonlylength-1
inclusive.item
index
th DOMString in
the collection. The index starts at 0. If index
is
greater than or equal to the number of nodes in the list, this
returns null
.
index
of type
int
|
The DOMString at the |
ASNamedNodeMap
is the AS analogue to
NamedNodeMap
. The order is not meaningful. Although
the contents of an ASNamedNodeMap is accessible through an ordinal,
it does not imply that DOM AS specifies an order on these
ASNodes.
interface ASNamedNodeMap { readonly attribute int length; ASNode getNamedItem(inout DOMString name); ASNode getNamedItemNS(in DOMString namespaceURI, inout DOMString localName); ASNode item(in int index); ASNode removeNamedItem(in DOMString name); ASNode removeNamedItemNS(in DOMString namespaceURI, in DOMString localName); ASNode setNamedItem(inout ASNode newASNode) raises(DOMASException); ASNode setNamedItemNS(inout ASNode newASNode) raises(DOMASException); };
length
of type
int
, readonlylength-1
inclusive.getNamedItem
getNamedItemNS
namespaceURI
of type
DOMString
localName
of type
DOMString
A ASNode (of any type) with the specified local name and namespace URI, or null if they do not identify any ASNode in this map. |
item
index
th item in the
map. The index starts at 0. If index
is greater than
or equal to the number of nodes in the list, this returns
null
.
index
of type
int
The ASNode at the |
removeNamedItem
name
of type
DOMString
The ASNode removed from this map if an ASNode with such a name exists. |
removeNamedItemNS
namespaceURI
of type
DOMString
localName
of type
DOMString
The ASNode removed from this map if an ASNode with such a local name and namespace URI exists. |
setNamedItem
newASNode
of type ASNode
If the new node replaces an existing one, the replaced node is
returned, otherwise |
|
setNamedItemNS
namespaceURI
and localName
attributes. If
an ASNode with the same namespaceURI and localName is already
present in this map, it is replaced by the new one.
newASNode
of type ASNode
If the new node replaces an existing one, the replaced node is
returned, otherwise |
|
The only primitive datatype supported by base DOM AS
implementation is string
type.
interface ASDataType { const short STRING_DATATYPE = 1; short getASPrimitiveType(); };
string
data type as defined
in XML
Schema Datatypes.getASPrimitiveType
|
code representing the primitive type of the attached data item. |
The primitive types supported by optional DOM AS implementations. A DOM application can use the hasFeature method of the DOMImplementation interface to determine whether this interface is supported or not. The feature string for all the interfaces listed in this section is "AS-PTYPES" and the version is "3.0".
interface ASPrimitiveType : ASDataType { const short BOOLEAN_DATATYPE = 2; const short FLOAT_DATATYPE = 3; const short DOUBLE_DATATYPE = 4; const short DECIMAL_DATATYPE = 5; const short HEXBINARY_DATATYPE = 6; const short BASE64BINARY_DATATYPE = 7; const short ANYURI_DATATYPE = 8; const short QNAME_DATATYPE = 9; const short DURATION_DATATYPE = 10; const short DATETIME_DATATYPE = 11; const short DATE_DATATYPE = 12; const short TIME_DATATYPE = 13; const short YEARMONTH_DATATYPE = 14; const short YEAR_DATATYPE = 15; const short MONTHDAY_DATATYPE = 16; const short DAY_DATATYPE = 17; const short MONTH_DATATYPE = 18; const short NOTATION_DATATYPE = 19; attribute decimal lowValue; attribute decimal highValue; };
boolean
data type as defined
in XML
Schema Datatypes.float
data type as defined
in XML
Schema Datatypes.double
data type as defined
in XML
Schema Datatypes.decimal
data type as defined
in XML
Schema Datatypes.hexbinary
data type as defined
in XML
Schema Datatypes.base64binary
data type as
defined in XML Schema
Datatypes.uri reference
data type as
defined in XML Schema Datatypes.
Note: @@uriReference is no longer part of the XML Schema PR draft.
XML qualified name
data type
as defined in XML
Schema Datatypes.duration
data type as defined
in XML
Schema Datatypes.datetime
data type as defined
in XML
Schema Datatypes.date
data type as defined in XML Schema
Datatypes.time
data type as defined in
XML
Schema Datatypes.yearmonth
data type as defined
in XML
Schema Datatypes.year
data type as defined in
XML
Schema Datatypes.monthday
data type as defined
in XML
Schema Datatypes.day
data type as defined in XML Schema
Datatypes.month
data type as defined in
XML
Schema Datatypes.NOTATION
data type as defined in
XML
Schema Datatypes.The element name along with the content specification in the
context of an ASNode
.
interface ASElementDeclaration : ASNode { const short EMPTY_CONTENTTYPE = 1; const short ANY_CONTENTTYPE = 2; const short MIXED_CONTENTTYPE = 3; const short ELEMENTS_CONTENTTYPE = 4; attribute boolean strictMixedContent; attribute ASDataType elementType; attribute boolean isPCDataOnly; attribute short contentType; attribute DOMString tagName; ASChildren getASChildren(); void setASChildren(inout ASChildren elementContent) raises(DOMASException); ASNamedNodeMap getASAttributeDecls(); void setASAttributeDecls(inout ASNamedNodeMap attributes); void addASAttributeDecl(in ASAttributeDeclaration attributeDecl); ASAttributeDeclaration removeASAttributeDecl(in ASAttributeDeclaration attributeDecl); };
contentType
of type short
elementType
of type
ASDataType
isPCDataOnly
of type boolean
strictMixedContent
of type boolean
tagName
of type
DOMString
addASAttributeDecl
ASAttributeDeclaration
for the element being
declared.
attributeDecl
of type
ASAttributeDeclaration
getASAttributeDecls
ASNamedNodeMap
containing
ASAttributeDeclarations
for all the attributes
that can appear on this type of element.
Attributes list for this |
getASChildren
Content model of this element. |
removeASAttributeDecl
ASAttributeDeclaration
from the element being
declared.
attributeDecl
of type
ASAttributeDeclaration
|
setASAttributeDecls
ASNamedNodeMap
containing
ASAttributeDeclarations
for all the attributes
that can appear on this type of element.
attributes
of type ASNamedNodeMap
setASChildren
elementContent
of type ASChildren
|
Raises exception AS_NO_CHILD_ALLOWED_ERR if the element is defined to be of EMPTY_CONTENTTYPE. |
The content model of a declared element.
interface ASChildren : ASNode { const unsigned long UNBOUNDED = MAX_LONG; const unsigned short NONE = 0; const unsigned short SEQUENCE = 1; const unsigned short CHOICE = 2; attribute unsigned short listOperator; attribute unsigned long minOccurs; attribute unsigned long maxOccurs; attribute ASNodeList subModels; ASNode removeASNode(in unsigned long nodeIndex); int insertASNode(in unsigned long nodeIndex, in ASNode newNode); int appendASNode(in ASNode newNode); };
subModels
. This is
usually the case where the subModels contain a single element
declaration.listOperator
of type unsigned short
subModels
. For example,
if the list operator is CHOICE and the components in subModels are
a, b and c then the abstract schema for the element being declared
is (a|b|c)maxOccurs
of type unsigned long
minOccurs
of type unsigned long
subModels
of type ASNodeList
ASNode
s
in which the element can be defined.appendASNode
subModels
.
newNode
of type ASNode
|
the length of the |
insertASNode
nodeIndex
of type
unsigned long
newNode
of type ASNode
|
The index value at which it is inserted. If the nodeIndex is
outside the bound of the |
removeASNode
nodeIndex
of type
unsigned long
The node removed is returned as a result of this method call.
The method returns |
An attribute declaration in the context of a ASNode
.
interface ASAttributeDeclaration : ASNode { const short NO_VALUE_CONSTRAINT = 0; const short DEFAULT_VALUE_CONSTRAINT = 1; const short FIXED_VALUE_CONSTRAINT = 2; attribute DOMString attrName; attribute ASDataType attrType; attribute DOMString attributeValue; attribute DOMString enumAttr; attribute ASNodeList ownerElement; attribute short constraintType; };
attrName
of type
DOMString
attrType
of type
ASDataType
attributeValue
of
type DOMString
constraintType
of
type short
enumAttr
of type
DOMString
ownerElement
of type
ASNodeList
Models a general entity declaration in an abstract schema.
interface ASEntityDeclaration : ASNode { const short INTERNAL_ENTITY = 1; const short EXTERNAL_ENTITY = 2; attribute short entityType; attribute DOMString entityName; attribute DOMString entityValue; attribute DOMString systemId; attribute DOMString publicId; attribute DOMString notationName; };
entityName
of type DOMString
entityType
of type short
entityValue
of type DOMString
null
.notationName
of type DOMString
null
.publicId
of
type DOMString
null
.systemId
of
type DOMString
null
.This interface represents a notation declaration.
interface ASNotationDeclaration : ASNode { attribute DOMString notationName; attribute DOMString systemId; attribute DOMString publicId; };
notationName
of type DOMString
publicId
of
type DOMString
systemId
of
type DOMString
This section contains "Validation and Other" methods common to
both the document-editing and AS-editing worlds (includes Document
,
DOMImplementation
, and DOMErrorHandler
methods).
The setErrorHandler
method is off of the
Document
interface.
interface Document { void setErrorHandler(in DOMErrorHandler handler); };
setErrorHandler
handler
of type DOMErrorHandler
This interface extends the Document
interface with additional methods for both document and AS
editing.
interface DocumentAS : Document { attribute boolean continuousValidityChecking; int numASs(); ASModel getInternalAS(); ASNodeList getASs(); ASModel getActiveAS(); void addAS(in ASModel cm); void removeAS(in ASModel cm); boolean activateAS(in ASModel cm); };
continuousValidityChecking
of type boolean
activateAS
ASModel
active. Note that if a user wants to activate one AS to get default
attribute values and then activate another to do validation, a user
can do that; however, only one AS is active at a time. If an
attribute is declared in an internal subset and the corresponding
ownerElement
points to a ASElementDeclaration
defined in an external subset, changing the active AS will cause
the ownerElement to be recomputed. If the owner element is not
defined in the newly active AS, the ownerElement
will
be an empty node list.
cm
of type ASModel
ASModel
points to a list of ASExternalModel
s;
with this call, only the specified AS will be active.
|
True if the |
addAS
ASModel
with a document. Can be invoked multiple times to result in a list
of ASExternalModel
s.
Note that only one internal ASModel
is associated with the document, however, and that only one of the
possible list of ASExternalModel
s
is active at any one time.
cm
of type ASModel
getASs
ASNode
s
of type AS_EXTERNAL_MODEL
s associated with the
document. The addAS
method associates a model with a
document.
A list of |
getActiveAS
ASExternalModel
for a document.
|
getInternalAS
numASs
ASExternalModel
s
associated with the document. Only one ASModel
can be associated with the document, but it may point to a list of
ASExternalModel
s.
|
Non-negative number of external AS objects. |
removeAS
ASExternalModel
associated with a document. Can be invoked multiple times to remove
a number of these in the list of ASExternalModel
s.
cm
of type ASModel
This interface extends the DOMImplementation
interface with additional methods.
interface DOMImplementationAS : DOMImplementation { ASModel createAS(); ASExternalModel createExternalAS(); };
createAS
A NULL return indicates failure. |
createExternalAS
A NULL return indicates failure. |
This section contains "Document-editing" methods (includes
Node
, Element
, Text
and Document
methods).
This interface extends the Node
interface with
additional methods for guided document editing.
interface NodeAS : Node { const short WF_CHECK = 1; const short NS_WF_CHECK = 2; const short PARTIAL_VALIDITY_CHECK = 3; const short STRICT_VALIDITY_CHECK = 4; attribute short wfValidityCheckLevel; boolean canInsertBefore(in Node newChild, in Node refChild) raises(DOMException); boolean canRemoveChild(in Node oldChild) raises(DOMException); boolean canReplaceChild(in Node newChild, in Node oldChild) raises(DOMException); boolean canAppendChild(in Node newChild) raises(DOMException); boolean isValid(in boolean deep) raises(DOMException); };
wfValidityCheckLevel
of
type short
isValid
method.
Default value for this attribute is
STRICT_VALIDITY_CHECK
canAppendChild
AppendChild
.
newChild
of type
Node
Node
to be appended.
|
A boolean that is true if the |
|
DOMException. |
canInsertBefore
Node::InsertBefore
operation would make this document
invalid with respect to the currently active AS. ISSUE: Describe
"valid" when referring to partially completed documents.
newChild
of type
Node
Node
to be inserted.refChild
of type
Node
Node
.
|
A boolean that is true if the |
|
DOMException. |
canRemoveChild
RemoveChild
.
oldChild
of type
Node
Node
to be removed.
|
A boolean that is true if the |
|
DOMException. |
canReplaceChild
ReplaceChild
.
newChild
of type
Node
Node
.oldChild
of type
Node
Node
to be replaced.
|
A boolean that is true if the |
|
DOMException. |
isValid
deep
of type
boolean
deep
flag
on, causes isValid method to check for the whole subtree of the
current node for validity. Setting it to false only checks the
current node and its immediate child nodes against the grammar
corresponding to that element declaration .
|
|
|
NO_AS_AVAILABLE: Exception is raised if the DocumentAS related to this node does not have any activeAS and wfValidityCheckLevel is set to PARTIAL or STRICT_VALIDITY_CHECK. |
This interface extends the Element
interface with
additional methods for guided document editing. An object
implmenting this interface must also implement NodeAS
interface.
interface ElementAS : Element { short contentType(); ASElementDeclaration getElementDeclaration() raises(DOMException); boolean canSetAttribute(in DOMString attrname, in DOMString attrval); boolean canSetAttributeNode(in Node node); boolean canSetAttributeNodeNS(in Node node); boolean canSetAttributeNS(in DOMString attrname, in DOMString attrval, in DOMString namespaceURI, in DOMString localName); boolean canRemoveAttribute(in DOMString attrname); boolean canRemoveAttributeNS(in DOMString attrname, inout DOMString namespaceURI); boolean canRemoveAttributeNode(in Node node); ASDOMStringList getChildElements(); ASDOMStringList getParentElements(); ASDOMStringList getAttributeList(); };
canRemoveAttribute
attrname
of type
DOMString
|
true or false. |
canRemoveAttributeNS
attrname
of type
DOMString
namespaceURI
of type
DOMString
|
true or false. |
canRemoveAttributeNode
node
of type
Node
Attr
node to remove from the attribute
list.
|
true or false. |
canSetAttribute
attrname
of type
DOMString
attrval
of type
DOMString
|
true or false. |
canSetAttributeNS
setAttributeNS
.
attrname
of type
DOMString
attrval
of type
DOMString
namespaceURI
of type
DOMString
namespaceURI
of namespace.localName
of type
DOMString
localName
of namespace.
|
Success or failure. |
canSetAttributeNode
node
of type
Node
Node
in which the attribute can possibly be
set.
|
Success or failure. |
canSetAttributeNodeNS
node
of type
Node
Attr
to be added to the attribute list.
|
Success or failure. |
contentType
|
Constant for mixed, empty, any, etc. |
getAttributeList
ASDOMStringList
containing all the possible Attr
s that can appear with
this type of element.
List of possible attributes of this element. |
getChildElements
ASDOMStringList
containing the possible Element
names that can appear
as children of this type of element.
List of possible children element types of this element. |
getElementDeclaration
ASElementDeclaration object if the implementation supports AS-EDIT feature. Otherwise null. |
|
If no abstract schema is present, raises this exception |
getParentElements
ASDOMStringList
containing the possible Element
names that can appear
as a parent of this type of element.
List of possible parent element types of this element. |
This interface extends the CharacterData
interface
with additional methods for document editing. An object implmenting
this interface must also implement NodeAS interface.
interface CharacterDataAS : CharacterData { boolean isWhitespaceOnly(); boolean canSetData(in unsigned long offset, in DOMString arg) raises(DOMException); boolean canAppendData(in DOMString arg) raises(DOMException); boolean canReplaceData(in unsigned long offset, in unsigned long count, in DOMString arg) raises(DOMException); boolean canInsertData(in unsigned long offset, in DOMString arg) raises(DOMException); boolean canDeleteData(in unsigned long offset, in DOMString arg) raises(DOMException); };
canAppendData
arg
of type
DOMString
|
Success or failure. |
|
DOMException. |
canDeleteData
offset
of type
unsigned long
arg
of type
DOMString
|
Success or failure. |
|
DOMException. |
canInsertData
offset
of type
unsigned long
arg
of type
DOMString
|
Success or failure. |
|
DOMException. |
canReplaceData
offset
of type
unsigned long
count
of type
unsigned long
arg
of type
DOMString
|
Success or failure. |
|
DOMException. |
canSetData
offset
of type
unsigned long
arg
of type
DOMString
|
Success or failure. |
|
DOMException. |
isWhitespaceOnly
|
True if content only whitespace; false for non-whitespace if it is a text node in element content. |
This interface extends the DocumentType
interface
with additional methods for document editing. An object implmenting
this interface must also implement NodeAS interface.
interface DocumentTypeAS : DocumentType { readonly attribute ASDOMStringList definedElementTypes; boolean isElementDefined(in DOMString elemTypeName); boolean isElementDefinedNS(in DOMString elemTypeName, in DOMString namespaceURI, in DOMString localName); boolean isAttributeDefined(in DOMString elemTypeName, in DOMString attrName); boolean isAttributeDefinedNS(in DOMString elemTypeName, in DOMString attrName, in DOMString namespaceURI, in DOMString localName); boolean isEntityDefined(in DOMString entName); };
definedElementTypes
of type ASDOMStringList
,
readonlyisAttributeDefined
elemTypeName
of type
DOMString
attrName
of type
DOMString
|
A boolean that is true if the attribute is defined, false otherwise. |
isAttributeDefinedNS
elemTypeName
of type
DOMString
attrName
of type
DOMString
namespaceURI
of type
DOMString
namespaceURI
of namespace.localName
of type
DOMString
localName
of namespace.
|
A boolean that is true if the attribute with is defined, false otherwise. |
isElementDefined
elemTypeName
of type
DOMString
|
A boolean that is true if the element is defined, false otherwise. |
isElementDefinedNS
elemTypeName
of type
DOMString
namespaceURI
of type
DOMString
namespaceURI
of namespace.localName
of type
DOMString
localName
of namespace.
|
A boolean that is true if the element is defined, false otherwise. |
isEntityDefined
entName
of type
DOMString
|
A boolean that is true if the entity is defined, false otherwise. |
This interface extends Attr
to provide guided
editing of an XML document. An object implmenting this interface
must also implement NodeAS interface.
interface AttributeAS : Attr { ASAttributeDeclaration getAttributeDeclaration(); ASNotationDeclaration getNotation() raises(DOMException); };
getAttributeDeclaration
The attribute declaration corresponding to this attribute |
getNotation
Returns the notation declaration for this attribute if the type is of notation type, null otherwise. |
|
DOMException |
This section contains DOM error handling interfaces.
Basic interface for DOM error handlers. If an application needs
to implement customized error handling for DOM such as AS or
Load/Save, it must implement this interface and then register an
instance using the setErrorHandler
method. All errors
and warnings will then be reported through this interface.
Application writers can override the methods in a subclass to take
user-specified actions.
interface DOMErrorHandler { void warning(in DOMLocator where, in DOMString how, in DOMString why) raises(DOMSystemException); void fatalError(in DOMLocator where, in DOMString how, in DOMString why) raises(DOMSystemException); void error(in DOMLocator where, in DOMString how, in DOMString why) raises(DOMSystemException); };
error
where
of type DOMLocator
how
of type
DOMString
why
of type
DOMString
|
A subclass of DOMException. |
fatalError
where
of type DOMLocator
how
of type
DOMString
why
of type
DOMString
|
A subclass of DOMException. |
warning
where
of type DOMLocator
how
of type
DOMString
why
of type
DOMString
|
A subclass of DOMException. |
This interface provides document location information and is similar to a SAX locator object.
interface DOMLocator { int getColumnNumber(); int getLineNumber(); DOMString getPublicID(); DOMString getSystemID(); Node getNode(); };
getColumnNumber
|
The column number, or -1 if none is available. |
getLineNumber
|
The line number, or -1 if none is available. |
getNode
|
The NODE, or null if none is available. |
getPublicID
|
A string containing the public identifier, or null if none is available. |
getSystemID
|
A string containing the system identifier, or null if none is available. |
Editing and generating an abstract schema falls in the AS-editing world. The most obvious requirement for this set of requirements is for tools that author abstract schemas, either under user control, i.e., explicitly designed document types, or generated from other representations. The latter class includes transcoding tools, e.g., synthesizing an XML representation to match a database schema.
It's important to note here that a DTD's "internal subset" is part of the Abstract Schema, yet is loaded, stored, and maintained as part of the individual document instance. This implies that even tools which do not want to let users change the definition of the Document Type may need to support editing operations upon this portion of the AS. It also means that our representation of the AS must be aware of where each portion of its content resides, so that when the serializer processes this document it can write out just the internal subset. A similar issue may arise with external parsed entities, or if schemas introduce the ability to reference other schemas. Finally, the internal-subset case suggests that we may want at least a two-level representation of abstract schemas, so a single DOM representation of a DTD can be shared among several documents, each potentially also having its own internal subset; it's possible that entity layering may be represented the same way.
The API for altering the abstract schema may also be the AS's official interface with parsers. One of the ongoing problems in the DOM is that there is some information which must currently be created via completely undocumented mechanisms, which limits the ability to mix and match DOMs and parsers. Given that specialized DOMs are going to become more common (sub-classed, or wrappers around other kinds of storage, or optimized for specific tasks), we must avoid that situation and provide a "builder" API. Particular pairs of DOMs and parsers may bypass it, but it's required as a portability mechanism.
Note that several of these applications require that an AS be able to be created, loaded, and manipulated without/before being bound to a specific Document. A related issue is that we'd want to be able to share a single representation of an AS among several documents, both for storage efficiency and so that changes in the AS can quickly be tested by validating it against a set of known-good documents. Similarly, there is a known problem in DOM Level 2 where we assume that the DocumentType will be created before the Document, which is fine for newly-constructed documents but not a good match for the order in which an XML parser encounters this data; being able to "rebind" a Document to a new AS, after it has been created may be desirable.
As noted earlier, questions about whether one can alter the content of the AS via its syntax, via higher-level abstractions, or both, exist. It's also worth noting that many of the editing concepts from the Document tree still apply; users should probably be able to clone part of an AS, remove and re-insert parts, and so on.
In addition to using the abstract schema to validate a document instance, applications would like to be able to use it to guide construction and editing of documents, which falls into the document-editing world. Examples of this sort of guided editing already exist, and are becoming more common. The necessary queries can be phrased in several ways, the most useful of which may be a combination of "what does the DTD allow me to insert here" and "if I insert this here, will the document still be valid". The former is better suited to presentation to humans via a user interface, and when taken together with sub-tree validation may subsume the latter.
It has been proposed that in addition to asking questions about specific parts of the abstract schema, there should be a reasonable way to obtain a list of all the defined symbols of a given type (element, attribute, entity) independent of whether they're valid in a given location; that might be useful in building a list in a user-interface, which could then be updated to reflect which of these are relevant for the program's current state.
Remember that namespaces also weigh in on this issue, in the case of attributes, a "can-this-go-there" may prompt a namespace-well-formedness check and warn you if you're about to conflict with or overwrite another attribute with the same namespaceURI/localName but different prefix, or same nodeName but different namespaceURI.
We have to deal with the fact that "the shortest distance between two valid documents may be through an invalid one". Users may want to know several levels of detail (all the possible children, those which would be valid given what precedes this point, those which would be valid given both preceding and following siblings). Also, once XML Schemas introduce context sensitive validity, we may have to consider the effect of children as well as the individual node being inserted.
The most obvious use for an abstract schema (DTD or XML Schema or any Abstract Schema) is to use it to validate that a given XML document is in fact a properly constructed instance of the document type described by this AS. This again falls into the document-editing world. The XML spec only discusses performing this test at the time the document is loaded into the "processor", which most of us have taken to mean that this check should be performed at parse time. But it is obviously desirable to be able to validate again a document -- or selected subtrees -- at other times. One such case would be validating an edited or newly constructed document before serializing it or otherwise passing it to other users. This issue also arises if the "internal subset" is altered -- or if the whole Abstract Schema changes.
In the past, the DOM has allowed users to create invalid
documents, and assumed the serializer would accept the task of
detecting problems and announcing/repairing them when the document
was written out in XML syntax... or that they would be checked for
validity when read back in. We considered adding validity checks to
the DOM's existing editing operations to prevent creation of
invalid documents, but are currently inclined against this for
several reasons. First, it would impose a significant amount of
computational overhead to the DOM, which might be unnecessary in
many situations, e.g., if the change is occurring in a context
where we know the result will be valid. Second, "the shortest
distance between two good documents may be through a bad document".
Preventing a document from becoming temporarily invalid may impose
a considerable amount of additional work on higher-level code and
users Hence our current plan is to continue to permit editing to
produce invalid DOMs, but provide operations which permit a user to
check the validity of a node on demand. If needed one can use
continuousValidityChecking
flag to ensure that the DOM
remains valid during the editing process.
Note that validation includes checking that ID attributes are unique, and that IDREFs point to IDs which actually exist.
XML defined the "well-formed" (WF) state for documents which are parsed without reference to their DTDs. Knowing that a document is well-formed may be useful by itself even when a DTD is available. For example, users may wish to deliberately save an invalid document, perhaps as a checkpoint before further editing. Hence, the AS feature will permit both full validity checking (see previous section) and "lightweight" WF checking, as requested by the caller, as well as processing entity declarations in the AS even if validation is not turned on. This falls within the document-editing world.
While the DOM inherently enforces some of XML's well-formedness conditions (proper nesting of elements, constraints on which children may be placed within each node), there are some checks that are not yet performed. These include:
In addition, Namespaces introduce their own concepts of well-formedness. Specifically:
namespaceNormalize
operation, which would
create the implied declarations and reconcile conflicts in some
reasonably standardized manner. This may be a major undertaking,
since some DOMs may be using the namespace to direct subclassing of
the nodes or similar special treatment; as with the existing
normalize
method, you may be left with a
different-but-equivalent set of node objects.In the past, the DOM has allowed users to create documents which violate these rules, and assumed the serializer would accept the task of detecting problems and announcing/repairing them when the document was written out in XML syntax. We considered adding WF checks to the DOM's existing editing operations to prevent WF violations from arising, but are currently inclined against this for two reasons. First, it would impose a significant amount of computational overhead to the DOM, which might be unnecessary in many situations (for example, if the change is occurring in a context where we know the illegal characters have already been prevented from arising). Second, "the shortest distance between two good documents may be through a bad document" -- preventing a document from becoming temporarily ill-formed may impose a considerable amount of additional work on higher-level code and users. (Note possible issue for Serialization: In some applications, being able to save and reload marginally poorly-formed DOMs might be useful -- editor checkpoint files, for example.) Hence our current plan is to continue to permit editing to produce ill-formed DOMs, but provide operations which permit a user to check the well-formedness of a node on demand, and possibly provide some of the primitive (e.g., string-checking) functions directly.
DOM Level 3 will provide an API for loading XML source documents into a DOM representation and for saving a DOM representation as a XML document.
Some environments, such as the Java platform or COM, have their own ways to persist objects to streams and to restore them. There is no direct relationship between these mechanisms and the DOM load/save mechanism. This specification defines how to serialize documents only to and from XML format.
Requirements that apply to both loading and saving documents.
Documents must be able to be parsed from and saved to the following sources:
Note that Input and Output streams take care of the in memory case. One point of caution is that a stream doesn't allow a base URI to be defined against which all relative URIs in the document are resolved.
While creating a new document using the DOM API, a mechanism must be provided to specify that the new document uses a pre-existing Content Model and to cause that Content Model to be loaded.
Note that while DOM Level 2 creation can specify a Content Model when creating a document (public and system IDs for the external subset, and a string for the subset), DOM Level 2 implementations do not process the Content Model's content. For DOM Level 3, the Content Model's content must be read.
When processing a series of documents, all of which use the same Content Model, implementations should be able to reuse the already parsed and loaded Content Model rather than parsing it again for each new document.
This feature may not have an explicit DOM API associated with it, but it does require that nothing in this section, or the Content Model section, of this specification block it or make it difficult to implement.
Some means is required to allow applications to map public and system IDs to the correct document. This facility should provide sufficient capability to allow the implementation of catalogs, but providing catalogs themselves is not a requirement. In addition XML Base needs to be addressed.
Loading a document can cause the generation of errors including:
Saving a document can cause the generation of errors including:
This section, as well as the DOM Level 3 Content Model section should use a common error reporting mechanism. Well-formedness and validity checking are in the domain of the Content Model section, even though they may be commonly generated in response to an application asking that a document be loaded.
The following requirements apply to loading documents.
Parsers may have properties or options that can be set by applications. Examples include:
A mechanism to set properties, query the state of properties, and to query the set of properties supported by a particular DOM implementation is required.
The fundamental requirement is to write a DOM document as XML source. All information to be serialized should be available via the normal DOM API.
There are several options that can be defined when saving an XML document. Some of these are:
The following items are not committed to, but are under consideration. Public feedback on these items is especially requested.
Provide the ability for a thread that requested the loading of a document to continue execution without blocking while the document is being loaded. This would require some sort of notification or completion event when the loading process was done.
Provide the ability to examine the partial DOM representation before it has been fully loaded.
In one form, a document may be loaded asynchronously while a DOM based application is accessing the document. In another form, the application may explicitly ask for the next incremental portion of a document to be loaded.
Provide the capability to write out only a part of a document. May be able to leverage TreeWalkers, or the Filters associated with TreeWalkers, or Ranges as a means of specifying the portion of the document to be written.
Document fragments, as specified by the XML Fragment specification, should be able to be loaded. This is useful to applications that only need to process some part of a large document. Because the DOM is typically implemented as an in-memory representation of a document, fully loading large documents can require large amounts of memory.
XPath should also be considered as a way to identify XML Document fragments to load.
Document fragments, as specified by the XML Fragment specification, should be able to be loaded into the context of an existing document at a point specified by a node position, or perhaps a range. This is a separate feature than simply loading document fragments as a new Node.
DocumentBuilder
(Sun) and DOMParser
(Xerces).SAXException.toString()
and
SAXException.getMessage()
always the same? If not, we
need to add another attribute.DOMCMBuilder
interfaceDOMCMBuilder
interfaceDOMSystemException
needs to
be defined as part of the error handling module that is to be
shared with CM. Common I/O type errors need to be defined for it,
so that they can be reported in a uniform way. A way to embed
errors or exceptions from the OS or language environment is needed,
to provide full information to applications that want it.DOMBuilder
.This section defines an API for loading (parsing) XML source documents into a DOM representation and for saving (serializing) a DOM representation as an XML document.
The proposal for loading is influenced by Sun's JAXP API for XML Parsing in Java, http://java.sun.com/xml/download.html, and by SAX2, available at http://www.megginson.com/SAX/index.html
Here is a list of each of the interfaces involved with the Loading and Saving XML documents.
DOMImplementationLS
-- A new DOMImplementation
interface that provides the
factory methods for creating the objects required for loading and
saving.DOMBuilder
-- A parser interface.DOMInputSource
-- Encapsulate information about the source of the XML to be
loaded.DOMEntityResolver
-- During loading, provides a way for applications to redirect
references to external entities.DOMBuilderFilter
-- Provide the ability to examine and optionally remove Element
nodes as they are being processed during the parsing of a
document.DOMWriter
-- An interface for writing out or serializing DOM documents.DocumentLS
-- Provides a client or browser style interface for loading and
saving.ParserErrorEvent
-- ParserErrorEvent is the event that is fired if there's an error
in the XML document being parsed using the methods of
DocumentLS.DOMImplementationLS
contains the factory methods
for creating objects implementing the DOMBuilder
(parser) and DOMWriter
interfaces.
An object implementing DOMImplementationLS is obtained by casting from DOMImplementation to DOMImplementationLS, using the customary casting facilities from the programming language in use. Implementations supporting the Load and Save feature must implement the DOMImplementationLS interface on whatever object implements the DOMImplementation interface.
interface DOMImplementationLS { DOMBuilder createDOMBuilder(); DOMWriter createDOMWriter(); };
createDOMBuilder
DOMBuilder
.
The newly constructed parser may then be configured by means of its
setFeature()
method, and used to parse documents by
means of its parse()
method.
The newly created parser object. |
createDOMWriter
A Content Model parser interface.
DOMCMBuilder
provides an API for parsing Content
Models and building the corresponding CMModel tree.
interface DOMCMBuilder : DOMBuilder { CMModel parseCMURI(in DOMString uri) raises(DOMException, DOMSystemException); CMModel parseCMInputSource(in DOMInputSource is) raises(DOMException, DOMSystemException); };
parseCMInputSource
DOMInputSource
.
is
of type DOMInputSource
DOMInputSource
from which the source Content Model is to be read.
|
The newly created |
|
Exceptions raised by Raise a WRONG_MIME_TYPE_ERR when |
|
Exceptions raised by |
parseCMURI
uri
of type
DOMString
|
The newly created |
|
Exceptions raised by Raise a WRONG_MIME_TYPE_ERR when |
|
Exceptions raised by |
A parser interface.
DOMBuilder
provides an API for parsing XML
documents and building the corresponding DOM document tree. A
DOMBuilder
instance is obtained from the DOMImplementationLS
interface by invoking its
createDOMBuilder()
method.
DOMBuilder
s have a number of named properties that
can be queried or set. Here is a list of properties that must be
recognized by all implementations.
validate-if-cm
feature will alter the validation
behavior when this feature is set true.interface DOMBuilder { attribute DOMEntityResolver entityResolver; attribute DOMErrorHandler errorHandler; attribute DOMBuilderFilter filter; attribute boolean mimeTypeCheck; void setFeature(in DOMString name, in boolean state) raises(DOMException); boolean supportsFeature(in DOMString name); boolean canSetFeature(in DOMString name, in boolean state); boolean getFeature(in DOMString name) raises(DOMException); Document parseURI(in DOMString uri) raises(DOMException, DOMSystemException); Document parseDOMInputSource(in DOMInputSource is) raises(DOMException, DOMSystemException); };
entityResolver
of type
DOMEntityResolver
DOMEntityResolver
has been specified, each time a reference to an external entity is
encountered the DOMBuilder
will pass the public and
system IDs to the entity resolver, which can then specify the
actual source of the entity.errorHandler
of type DOMErrorHandler
DOMDcoumentBuilder
will call back to
the errorHandler
with the error information.
Note: The DOMErrorHandler interface is being developed separately, in conjunction with the design of the content model and validation module.
filter
of type DOMBuilderFilter
Element
node. The filter implementation can choose to
remove the element from the document being constructed or to
terminate the parse early.mimeTypeCheck
of type
boolean
canSetFeature
DOMBuilder
to recognize a feature
name but to be unable to set its value.
name
of type
DOMString
state
of type
boolean
|
true if the feature could be successfully set to the specified value, or false if the feature is not recognized or the requested value is not supported. The value of the feature itself is not changed. |
getFeature
name
of type
DOMString
|
The current state of the feature (true or false). |
|
Raise a NOT_FOUND_ERR When the |
parseDOMInputSource
DOMInputSource
.
is
of type DOMInputSource
DOMInputSource
from which the source document is to be read.
|
Exceptions raised by Raise a WRONG_MIME_TYPE_ERR when |
|
Exceptions raised by |
parseURI
uri
of type
DOMString
|
Exceptions raised by Raise a WRONG_MIME_TYPE_ERR when |
|
Exceptions raised by |
setFeature
DOMBuilder
to recognize a feature
name but to be unable to set its value.
name
of type
DOMString
state
of type
boolean
|
Raise a NOT_SUPPORTED_ERR exception When the
Raise a NOT_FOUND_ERR When the |
supportsFeature
DOMBuilder
recognizes a feature name.DOMBuilder
to recognize a feature
name but to be unable to set its value. For example, a
non-validating parser would recognize the feature "validation",
would report that its value was false, and would raise an exception
if an attempt was made to enable validation by setting the feature
to true.
name
of type
DOMString
|
true if the feature name is recognized by the
|
This interface represents a single input source for an XML entity.
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), and/or a character stream.
The exact definitions of a byte stream and a character stream are binding dependent.
There are two places that the application will deliver this
input source to the parser: as the argument to the
parseDOMInputSource
method, or as the return value of
the DOMEntityResolver.resolveEntity
method.
The DOMBuilder
will use the DOMInputSource
object to determine how to
read XML input. If there is a character stream available, the
parser will read that stream directly; if not, the parser will use
a byte stream, if available; if neither a character stream nor a
byte stream is available, the parser will attempt to open a URI
connection to the resource identified by the system identifier.
An DOMInputSource
object belongs to the
application: the parser shall never modify it in any way (it may
modify a copy if necessary).
interface DOMInputSource { attribute DOMInputStream byteStream; attribute DOMReader characterStream; attribute DOMString encoding; attribute DOMString publicId; attribute DOMString systemId; };
byteStream
of type
DOMInputStream
characterStream
of type DOMReader
encoding
of type
DOMString
publicId
of type
DOMString
systemId
of type
DOMString
DOMEntityResolver
Provides a way for applications
to redirect references to external entities.
Applications needing to implement customized handling for
external entities must implement this interface and register their
implementation by setting the entityResolver
property
of the DOMBuilder
.
The DOMBuilder
will then allow the application to intercept any external entities
(including the external DTD subset and external parameter entities)
before including them.
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 URI types other than URLs.
DOMEtityResolver
is based on the SAX2
EntityResolver
interface, described at
http://www.megginson.com/SAX/Java/javadoc/org/xml/sax/EntityResolver.html
interface DOMEntityResolver { DOMInputSource resolveEntity(in DOMString publicId, in DOMString systemId ) raises(DOMSystemException); };
resolveEntity
DOMBuilder
will call this method before opening any external entity except the
top-level document entity (including the external DTD subset,
external entities referenced within the DTD, and external entities
referenced within the document element); the application may
request that the DOMBuilder
resolve the entity itself, that it use an alternative URI, or that
it use an entirely different input source.DOMBuilder
must resolve it fully before reporting it to the application
through this interface.
Note: See issue #4. An alternative would be to pass the URL out without resolving it, and to provide a base as an additional parameter. SAX resolves URLs first, and does not provide a base.
publicId
of type
DOMString
systemId
of type
DOMString
A |
|
Any |
DOMBuilderFilter
s provide applications the ability
to examine Element nodes as they are being constructed during a
parse. As each elements 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.
All validity checking while reading 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.
interface DOMBuilderFilter { boolean startElement(in Element element); boolean endElement(in Element element); };
endElement
element
of type
Element
|
return true |
startElement
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.)element
of type
Element
|
return true if this Element should be included in the DOM document being built. Return false if the Element and all of its children should be skipped. |
DOMWriter provides an API for serializing (writing) a DOM document out in the form of a source XML document. The XML data is written to an output stream, the type of which depends on the specific language bindings in use.
Three options are available for the general appearance of the formatted output: As-is, canonical and reformatted.
DOMWriter
accepts any node type for serialization.
For nodes of type Document
or Entity
, well formed XML will be created. The
serialized output for these node types is either as a Document or
an External Entity, respectively, and is acceptable input for an
XML parser. For all other types of nodes the serialized form is not
specified, but should be something useful to a human for debugging
or diagnostic purposes. Note: rigorously designing an external
(source) form for stand-alone node types that don't already have
one defined by the XML rec seems a bit much to take on here.
Within a Document or Entity being serialized, Nodes are processed as follows
DOMWriter.writeNode()
, output a Text Decl and the
entity expansion. The resulting output will be valid as an external
entity.Document
."&entityName;"
) in the output. Child
nodes (the expansion) of the entity reference are ignored.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 < and &. The other predefined entities (>, &apos, etc.) are not used; these characters can be included directly. Any character that can not be represented directly in the output character encoding is serialized as a numeric character reference.
Attributes not containing quotes are serialized in quotes. Attributes containing quotes but no apostrophes are serialized in apostrophes (single quotes). Attributes containing both forms of quotes are serialized in quotes, with quotes within the value represented by the predefined entity ". Any character that can not be represented directly in the output character encoding is 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 an error. An example would be serializing the element <LaCañada/> with the encoding=US-ASCII
Unicode Character Normalization. When requested by setting the
normalize-characters
option on DOMWriter, all data to
be serialized, both markup and character data, is normalized
according to the rules defined by Unicode Canonical Composition,
Normalization Form C. The 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. The W3C character
model and normalization are described at
http://www.w3.org/TR/charmod/#TextNormalization. Unicode
normalization forms are described at http://www.unicode.org/unicode/reports/tr15/
Name space checking and fixup during serialization is a user option. When the option is selected, the serialization process will verify that name space declarations, name space prefixes and the name space URIs associated with Elements and Attributes are consistent. If inconsistencies are found, the serialized form of the document will be altered to remove them. The exact form of the alterations are not defined, and are implementation dependent.
Any changes made affect only the name space prefixes and declarations appearing in the serialized data. The DOM's view of the document is not altered by the serialization operation, and does not reflect any changes made to name space declarations or prefixes in the serialized output.
DOMWriter
s have a number of named properties that
can be queried or set. Here is a list of properties that must be
recognized by all implementations.
interface DOMWriter { attribute DOMString encoding; readonly attribute DOMString lastEncoding; attribute unsigned short format; // Modified in DOM Level 3: attribute DOMString newLine; void writeNode(in DOMOutputStream destination, in Node node) raises(DOMSystemException); };
encoding
of type
DOMString
format
of type
unsigned short
lastEncoding
of type
DOMString
, readonlynewLine
of type
DOMString
, modified in DOM Level
3writeNode
DOMWriter
. Writing a Document or
Entity node produces a serialized form that is well formed XML.
Writing other node types produces a fragment of text in a form that
is not fully defined by this document, but that should be useful to
a human for debugging or diagnostic purposes.
destination
of type
DOMOutputStream
node
of type
Node
Document
or Entity
node to be written. For other node types,
something sensible should be written, but the exact serialized form
is not specified.
|
This exception will be raised in response to any sort of IO or system error that occurs while writing to the destination. It may wrap an underlying system exception. |
A Content Model serialization interface.
DOMCMWriters provides an API for serializing Content Models out in the form of a source Content Model. The Content Model is written to an output stream, the type of which depends on the specific language bindings in use.
DOMCMWriter is a generic Content Model serialization interface.
It can be applied to both an internal Content Model and/or an
external Content Model. DOMCMWriter is applied to serialize a
single Content Model. Serializing a document with an active
Internal Content Model will serialize this internal Content Model
with the document as it is part of the Document (see DOMWriter
).
interface DOMCMWriter : DOMWriter { void writeCMModel(in DOMOutputStream destination, in CMModel model) raises(DOMSystemException); };
writeCMModel
destination
of type
DOMOutputStream
model
of type
CMModel
|
This exception will be raised in response to any sort of IO or system error that occurs while writing to the destination. It may wrap an underlying system exception. |
The DocumentLS interface provides a mechanism by which the content of a document can be replaced with the DOM tree produced when loading a URL, or parsing a string. The expectation is that an instance of the DocumentLS interface can be obtained by using binding-specific casting methods on an instance of the Document interface.
interface DocumentLS { attribute boolean async; void abort(); boolean load(in DOMString url); boolean loadXML(in DOMString source); DOMString saveXML(in Node node) raises(DOMException); };
async
of type
boolean
abort
load()
being invoked the loading
and parsing is immediately aborted. The possibly partial result of
parsing the document is discarded and the document is cleared.
load
ParserErrorEvent
).
url
of type
DOMString
|
If async is set to true load() returns true if the document load
was successfully initiated. If an error occurred when initiating
the document load load() returns false. |
loadXML
source
of type
DOMString
|
True if parsing the input string succeeded without errors, otherwise false. |
saveXML
node
of type
Node
|
The serialized document or node. |
|
DOMException WRONG_DOCUMENT_ERR: Raised if the node passed in as the node parameter is from an other document. |
ParserErrorEvent is the event that is fired if there's an error in the XML document being parsed.
interface ParserErrorEvent { readonly attribute long errorCode; readonly attribute long filepos; readonly attribute long line; readonly attribute long linepos; readonly attribute DOMString reason; readonly attribute DOMString srcText; readonly attribute DOMString url; };
errorCode
of type
long
, readonlyfilepos
of type
long
, readonlyline
of type
long
, readonlylinepos
of type
long
, readonlyreason
of type
DOMString
, readonlysrcText
of type
DOMString
, readonlyurl
of type
DOMString
, readonlyThis appendix contains the complete OMG IDL [OMGIDL] for the Level 3 Document Object Model Abstract Schemas and Load and Save definitions.
The IDL files are also available as: http://www.w3.org/TR/2001/WD-DOM-Level-3-ASLS-20010607/idl.zip
// File: abstract-schemas.idl #ifndef _ABSTRACT-SCHEMAS_IDL_ #define _ABSTRACT-SCHEMAS_IDL_ #include "dom.idl" #pragma prefix "dom.w3c.org" module abstract-schemas { typedef dom::DOMString DOMString; typedef dom::int int; typedef dom::decimal decimal; typedef dom::Node Node; typedef dom::DOMImplementation DOMImplementation; typedef dom::Element Element; typedef dom::CharacterData CharacterData; typedef dom::DocumentType DocumentType; typedef dom::Attr Attr; interface ASModel; interface ASChildren; interface ASAttributeDeclaration; interface DOMErrorHandler; interface DOMLocator; interface ASNode { const unsigned short AS_ELEMENT_DECLARATION = 1; const unsigned short AS_ATTRIBUTE_DECLARATION = 2; const unsigned short AS_NOTATION_DECLARATION = 3; const unsigned short AS_ENTITY_DECLARATION = 4; const unsigned short AS_CHILDREN = 5; const unsigned short AS_MODEL = 6; const unsigned short AS_EXTERNALMODEL = 7; readonly attribute unsigned short cmNodeType; attribute ASModel ownerASModel; attribute DOMString nodeName; attribute DOMString prefix; attribute DOMString localName; attribute DOMString namespaceURI; ASNode cloneASNode(); }; interface ASNodeList { readonly attribute int length; ASNode item(in int index); }; interface ASDOMStringList { readonly attribute int length; DOMString item(in int index); }; interface ASNamedNodeMap { readonly attribute int length; ASNode getNamedItem(inout DOMString name); ASNode getNamedItemNS(in DOMString namespaceURI, inout DOMString localName); ASNode item(in int index); ASNode removeNamedItem(in DOMString name); ASNode removeNamedItemNS(in DOMString namespaceURI, in DOMString localName); ASNode setNamedItem(inout ASNode newASNode) raises(dom::DOMASException); ASNode setNamedItemNS(inout ASNode newASNode) raises(dom::DOMASException); }; interface ASDataType { const short STRING_DATATYPE = 1; short getASPrimitiveType(); }; interface ASPrimitiveType : ASDataType { const short BOOLEAN_DATATYPE = 2; const short FLOAT_DATATYPE = 3; const short DOUBLE_DATATYPE = 4; const short DECIMAL_DATATYPE = 5; const short HEXBINARY_DATATYPE = 6; const short BASE64BINARY_DATATYPE = 7; const short ANYURI_DATATYPE = 8; const short QNAME_DATATYPE = 9; const short DURATION_DATATYPE = 10; const short DATETIME_DATATYPE = 11; const short DATE_DATATYPE = 12; const short TIME_DATATYPE = 13; const short YEARMONTH_DATATYPE = 14; const short YEAR_DATATYPE = 15; const short MONTHDAY_DATATYPE = 16; const short DAY_DATATYPE = 17; const short MONTH_DATATYPE = 18; const short NOTATION_DATATYPE = 19; attribute decimal lowValue; attribute decimal highValue; }; interface ASElementDeclaration : ASNode { const short EMPTY_CONTENTTYPE = 1; const short ANY_CONTENTTYPE = 2; const short MIXED_CONTENTTYPE = 3; const short ELEMENTS_CONTENTTYPE = 4; attribute boolean strictMixedContent; attribute ASDataType elementType; attribute boolean isPCDataOnly; attribute short contentType; attribute DOMString tagName; ASChildren getASChildren(); void setASChildren(inout ASChildren elementContent) raises(dom::DOMASException); ASNamedNodeMap getASAttributeDecls(); void setASAttributeDecls(inout ASNamedNodeMap attributes); void addASAttributeDecl(in ASAttributeDeclaration attributeDecl); ASAttributeDeclaration removeASAttributeDecl(in ASAttributeDeclaration attributeDecl); }; interface ASChildren : ASNode { const unsigned long UNBOUNDED = MAX_LONG; const unsigned short NONE = 0; const unsigned short SEQUENCE = 1; const unsigned short CHOICE = 2; attribute unsigned short listOperator; attribute unsigned long minOccurs; attribute unsigned long maxOccurs; attribute ASNodeList subModels; ASNode removeASNode(in unsigned long nodeIndex); int insertASNode(in unsigned long nodeIndex, in ASNode newNode); int appendASNode(in ASNode newNode); }; interface ASAttributeDeclaration : ASNode { const short NO_VALUE_CONSTRAINT = 0; const short DEFAULT_VALUE_CONSTRAINT = 1; const short FIXED_VALUE_CONSTRAINT = 2; attribute DOMString attrName; attribute ASDataType attrType; attribute DOMString attributeValue; attribute DOMString enumAttr; attribute ASNodeList ownerElement; attribute short constraintType; }; interface ASEntityDeclaration : ASNode { const short INTERNAL_ENTITY = 1; const short EXTERNAL_ENTITY = 2; attribute short entityType; attribute DOMString entityName; attribute DOMString entityValue; attribute DOMString systemId; attribute DOMString publicId; attribute DOMString notationName; }; interface ASNotationDeclaration : ASNode { attribute DOMString notationName; attribute DOMString systemId; attribute DOMString publicId; }; interface Document { void setErrorHandler(in DOMErrorHandler handler); }; interface DocumentAS : Document { attribute boolean continuousValidityChecking; int numASs(); ASModel getInternalAS(); ASNodeList getASs(); ASModel getActiveAS(); void addAS(in ASModel cm); void removeAS(in ASModel cm); boolean activateAS(in ASModel cm); }; interface DOMErrorHandler { void warning(in DOMLocator where, in DOMString how, in DOMString why) raises(dom::DOMSystemException); void fatalError(in DOMLocator where, in DOMString how, in DOMString why) raises(dom::DOMSystemException); void error(in DOMLocator where, in DOMString how, in DOMString why) raises(dom::DOMSystemException); }; interface DOMLocator { int getColumnNumber(); int getLineNumber(); DOMString getPublicID(); DOMString getSystemID(); Node getNode(); }; interface ASModel : ASNode { readonly attribute boolean isNamespaceAware; attribute ASElementDeclaration rootElementDecl; attribute DOMString systemId; attribute DOMString publicId; ASNodeList getASNodes(); boolean removeNode(in ASNode node); boolean insertBefore(in ASNode newNode, in ASNode refNode); boolean validate(); ASElementDeclaration createASElementDeclaration(inout DOMString namespaceURI, in DOMString qualifiedElementName) raises(dom::DOMException); ASAttributeDeclaration createASAttributeDeclaration(inout DOMString namespaceURI, in DOMString qualifiedName) raises(dom::DOMException); ASNotationDeclaration createASNotationDeclaration(inout DOMString namespaceURI, in DOMString qualifiedElementName, in DOMString systemIdentifier, inout DOMString publicIdentifier) raises(dom::DOMException); ASEntityDeclaration createASEntityDeclaration(in DOMString name) raises(dom::DOMException); ASChildren createASChildren(in unsigned long minOccurs, in unsigned long maxOccurs, inout unsigned short operator) raises(dom::DOMException); }; interface ASExternalModel : ASModel { }; interface DOMImplementationAS : DOMImplementation { ASModel createAS(); ASExternalModel createExternalAS(); }; interface NodeAS : Node { const short WF_CHECK = 1; const short NS_WF_CHECK = 2; const short PARTIAL_VALIDITY_CHECK = 3; const short STRICT_VALIDITY_CHECK = 4; attribute short wfValidityCheckLevel; boolean canInsertBefore(in Node newChild, in Node refChild) raises(dom::DOMException); boolean canRemoveChild(in Node oldChild) raises(dom::DOMException); boolean canReplaceChild(in Node newChild, in Node oldChild) raises(dom::DOMException); boolean canAppendChild(in Node newChild) raises(dom::DOMException); boolean isValid(in boolean deep) raises(dom::DOMException); }; interface ElementAS : Element { short contentType(); ASElementDeclaration getElementDeclaration() raises(dom::DOMException); boolean canSetAttribute(in DOMString attrname, in DOMString attrval); boolean canSetAttributeNode(in Node node); boolean canSetAttributeNodeNS(in Node node); boolean canSetAttributeNS(in DOMString attrname, in DOMString attrval, in DOMString namespaceURI, in DOMString localName); boolean canRemoveAttribute(in DOMString attrname); boolean canRemoveAttributeNS(in DOMString attrname, inout DOMString namespaceURI); boolean canRemoveAttributeNode(in Node node); ASDOMStringList getChildElements(); ASDOMStringList getParentElements(); ASDOMStringList getAttributeList(); }; interface CharacterDataAS : CharacterData { boolean isWhitespaceOnly(); boolean canSetData(in unsigned long offset, in DOMString arg) raises(dom::DOMException); boolean canAppendData(in DOMString arg) raises(dom::DOMException); boolean canReplaceData(in unsigned long offset, in unsigned long count, in DOMString arg) raises(dom::DOMException); boolean canInsertData(in unsigned long offset, in DOMString arg) raises(dom::DOMException); boolean canDeleteData(in unsigned long offset, in DOMString arg) raises(dom::DOMException); }; interface DocumentTypeAS : DocumentType { readonly attribute ASDOMStringList definedElementTypes; boolean isElementDefined(in DOMString elemTypeName); boolean isElementDefinedNS(in DOMString elemTypeName, in DOMString namespaceURI, in DOMString localName); boolean isAttributeDefined(in DOMString elemTypeName, in DOMString attrName); boolean isAttributeDefinedNS(in DOMString elemTypeName, in DOMString attrName, in DOMString namespaceURI, in DOMString localName); boolean isEntityDefined(in DOMString entName); }; interface AttributeAS : Attr { ASAttributeDeclaration getAttributeDeclaration(); ASNotationDeclaration getNotation() raises(dom::DOMException); }; }; #endif // _ABSTRACT-SCHEMAS_IDL_
// File: load-save.idl #ifndef _LOAD-SAVE_IDL_ #define _LOAD-SAVE_IDL_ #include "dom.idl" #pragma prefix "dom.w3c.org" module load-save { typedef dom::DOMErrorHandler DOMErrorHandler; typedef dom::DOMString DOMString; typedef dom::Document Document; typedef dom::DOMInputStream DOMInputStream; typedef dom::DOMReader DOMReader; typedef dom::Element Element; typedef dom::DOMOutputStream DOMOutputStream; typedef dom::Node Node; typedef dom::CMModel CMModel; interface DOMBuilder; interface DOMWriter; interface DOMEntityResolver; interface DOMBuilderFilter; interface DOMInputSource; interface DOMImplementationLS { DOMBuilder createDOMBuilder(); DOMWriter createDOMWriter(); }; interface DOMBuilder { attribute DOMEntityResolver entityResolver; attribute DOMErrorHandler errorHandler; attribute DOMBuilderFilter filter; attribute boolean mimeTypeCheck; void setFeature(in DOMString name, in boolean state) raises(dom::DOMException); boolean supportsFeature(in DOMString name); boolean canSetFeature(in DOMString name, in boolean state); boolean getFeature(in DOMString name) raises(dom::DOMException); Document parseURI(in DOMString uri) raises(dom::DOMException, dom::DOMSystemException); Document parseDOMInputSource(in DOMInputSource is) raises(dom::DOMException, dom::DOMSystemException); }; interface DOMInputSource { attribute DOMInputStream byteStream; attribute DOMReader characterStream; attribute DOMString encoding; attribute DOMString publicId; attribute DOMString systemId; }; interface DOMEntityResolver { DOMInputSource resolveEntity(in DOMString publicId, in DOMString systemId ) raises(dom::DOMSystemException); }; interface DOMBuilderFilter { boolean startElement(in Element element); boolean endElement(in Element element); }; interface DOMWriter { attribute DOMString encoding; readonly attribute DOMString lastEncoding; attribute unsigned short format; // Modified in DOM Level 3: attribute DOMString newLine; void writeNode(in DOMOutputStream destination, in Node node) raises(dom::DOMSystemException); }; interface DOMCMWriter : DOMWriter { void writeCMModel(in DOMOutputStream destination, in CMModel model) raises(dom::DOMSystemException); }; interface DocumentLS { attribute boolean async; void abort(); boolean load(in DOMString url); boolean loadXML(in DOMString source); DOMString saveXML(in Node node) raises(dom::DOMException); }; interface ParserErrorEvent { readonly attribute long errorCode; readonly attribute long filepos; readonly attribute long line; readonly attribute long linepos; readonly attribute DOMString reason; readonly attribute DOMString srcText; readonly attribute DOMString url; }; interface DOMCMBuilder : DOMBuilder { CMModel parseCMURI(in DOMString uri) raises(dom::DOMException, dom::DOMSystemException); CMModel parseCMInputSource(in DOMInputSource is) raises(dom::DOMException, dom::DOMSystemException); }; }; #endif // _LOAD-SAVE_IDL_
This appendix contains the complete Java [Java] bindings for the Level 3 Document Object Model Abstract Schemas and Load and Save.
The Java files are also available as http://www.w3.org/TR/2001/WD-DOM-Level-3-ASLS-20010607/java-binding.zip
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMException; public interface ASModel extends ASNode { public boolean getIsNamespaceAware(); public ASElementDeclaration getRootElementDecl(); public void setRootElementDecl(ASElementDeclaration rootElementDecl); public String getSystemId(); public void setSystemId(String systemId); public String getPublicId(); public void setPublicId(String publicId); public ASNodeList getASNodes(); public boolean removeNode(ASNode node); public boolean insertBefore(ASNode newNode, ASNode refNode); public boolean validate(); public ASElementDeclaration createASElementDeclaration(String namespaceURI, String qualifiedElementName) throws DOMException; public ASAttributeDeclaration createASAttributeDeclaration(String namespaceURI, String qualifiedName) throws DOMException; public ASNotationDeclaration createASNotationDeclaration(String namespaceURI, String qualifiedElementName, String systemIdentifier, String publicIdentifier) throws DOMException; public ASEntityDeclaration createASEntityDeclaration(String name) throws DOMException; public ASChildren createASChildren(int minOccurs, int maxOccurs, short operator) throws DOMException; }
package org.w3c.dom.abstractSchemas; public interface ASExternalModel extends ASModel { }
package org.w3c.dom.abstractSchemas; public interface ASNode { public static final short AS_ELEMENT_DECLARATION = 1; public static final short AS_ATTRIBUTE_DECLARATION = 2; public static final short AS_NOTATION_DECLARATION = 3; public static final short AS_ENTITY_DECLARATION = 4; public static final short AS_CHILDREN = 5; public static final short AS_MODEL = 6; public static final short AS_EXTERNALMODEL = 7; public short getCmNodeType(); public ASModel getOwnerASModel(); public void setOwnerASModel(ASModel ownerASModel); public String getNodeName(); public void setNodeName(String nodeName); public String getPrefix(); public void setPrefix(String prefix); public String getLocalName(); public void setLocalName(String localName); public String getNamespaceURI(); public void setNamespaceURI(String namespaceURI); public ASNode cloneASNode(); }
package org.w3c.dom.abstractSchemas; public interface ASNodeList { public int getLength(); public ASNode item(int index); }
package org.w3c.dom.abstractSchemas; public interface ASDOMStringList { public int getLength(); public String item(int index); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMASException; public interface ASNamedNodeMap { public int getLength(); public ASNode getNamedItem(String name); public ASNode getNamedItemNS(String namespaceURI, String localName); public ASNode item(int index); public ASNode removeNamedItem(String name); public ASNode removeNamedItemNS(String namespaceURI, String localName); public ASNode setNamedItem(ASNode newASNode) throws DOMASException; public ASNode setNamedItemNS(ASNode newASNode) throws DOMASException; }
package org.w3c.dom.abstractSchemas; public interface ASDataType { public static final short STRING_DATATYPE = 1; public short getASPrimitiveType(); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.decimal; public interface ASPrimitiveType extends ASDataType { public static final short BOOLEAN_DATATYPE = 2; public static final short FLOAT_DATATYPE = 3; public static final short DOUBLE_DATATYPE = 4; public static final short DECIMAL_DATATYPE = 5; public static final short HEXBINARY_DATATYPE = 6; public static final short BASE64BINARY_DATATYPE = 7; public static final short ANYURI_DATATYPE = 8; public static final short QNAME_DATATYPE = 9; public static final short DURATION_DATATYPE = 10; public static final short DATETIME_DATATYPE = 11; public static final short DATE_DATATYPE = 12; public static final short TIME_DATATYPE = 13; public static final short YEARMONTH_DATATYPE = 14; public static final short YEAR_DATATYPE = 15; public static final short MONTHDAY_DATATYPE = 16; public static final short DAY_DATATYPE = 17; public static final short MONTH_DATATYPE = 18; public static final short NOTATION_DATATYPE = 19; public decimal getLowValue(); public void setLowValue(decimal lowValue); public decimal getHighValue(); public void setHighValue(decimal highValue); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMASException; public interface ASElementDeclaration extends ASNode { public static final short EMPTY_CONTENTTYPE = 1; public static final short ANY_CONTENTTYPE = 2; public static final short MIXED_CONTENTTYPE = 3; public static final short ELEMENTS_CONTENTTYPE = 4; public boolean getStrictMixedContent(); public void setStrictMixedContent(boolean strictMixedContent); public ASDataType getElementType(); public void setElementType(ASDataType elementType); public boolean getIsPCDataOnly(); public void setIsPCDataOnly(boolean isPCDataOnly); public short getContentType(); public void setContentType(short contentType); public String getTagName(); public void setTagName(String tagName); public ASChildren getASChildren(); public void setASChildren(ASChildren elementContent) throws DOMASException; public ASNamedNodeMap getASAttributeDecls(); public void setASAttributeDecls(ASNamedNodeMap attributes); public void addASAttributeDecl(ASAttributeDeclaration attributeDecl); public ASAttributeDeclaration removeASAttributeDecl(ASAttributeDeclaration attributeDecl); }
package org.w3c.dom.abstractSchemas; public interface ASChildren extends ASNode { public static final int UNBOUNDED = MAX_LONG; public static final short NONE = 0; public static final short SEQUENCE = 1; public static final short CHOICE = 2; public short getListOperator(); public void setListOperator(short listOperator); public int getMinOccurs(); public void setMinOccurs(int minOccurs); public int getMaxOccurs(); public void setMaxOccurs(int maxOccurs); public ASNodeList getSubModels(); public void setSubModels(ASNodeList subModels); public ASNode removeASNode(int nodeIndex); public int insertASNode(int nodeIndex, ASNode newNode); public int appendASNode(ASNode newNode); }
package org.w3c.dom.abstractSchemas; public interface ASAttributeDeclaration extends ASNode { public static final short NO_VALUE_CONSTRAINT = 0; public static final short DEFAULT_VALUE_CONSTRAINT = 1; public static final short FIXED_VALUE_CONSTRAINT = 2; public String getAttrName(); public void setAttrName(String attrName); public ASDataType getAttrType(); public void setAttrType(ASDataType attrType); public String getAttributeValue(); public void setAttributeValue(String attributeValue); public String getEnumAttr(); public void setEnumAttr(String enumAttr); public ASNodeList getOwnerElement(); public void setOwnerElement(ASNodeList ownerElement); public short getConstraintType(); public void setConstraintType(short constraintType); }
package org.w3c.dom.abstractSchemas; public interface ASEntityDeclaration extends ASNode { public static final short INTERNAL_ENTITY = 1; public static final short EXTERNAL_ENTITY = 2; public short getEntityType(); public void setEntityType(short entityType); public String getEntityName(); public void setEntityName(String entityName); public String getEntityValue(); public void setEntityValue(String entityValue); public String getSystemId(); public void setSystemId(String systemId); public String getPublicId(); public void setPublicId(String publicId); public String getNotationName(); public void setNotationName(String notationName); }
package org.w3c.dom.abstractSchemas; public interface ASNotationDeclaration extends ASNode { public String getNotationName(); public void setNotationName(String notationName); public String getSystemId(); public void setSystemId(String systemId); public String getPublicId(); public void setPublicId(String publicId); }
package org.w3c.dom.abstractSchemas; public interface Document { public void setErrorHandler(DOMErrorHandler handler); }
package org.w3c.dom.abstractSchemas; public interface DocumentAS extends Document { public boolean getContinuousValidityChecking(); public void setContinuousValidityChecking(boolean continuousValidityChecking); public int numASs(); public ASModel getInternalAS(); public ASNodeList getASs(); public ASModel getActiveAS(); public void addAS(ASModel cm); public void removeAS(ASModel cm); public boolean activateAS(ASModel cm); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMImplementation; public interface DOMImplementationAS extends DOMImplementation { public ASModel createAS(); public ASExternalModel createExternalAS(); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.Node; import org.w3c.dom.DOMException; public interface NodeAS extends Node { public static final short WF_CHECK = 1; public static final short NS_WF_CHECK = 2; public static final short PARTIAL_VALIDITY_CHECK = 3; public static final short STRICT_VALIDITY_CHECK = 4; public short getWfValidityCheckLevel(); public void setWfValidityCheckLevel(short wfValidityCheckLevel); public boolean canInsertBefore(Node newChild, Node refChild) throws DOMException; public boolean canRemoveChild(Node oldChild) throws DOMException; public boolean canReplaceChild(Node newChild, Node oldChild) throws DOMException; public boolean canAppendChild(Node newChild) throws DOMException; public boolean isValid(boolean deep) throws DOMException; }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.DOMException; public interface ElementAS extends Element { public short contentType(); public ASElementDeclaration getElementDeclaration() throws DOMException; public boolean canSetAttribute(String attrname, String attrval); public boolean canSetAttributeNode(Node node); public boolean canSetAttributeNodeNS(Node node); public boolean canSetAttributeNS(String attrname, String attrval, String namespaceURI, String localName); public boolean canRemoveAttribute(String attrname); public boolean canRemoveAttributeNS(String attrname, String namespaceURI); public boolean canRemoveAttributeNode(Node node); public ASDOMStringList getChildElements(); public ASDOMStringList getParentElements(); public ASDOMStringList getAttributeList(); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMException; import org.w3c.dom.CharacterData; public interface CharacterDataAS extends CharacterData { public boolean isWhitespaceOnly(); public boolean canSetData(int offset, String arg) throws DOMException; public boolean canAppendData(String arg) throws DOMException; public boolean canReplaceData(int offset, int count, String arg) throws DOMException; public boolean canInsertData(int offset, String arg) throws DOMException; public boolean canDeleteData(int offset, String arg) throws DOMException; }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DocumentType; public interface DocumentTypeAS extends DocumentType { public ASDOMStringList getDefinedElementTypes(); public boolean isElementDefined(String elemTypeName); public boolean isElementDefinedNS(String elemTypeName, String namespaceURI, String localName); public boolean isAttributeDefined(String elemTypeName, String attrName); public boolean isAttributeDefinedNS(String elemTypeName, String attrName, String namespaceURI, String localName); public boolean isEntityDefined(String entName); }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMException; import org.w3c.dom.Attr; public interface AttributeAS extends Attr { public ASAttributeDeclaration getAttributeDeclaration(); public ASNotationDeclaration getNotation() throws DOMException; }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.DOMSystemException; public interface DOMErrorHandler { public void warning(DOMLocator where, String how, String why) throws DOMSystemException; public void fatalError(DOMLocator where, String how, String why) throws DOMSystemException; public void error(DOMLocator where, String how, String why) throws DOMSystemException; }
package org.w3c.dom.abstractSchemas; import org.w3c.dom.Node; public interface DOMLocator { public int getColumnNumber(); public int getLineNumber(); public String getPublicID(); public String getSystemID(); public Node getNode(); }
package org.w3c.dom.loadSave; public interface DOMImplementationLS { public DOMBuilder createDOMBuilder(); public DOMWriter createDOMWriter(); }
package org.w3c.dom.loadSave; import org.w3c.dom.CMModel; import org.w3c.dom.DOMSystemException; import org.w3c.dom.DOMException; public interface DOMCMBuilder extends DOMBuilder { public CMModel parseCMURI(String uri) throws DOMException, DOMSystemException; public CMModel parseCMInputSource(DOMInputSource is) throws DOMException, DOMSystemException; }
package org.w3c.dom.loadSave; import org.w3c.dom.Document; import org.w3c.dom.DOMSystemException; import org.w3c.dom.DOMException; import org.w3c.dom.DOMErrorHandler; public interface DOMBuilder { public DOMEntityResolver getEntityResolver(); public void setEntityResolver(DOMEntityResolver entityResolver); public DOMErrorHandler getErrorHandler(); public void setErrorHandler(DOMErrorHandler errorHandler); public DOMBuilderFilter getFilter(); public void setFilter(DOMBuilderFilter filter); public boolean getMimeTypeCheck(); public void setMimeTypeCheck(boolean mimeTypeCheck); public void setFeature(String name, boolean state) throws DOMException; public boolean supportsFeature(String name); public boolean canSetFeature(String name, boolean state); public boolean getFeature(String name) throws DOMException; public Document parseURI(String uri) throws DOMException, DOMSystemException; public Document parseDOMInputSource(DOMInputSource is) throws DOMException, DOMSystemException; }
package org.w3c.dom.loadSave; public interface DOMInputSource { public java.io.InputStream getByteStream(); public void setByteStream(java.io.InputStream byteStream); public java.io.Reader getCharacterStream(); public void setCharacterStream(java.io.Reader characterStream); public String getEncoding(); public void setEncoding(String encoding); public String getPublicId(); public void setPublicId(String publicId); public String getSystemId(); public void setSystemId(String systemId); }
package org.w3c.dom.loadSave; import org.w3c.dom.DOMSystemException; public interface DOMEntityResolver { public DOMInputSource resolveEntity(String publicId, String systemId ) throws DOMSystemException; }
package org.w3c.dom.loadSave; import org.w3c.dom.Element; public interface DOMBuilderFilter { public boolean startElement(Element element); public boolean endElement(Element element); }
package org.w3c.dom.loadSave; import org.w3c.dom.Node; import org.w3c.dom.DOMSystemException; public interface DOMWriter { public String getEncoding(); public void setEncoding(String encoding); public String getLastEncoding(); public short getFormat(); public void setFormat(short format); public String getNewLine(); public void setNewLine(String newLine); public void writeNode(java.io.OutputStream destination, Node node) throws DOMSystemException; }
package org.w3c.dom.loadSave; import org.w3c.dom.CMModel; import org.w3c.dom.DOMSystemException; public interface DOMCMWriter extends DOMWriter { public void writeCMModel(java.io.OutputStream destination, CMModel model) throws DOMSystemException; }
package org.w3c.dom.loadSave; import org.w3c.dom.Node; import org.w3c.dom.DOMException; public interface DocumentLS { public boolean getAsync(); public void setAsync(boolean async); public void abort(); public boolean load(String url); public boolean loadXML(String source); public String saveXML(Node node) throws DOMException; }
package org.w3c.dom.loadSave; public interface ParserErrorEvent { public int getErrorCode(); public int getFilepos(); public int getLine(); public int getLinepos(); public String getReason(); public String getSrcText(); public String getUrl(); }
This appendix contains the complete ECMA Script [ECMAScript] binding for the Level 3 Document Object Model Abstract Schemas and Load and Save definitions.
Many people contributed to this specification, including members of the DOM Working Group and the DOM Interest Group. We especially thank the following:
Andrew Watson (Object Management Group), Andy Heninger (IBM), Arnaud Le Hors (W3C and IBM), Ben Chang (Oracle), Bill Smith (Sun), Bill Shea (Merrill Lynch), Bob Sutor (IBM), Chris Lovett (Microsoft), Chris Wilson (Microsoft), David Brownell (Sun), David Singer (IBM), Don Park (invited), Eric Vasilik (Microsoft), Gavin Nicol (INSO), Ian Jacobs (W3C), James Clark (invited), James Davidson (Sun), Jared Sorensen (Novell), Joe Kesselman (IBM), Joe Lapp (webMethods), Joe Marini (Macromedia), Johnny Stenback (Netscape), Jonathan Marsh (Microsoft), Jonathan Robie (Texcel Research and Software AG), Kim Adamson-Sharpe (SoftQuad Software Inc.), Lauren Wood (SoftQuad Software Inc., former chair), Laurence Cable (Sun), Mark Davis (IBM), Mark Scardina (Oracle), Martin Dürst (W3C), Mick Goulish (Software AG), Mike Champion (Arbortext and Software AG), Miles Sabin (Cromwell Media), Patti Lutsky (Arbortext), Paul Grosso (Arbortext), Peter Sharpe (SoftQuad Software Inc.), Phil Karlton (Netscape), Philippe Le Hégaret (W3C, W3C team contact and Chair), Ramesh Lekshmynarayanan (Merrill Lynch), Ray Whitmer (iMall, Excite@Home and Netscape/AOL), Rich Rollman (Microsoft), Rick Gessner (Netscape), Scott Isaacs (Microsoft), Sharon Adler (INSO), Steve Byrne (JavaSoft), Tim Bray (invited), Tom Pixley (Netscape), Vidur Apparao (Netscape), Vinod Anupam (Lucent), Johnny Stenback (Netscape/AOL), Jeroen van Rotterdam (X-Hive Corporation), Rezaur Rahman (Intel), Rob Relyea (Microsoft), Tim Yu (Oracle), Angel Diaz (Oracle), Jon Ferraiolo (Adobe), David Ezell (Hewlett Packard Company), Ashok Malhotra, (IBM and Microsoft), Rick Jelliffe (invited), Elena Litani (IBM), Mary Brady (NIST), Dimitris Dimitriadis (Improve AB).
Thanks to all those who have helped to improve this specification by sending suggestions and corrections (Please, keep bugging us with your issues!).
This specification was written in XML. The HTML, OMG IDL, Java and ECMA Script bindings were all produced automatically.
Thanks to Joe English, author of cost, which was used as the basis for producing DOM Level 1. Thanks also to Gavin Nicol, who wrote the scripts which run on top of cost. Arnaud Le Hors and Philippe Le Hégaret maintained the scripts.
After DOM Level 1, we used Xerces as the basis DOM implementation and wish to thank the authors. Philippe Le Hégaret and Arnaud Le Hors wrote the Java programs which are the DOM application.
Thanks also to Jan Kärrman, author of html2ps, which we use in creating the PostScript version of the specification.
Several of the following term definitions have been borrowed or modified from similar definitions in other W3C or standards documents. See the links within the definitions for more information.
For the latest version of any W3C specification please consult the list of W3C Technical Reports available at http://www.w3.org/TR.