07 June 2001

1. Abstract Schemas

Editors
Ben Chang, Oracle
Joe Kesselman, IBM
Rezaur Rahman, Intel Corporation

Table of contents

1.1. Overview

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.

1.1.1. General Characteristics

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.

1.1.2. Use Cases and Requirements

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:

  1. CU1. Associating an abstract schema (external and/or internal) with a document, or changing the current association.
  2. CU2. Using the same external abstract schema with several documents, without having to reload it.

Requirements:

  1. CR1. Validate against the abstract schema.
  2. CR2. Retrieve information from abstract schema.
  3. CR3. Load an existing abstract schema, perhaps independently from a document.
  4. CR4. Being able to determine if a document has an abstract schema associated with it.
  5. CR5. Associate an AS with a document and make it the active AS.

Specific to the AS-editing world, the following are use cases and requirements and could be labeled as the "AS-editing" section:

Use Cases:

  1. ASU1. Clone/map all or parts of an existing abstract schema to a new or existing abstract schema.
  2. ASU2. Save an abstract schema in a separate file. For example, if a DTD can be broken up into reusable pieces, which are then brought in via entity references, these can then be saved in a separate file. Note that the external subset of a DTD, which includes both an internal and external subset, is a special case of dividing an abstract schema into entities.
  3. ASU3. Modify an existing abstract schema.
  4. ASU4. Create a new abstract schema.
  5. ASU5. Partial abstract schema checking. For example, the document need only be validated against a selected portion of the abstract schema.

Requirements:

  1. ASR1. View and modify all parts of the abstract schema.
  2. ASR2. Validate the abstract schema itself.
  3. ASR3. Serialize the abstract schema.
  4. ASR4. Clone all or parts of an existing abstract schema.
  5. ASR5. Create a new abstract schema object.
  6. ASR6. Validate portions of the XML document against the abstract schema.

Specific to the document-editing world, the following are use cases and requirements and could be labeled as the "Document-editing" section:

Use Cases:

  1. DU1. For editing documents with an associated abstract schema, provide the guidance necessary so that valid documents can be modified and remain valid.
  2. DU2. For editing documents with an associated abstract schema, provide the guidance necessary to transform an invalid document into a valid one.

Requirements:

  1. DR1. Be able to determine if the document is well-formed, and if not, be given enough guidance to locate the error.
  2. DR2. Be able to determine if the document is namespace well-formed, and if not, be given enough guidance to locate the error.
  3. DR3. Be able to determine if the document is valid with respect to its associated abstract schema, and if not, give enough guidance to locate the error.
  4. DR4. Be able to determine if specific modifications to a document would make it become invalid.
  5. DR5. Retrieve information from all abstract schemas. One example might be getting a list of all the defined element names for document editing purposes.

General Issues:

  1. I1. Some concerns exist regarding whether a single abstract Abstract Schema structure can successfully represent both namespace-unaware, e.g., DTD, and namespace-aware, e.g., XML Schema, models of document's content. For example, when you ask what elements can be inserted in a specific place, the former will report the element's 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.
  2. I2. An XML document may be associated with multiple ASs. We have decided that only one of these is "active" (for validation and guidance) at a time. DOM applications may switch which AS is active, remove ASs that are no longer relevant, or add ASs to the list. If it becomes necessary to simultaneously consult more than one AS, it should be possible to write a "union" AS which provides that capability within this framework.
  3. I3. Round-trippability for include/ignore statements and other constructs such as parameter entities, e.g., "macro-like" constructs, will not be supported since no data representation exists to support these constructs without having to re-parse them.
  4. I4. Basic interface for a common error handler for both AS and Load/Save. Agreement has been to utilize user-registered callbacks but other details to be worked out.

1.2. Abstract Schema and AS-Editing Interfaces

A list of the proposed Abstract Schema data structures and functions follow, starting off with the data structures and "AS-editing" methods.

Interface ASModel

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 ASExternalModels 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.


IDL Definition
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);
};

Attributes
isNamespaceAware of type boolean, readonly
True if this abstract schema defines the document structure in terms of namespaces and local names; false if the document structure is defined only in terms of QNames.
publicId of type DOMString
Public id of the source of this ASModel.
rootElementDecl of type ASElementDeclaration
The root element declaration for the abstract schema. Although a root element is specified in the document instance, when an abstract schema is generated, a user should be able to chose the root element for editing purposes. This is just a placeholder for that element. It could also be null. For validating an XML document, the root element must be defined in its active abstract schema. ASModel.rootElementDecl provides access to that root element declaration. This recommendation does not say how to fill in the rootElementdecl. It could be manually done by the user before validating a document, in some cases where possible, the ASModel loader may be able to fill it in etc.
systemId of type DOMString
System id of the source of this ASModel.
Methods
createASAttributeDeclaration
Creates an attribute declaration. The returned object implements ASAttributeDeclaration interface.
Parameters
namespaceURI of type DOMString

qualifiedName of type DOMString
The name of the attribute being declared.
Return Value

ASAttributeDeclaration

A new ASAttributeDeclaration object with attributeName attribute set to input qualifiedname parameter.

Exceptions

DOMException

INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createASChildren
Creates a new ASChildren object. The subModels of the ASChildren is built using ASChildren interface methods.
Parameters
minOccurs of type unsigned long
The minimum occurance for the subModels of this ASChildren.
maxOccurs of type unsigned long
The maximum occurance for the subModels of this ASChildren.
operator of type unsigned short
operator of type CHOICE, SEQ or NONE
Return Value

ASChildren

A new ASChildren object.

Exceptions

DOMException

INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createASElementDeclaration
Creates an element declaration for the element type specified. The returned object implements ASElementDeclaration interface.
Parameters
namespaceURI of type DOMString

qualifiedElementName of type DOMString
The qualified name of the element type being declared.
Return Value

ASElementDeclaration

A new ASElementDeclaration object with name attribute set to qualifiedElementName and the contentType set to contentSpec. Other attributes of the element declaration are set through ASElementDeclaration interface methods.

Exceptions

DOMException

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
Creates a new entity declaration. The returned object implements ASEntityDeclaration interface.
Parameters
name of type DOMString
The name of the entity being declared.
Return Value

ASEntityDeclaration

A new ASNotationDeclaration object with entityName attribute set to name.

Exceptions

DOMException

INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.

createASNotationDeclaration
Creates a new notation declaration. The returned object implements ASNotationDeclaration interface.
Parameters
namespaceURI of type DOMString
The namespace uri of the Notation being declared.
qualifiedElementName of type DOMString
The qualified name of the Notation being declared.
systemIdentifier of type DOMString
The system identifier for the notation declaration.
publicIdentifier of type DOMString
The public identifier for the notation declaraiton.
Return Value

ASNotationDeclaration

A new ASNotationDeclaration object with notationName attribute set to name.

Exceptions

DOMException

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
Returns ASNode list of all the constituent nodes in the abstract schema.
Return Value

ASNodeList

List of all ASNodes of the abstract schema.

No Parameters
No Exceptions
insertBefore
Insert the new 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.
Parameters
newNode of type ASNode
ASNode to be inserted.
refNode of type ASNode
ASNode to be inserted before.
Return Value

boolean

success or failure. If a refNode is specified (non null) and it is not in the list maintained by the ASModel, this method returns failure. If the newNode is null or already exists in the list maintained by the model, it does not change the list but returns success.

No Exceptions
removeNode
Removes the specifiedASNode.
Parameters
node of type ASNode
ASNode to be removed.
Return Value

boolean

Retruns failure if the node is not found. Otherwise returns success.

No Exceptions
validate
Determines if an ASModel and ASExternalModel itself is valid, i.e., confirming that it's well-formed and valid per its own formal grammar. Note that within an ASModel, a pointer to an ASExternalModel can exist.
Return Value

boolean

Is the AS valid?

No Parameters
No Exceptions
Interface ASExternalModel

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.


IDL Definition
interface ASExternalModel : ASModel {
};

Interface ASNode

ASNodeis 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.


IDL Definition
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();
};

Constant AS_ELEMENT_DECLARATION
The node is an ASElementDeclaration.
Constant AS_ATTRIBUTE_DECLARATION
The node is an ASAttributeDeclaration.
Constant AS_NOTATION_DECLARATION
The node is a ASNotationDeclaration.
Constant AS_ENTITY_DECLARATION
The node is an ASEntityDeclaration.
Constant AS_CHILDREN
The node is a ASChildren.
Constant AS_MODEL
The node is a ASModel.
Constant AS_EXTERNALMODEL
The node is a ASExternalModel.
Attributes
cmNodeType of type unsigned short, readonly
A code representing the underlying object as defined above.
localName of type DOMString
Returns the local part of the qualified name of this ASNode.
namespaceURI of type DOMString
The namespace URI of this node, or null if it is unspecified.
nodeName of type DOMString
The qualified name of this ASNode depending on the ASNode type.
ownerASModel of type ASModel
The ASModel object associated with this ASNode. For a node of type AS_MODEL, this is null.
prefix of type DOMString
The namespace prefix of this node, or null if it is unspecified.
Methods
cloneASNode
Creates a copy of this ASNode.
Return Value

ASNode

Cloned ASNode.

No Parameters
No Exceptions
Interface ASNodeList

ASNodeList is the AS analogue to NodeList; the document order is meaningful, as opposed to ASNamedNodeMap. ASNodeList objects in the DOM AS are live.


IDL Definition
interface ASNodeList {
  readonly attribute int              length;
  ASNode             item(in int index);
};

Attributes
length of type int, readonly
The number of ASNodes in the ASNodeList. The range of valid child node indices is 0 to length-1 inclusive.
Methods
item
Returns the indexth 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.
Parameters
index of type int
The position in the collection from which the item is to be retrieved.
Return Value

ASNode

The ASNode at the indexth position in the ASNodeList, or null if that is not a valid index.

No Exceptions
Interface ASDOMStringList

ASDOMStringList represents a collection of DOMStrings.


IDL Definition
interface ASDOMStringList {
  readonly attribute int              length;
  DOMString          item(in int index);
};

Attributes
length of type int, readonly
The number of DOMStrings in the ASDOMStringList. The range of valid child node indices is 0 to length-1 inclusive.
Methods
item
Returns the indexth 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.
Parameters
index of type int
The position in the collection from which the item is to be retrieved.
Return Value

DOMString

The DOMString at the indexth position in the ASDOMStringList, or null if that is not a valid index.

No Exceptions
Interface ASNamedNodeMap

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.


IDL Definition
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);
};

Attributes
length of type int, readonly
The number of ASNodes in the ASNodeList. The range of valid child node indices is 0 to length-1 inclusive.
Methods
getNamedItem
Retrieves a ASNode specified by name.
Parameters
name of type DOMString
The nodeName of an ASNode to retrieve.
Return Value

ASNode

A ASNode with specified node name and null if the map does not contain an element with the given name.

No Exceptions
getNamedItemNS
Retrieves an ASNode specified by local name and namespace URI.
Parameters
namespaceURI of type DOMString
The namespace URI of the ASNode to retrieve.
localName of type DOMString
The local name of the ASNode to retrieve.
Return Value

ASNode

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.

No Exceptions
item
Returns the indexth 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.
Parameters
index of type int
The position in the map from which the item is to be retrieved.
Return Value

ASNode

The ASNode at the indexth position in the ASNamedNodeMap, or null if that is not a valid index.

No Exceptions
removeNamedItem
Removes an ASNode specified by a nodeName.
Parameters
name of type DOMString
The nodeName of the ASNode to be removed.
Return Value

ASNode

The ASNode removed from this map if an ASNode with such a name exists.

No Exceptions
removeNamedItemNS
Removes an ASNode specified by a namespace URI and a local name.
Parameters
namespaceURI of type DOMString
The namespace URI of the ASNode to be removed.
localName of type DOMString
The local name of the ASNode to remove.
Return Value

ASNode

The ASNode removed from this map if an ASNode with such a local name and namespace URI exists.

No Exceptions
setNamedItem
Adds an ASNode using its nodeName attribute. If an ASNode with that name is already present in this map, it is replaced by the new one.
Parameters
newASNode of type ASNode
The ASNode to be inserted in the map with its nodeName as the key.
Return Value

ASNode

If the new node replaces an existing one, the replaced node is returned, otherwise null.

Exceptions

DOMASException

setNamedItemNS
Adds an ASNode using its 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.
Parameters
newASNode of type ASNode
The ASNode to be inserted in the map.The ASNode will later be accessible using the value of its namespaceURI and localName attributes.
Return Value

ASNode

If the new node replaces an existing one, the replaced node is returned, otherwise null.

Exceptions

DOMASException

Interface ASDataType

The only primitive datatype supported by base DOM AS implementation is string type.


IDL Definition
interface ASDataType {
  const short               STRING_DATATYPE                = 1;
  short              getASPrimitiveType();
};

Constant STRING_DATATYPE
code representing the string data type as defined in XML Schema Datatypes.
Methods
getASPrimitiveType
Returns one of the enumerated codes representing the primitive data type.
Return Value

short

code representing the primitive type of the attached data item.

No Parameters
No Exceptions
Interface ASPrimitiveType

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


IDL Definition
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;
};

Constant BOOLEAN_DATATYPE
code representing the boolean data type as defined in XML Schema Datatypes.
Constant FLOAT_DATATYPE
code representing the float data type as defined in XML Schema Datatypes.
Constant DOUBLE_DATATYPE
code representing the double data type as defined in XML Schema Datatypes.
Constant DECIMAL_DATATYPE
code representing a decimal data type as defined in XML Schema Datatypes.
Constant HEXBINARY_DATATYPE
code representing a hexbinary data type as defined in XML Schema Datatypes.
Constant BASE64BINARY_DATATYPE
code representing a base64binary data type as defined in XML Schema Datatypes.
Constant ANYURI_DATATYPE
code representing an uri reference data type as defined in XML Schema Datatypes.

Note: @@uriReference is no longer part of the XML Schema PR draft.

Constant QNAME_DATATYPE
code representing an XML qualified name data type as defined in XML Schema Datatypes.
Constant DURATION_DATATYPE
code representing a duration data type as defined in XML Schema Datatypes.
Constant DATETIME_DATATYPE
code representing adatetime data type as defined in XML Schema Datatypes.
Constant DATE_DATATYPE
code representing adate data type as defined in XML Schema Datatypes.
Constant TIME_DATATYPE
code representing a time data type as defined in XML Schema Datatypes.
Constant YEARMONTH_DATATYPE
code representing a yearmonth data type as defined in XML Schema Datatypes.
Constant YEAR_DATATYPE
code representing a year data type as defined in XML Schema Datatypes.
Constant MONTHDAY_DATATYPE
code representing a monthday data type as defined in XML Schema Datatypes.
Constant DAY_DATATYPE
code representing a day data type as defined in XML Schema Datatypes.
Constant MONTH_DATATYPE
code representing a month data type as defined in XML Schema Datatypes.
Constant NOTATION_DATATYPE
code representing aNOTATIONdata type as defined in XML Schema Datatypes.
Attributes
highValue of type decimal
The high value for a primitive DECIMAL_DATATYPE in the value range.
lowValue of type decimal
The low value for a primitive DECIMAL_DATATYPE in the value range.
Interface ASElementDeclaration

The element name along with the content specification in the context of an ASNode.


IDL Definition
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);
};

Constant EMPTY_CONTENTTYPE
Represents an EMPTY content type for an Element declaration.
Constant ANY_CONTENTTYPE
Represents an ANY content type for an Element declaration.
Constant MIXED_CONTENTTYPE
Represents a MIXED content type for an Element declaration.
Constant ELEMENTS_CONTENTTYPE
Represents an ELEMENTS only content type for an Element declaration.
Attributes
contentType of type short
The content type of the element. One of EMPTY_CONTENTYPE, ANY_CONTENTTYPE, MIXED_CONTENTTYPE, ELEMENTS_CONTENTTYPE.
elementType of type ASDataType
Datatype of the element.
isPCDataOnly of type boolean
Boolean defining whether the element type contains child elements and PCDATA or PCDATA only for mixed element types. True if the element is of type PCDATA only. Relevant only for mixed content type elements.
strictMixedContent of type boolean
A boolean defining whether the element order and number of the child elements for mixed content type has to be respected or not. For example XML Schema defined mixed content types the order is important and needs to be respected whether for DTD based AS the order and number of child elements are not important.
tagName of type DOMString
tagName of the element being declared.
Methods
addASAttributeDecl
Adds an ASAttributeDeclaration for the element being declared.
Parameters
attributeDecl of type ASAttributeDeclaration
The new attribute to add. If the attribute declaration already exists for the element, the call does not have any effect.
No Return Value
No Exceptions
getASAttributeDecls
Returns a ASNamedNodeMap containing ASAttributeDeclarations for all the attributes that can appear on this type of element.
Return Value

ASNamedNodeMap

Attributes list for this ASNode.

No Parameters
No Exceptions
getASChildren
Gets content model of element.
Return Value

ASChildren

Content model of this element.

No Parameters
No Exceptions
removeASAttributeDecl
Removes an ASAttributeDeclaration from the element being declared.
Parameters
attributeDecl of type ASAttributeDeclaration
The attribute declaraiton to be removed. If the attribute declaration does not exist for the element, the call does not have any effect.
Return Value

ASAttributeDeclaration

null if the attribute does not exist. Otherwise returns the attribute being removed.

No Exceptions
setASAttributeDecls
Adds an ASNamedNodeMap containing ASAttributeDeclarations for all the attributes that can appear on this type of element.
Parameters
attributes of type ASNamedNodeMap
The attribute collection to set the attributes to.
No Return Value
No Exceptions
setASChildren
Sets content model of an element.
Parameters
elementContent of type ASChildren
The content model for this element declaration.
Exceptions

DOMASException

Raises exception AS_NO_CHILD_ALLOWED_ERR if the element is defined to be of EMPTY_CONTENTTYPE.

No Return Value
Interface ASChildren

The content model of a declared element.


IDL Definition
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);
};

Constant UNBOUNDED
Signifies unbounded upper limit. The MAX_LONG value is the maximum value of an unsigned long integer for a given language binding.
Constant NONE
No operators defined on the subModels. This is usually the case where the subModels contain a single element declaration.
Constant SEQUENCE
This constant value signifies a sequence operator ",".
Constant CHOICE
This constant value signifies a choice operator "|".
Attributes
listOperator of type unsigned short
One of CHOICE or SEQUENCE. The operator is applied to all the components(ASNodes) in the the 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
maximum occurrence for this content particle. Valid values are from 0 to UNBOUNDED.
minOccurs of type unsigned long
min occurrence for this content particle. Valid values are from 0 to UNBOUNDED.
subModels of type ASNodeList
Additional ASNodes in which the element can be defined.
Methods
appendASNode
Appends a new node to the end of the list representing thesubModels.
Parameters
newNode of type ASNode
The new node to be appended.
Return Value

int

the length of the subModels.

No Exceptions
insertASNode
Inserts a new node at a position in the submodel referred to by the nodeIndex. Nodes that already exisit in the list is moved as needed.
Parameters
nodeIndex of type unsigned long
The position of where the newNode is inserted.
newNode of type ASNode
The new node to be inserted.
Return Value

int

The index value at which it is inserted. If the nodeIndex is outside the bound of the subModels list, the item is inserted at the back of the list.

No Exceptions
removeASNode
Removes the ASNode at the indicated index position in the submodel.
Parameters
nodeIndex of type unsigned long
Index of the node being removed.
Return Value

ASNode

The node removed is returned as a result of this method call. The method returns null if the index is outside the bounds of the subModels list.

No Exceptions
Interface ASAttributeDeclaration

An attribute declaration in the context of a ASNode.


IDL Definition
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;
};

Constant NO_VALUE_CONSTRAINT
Describes that the attribute does not have any value constraint.
Constant DEFAULT_VALUE_CONSTRAINT
Indicates that the there is a default value constraint.
Constant FIXED_VALUE_CONSTRAINT
Indicates that there is a fixed value constraint for this attribute.
Attributes
attrName of type DOMString
Name of the attribute.
attrType of type ASDataType
Datatype of the attribute.
attributeValue of type DOMString
Default value.
constraintType of type short
Constraint type if any for this attribute.
enumAttr of type DOMString
Enumeration of attribute.
ownerElement of type ASNodeList
Owner element ASNode of attribute.
Interface ASEntityDeclaration

Models a general entity declaration in an abstract schema.

(ED: The abstract schema does not handle any parameter entity. It is assumed that the parameter entiites are expanded by the implementation as the abstract schema is built.)

IDL Definition
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;
};

Constant INTERNAL_ENTITY
constant defining an internal entity.
Constant EXTERNAL_ENTITY
constant defining an external entity.
Attributes
entityName of type DOMString
The name of the declared general entity.
entityType of type short
One of the INTERNAL_ENTITY or EXTERNAL_ENTITY.
entityValue of type DOMString
The replacement text for the internal entity. The entity references within the replacement text are kept intact. For an entity of type EXTERNAL_ENTITY this is null.
notationName of type DOMString
For unparsed entities, the name of the notation declaration for the entity. For parsed entities, this is null.
publicId of type DOMString
The public identifier associated with the entity, if specified. If the public identifier was not specified, this is null.
systemId of type DOMString
The system identifier associated with the entity, if specified. If the system identifier was not specified, this is null.
Interface ASNotationDeclaration

This interface represents a notation declaration.


IDL Definition
interface ASNotationDeclaration : ASNode {
           attribute DOMString        notationName;
           attribute DOMString        systemId;
           attribute DOMString        publicId;
};

Attributes
notationName of type DOMString
The name of this notation declaration.
publicId of type DOMString
The string representing the public identifier for this notation declaration.
systemId of type DOMString
the URI representing the system identifier for the notation declaration, if present, null otherwise.

1.3. Validation and Other Interfaces

This section contains "Validation and Other" methods common to both the document-editing and AS-editing worlds (includes Document, DOMImplementation, and DOMErrorHandler methods).

Interface Document

The setErrorHandler method is off of the Document interface.


IDL Definition
interface Document {
  void               setErrorHandler(in DOMErrorHandler handler);
};

Methods
setErrorHandler
Allow an application to register an error event handler.
Parameters
handler of type DOMErrorHandler
The error handler
No Return Value
No Exceptions
Interface DocumentAS

This interface extends the Document interface with additional methods for both document and AS editing.


IDL Definition
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);
};

Attributes
continuousValidityChecking of type boolean
An attribute specifying whether continuous checking for the validity of the document is enforced or not. When set to true the implementation is free to raise the VALIDATION_ERR exception on DOM operations that would make the document invalid with respect to "partial validity". This attribute is false by default.
(ED: Add VALIDATION_ERR code to the list of constants in DOMException.)
Methods
activateAS
Make the given 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.
Parameters
cm of type ASModel
AS to be active for the document. The ASModel points to a list of ASExternalModels; with this call, only the specified AS will be active.
Return Value

boolean

True if the ASModel has already been associated with the document using addAS(); false if not.

No Exceptions
addAS
Associate a ASModel with a document. Can be invoked multiple times to result in a list of ASExternalModels. Note that only one internal ASModel is associated with the document, however, and that only one of the possible list of ASExternalModels is active at any one time.
Parameters
cm of type ASModel
AS to be associated with the document.
No Return Value
No Exceptions
getASs
Returns the list of ASNodes of type AS_EXTERNAL_MODELs associated with the document. The addAS method associates a model with a document.
Return Value

ASNodeList

A list of ASExternalModels associated with a document.

No Parameters
No Exceptions
getActiveAS
Find the active ASExternalModel for a document.
Return Value

ASModel

ASModel with a pointer to the active ASExternalModel of document.

No Parameters
No Exceptions
getInternalAS
Find the sole internal ASModel of a document. Only one internal ASModel may be associated with the document.
Return Value
No Parameters
No Exceptions
numASs
Determines the number of ASExternalModels associated with the document. Only one ASModel can be associated with the document, but it may point to a list of ASExternalModels.
Return Value

int

Non-negative number of external AS objects.

No Parameters
No Exceptions
removeAS
Removes a ASExternalModel associated with a document. Can be invoked multiple times to remove a number of these in the list of ASExternalModels.
Parameters
cm of type ASModel
AS to be removed.
No Return Value
No Exceptions
Interface DOMImplementationAS

This interface extends the DOMImplementation interface with additional methods.


IDL Definition
interface DOMImplementationAS : DOMImplementation {
  ASModel            createAS();
  ASExternalModel    createExternalAS();
};

Methods
createAS
Creates an ASModel.
Return Value

ASModel

A NULL return indicates failure.

No Parameters
No Exceptions
createExternalAS
Creates an ASExternalModel.
Return Value

ASExternalModel

A NULL return indicates failure.

No Parameters
No Exceptions

1.4. Document-Editing Interfaces

This section contains "Document-editing" methods (includes Node, Element, Text and Document methods).

Interface NodeAS

This interface extends the Node interface with additional methods for guided document editing.


IDL Definition
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);
};

Constant WF_CHECK
Check for well-formedness of this node.
Constant NS_WF_CHECK
Check for namespace well-formedness includes WF_CHECK.
Constant PARTIAL_VALIDITY_CHECK
Checks for whether this node is partially valid. It includes NS_WF_CHECK.
Definition: A node in a DOM tree is partially valid if it is well formed (this part is for comments and PIs) and its immediate children are those expected by the content model. The node may be missing trailing required children yet still be considered partially valid.
Constant STRICT_VALIDITY_CHECK
Checks for strict validity of the node with respect to active AS which by definition includes NS_WF_CHECK.
Attributes
wfValidityCheckLevel of type short
This attribute defines the level at which the validity and welformedness testing is done by the isValid method. Default value for this attribute is STRICT_VALIDITY_CHECK
Methods
canAppendChild
Has the same arguments as AppendChild.
Parameters
newChild of type Node
Node to be appended.
Return Value

boolean

A boolean that is true if the Node::AppendChild operation is allowed.

Exceptions

DOMException

DOMException.

canInsertBefore
Determines whether the Node::InsertBefore operation would make this document invalid with respect to the currently active AS. ISSUE: Describe "valid" when referring to partially completed documents.
Parameters
newChild of type Node
Node to be inserted.
refChild of type Node
Reference Node.
Return Value

boolean

A boolean that is true if the Node::InsertBefore operation is allowed.

Exceptions

DOMException

DOMException.

canRemoveChild
Has the same arguments as RemoveChild.
Parameters
oldChild of type Node
Node to be removed.
Return Value

boolean

A boolean that is true if the Node::RemoveChild operation is allowed.

Exceptions

DOMException

DOMException.

canReplaceChild
Has the same arguments as ReplaceChild.
Parameters
newChild of type Node
New Node.
oldChild of type Node
Node to be replaced.
Return Value

boolean

A boolean that is true if the Node::ReplaceChild operation is allowed.

Exceptions

DOMException

DOMException.

isValid
Determines if the associated Node is valid relative to currently active AS.
Parameters
deep of type boolean
For the Element type node, setting the 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 .
Return Value

boolean

true if the node is valid/well-formed in the current context and check level defined by wfValidityCheckLevel, false if not.

Exceptions

DOMException

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.

Interface ElementAS

This interface extends the Element interface with additional methods for guided document editing. An object implmenting this interface must also implement NodeAS interface.


IDL Definition
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();
};

Methods
canRemoveAttribute
Verifies if an attribute by the given name can be removed.
Parameters
attrname of type DOMString
Name of attribute.
Return Value

boolean

true or false.

No Exceptions
canRemoveAttributeNS
Verifies if an attribute by the given name and namespace can be removed.
Parameters
attrname of type DOMString
Qualified name of the attribute to be removed.
namespaceURI of type DOMString
The namespace URI of the attribute to remove.
Return Value

boolean

true or false.

No Exceptions
canRemoveAttributeNode
Determines if an attribute node can be removed.
Parameters
node of type Node
The Attr node to remove from the attribute list.
Return Value

boolean

true or false.

No Exceptions
canSetAttribute
Determines if the value for specified attribute can be set.
Parameters
attrname of type DOMString
Name of attribute.
attrval of type DOMString
Value to be assigned to the attribute.
Return Value

boolean

true or false.

No Exceptions
canSetAttributeNS
Determines if the attribute with given namespace and local name can be created if not already present in the attribute list of the element. If the attribute with same local name and namespaceURI is already present in the elements attribute list it sets the value of the attribute and its prefix to the new value. See DOM core setAttributeNS.
Parameters
attrname of type DOMString
Name of attribute.
attrval of type DOMString
Value to be assigned to the attribute.
namespaceURI of type DOMString
namespaceURI of namespace.
localName of type DOMString
localName of namespace.
Return Value

boolean

Success or failure.

No Exceptions
canSetAttributeNode
Determines if an attribute node can be added.
Parameters
node of type Node
Node in which the attribute can possibly be set.
Return Value

boolean

Success or failure.

No Exceptions
canSetAttributeNodeNS
Determines if the attribute node with the given namespace can be added.
Parameters
node of type Node
The Attr to be added to the attribute list.
Return Value

boolean

Success or failure.

No Exceptions
contentType
Determines element content type.
Return Value

short

Constant for mixed, empty, any, etc.

No Parameters
No Exceptions
getAttributeList
Returns an ASDOMStringList containing all the possible Attrs that can appear with this type of element.
Return Value

ASDOMStringList

List of possible attributes of this element.

No Parameters
No Exceptions
getChildElements
Returns an ASDOMStringList containing the possible Element names that can appear as children of this type of element.
Return Value

ASDOMStringList

List of possible children element types of this element.

No Parameters
No Exceptions
getElementDeclaration
gets the AS editing object describing this element
Return Value

ASElementDeclaration

ASElementDeclaration object if the implementation supports AS-EDIT feature. Otherwise null.

Exceptions

DOMException

If no abstract schema is present, raises this exception

No Parameters
getParentElements
Returns an ASDOMStringList containing the possible Element names that can appear as a parent of this type of element.
Return Value

ASDOMStringList

List of possible parent element types of this element.

No Parameters
No Exceptions
Interface CharacterDataAS

This interface extends the CharacterData interface with additional methods for document editing. An object implmenting this interface must also implement NodeAS interface.


IDL Definition
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);
};

Methods
canAppendData
Determines if data can be appended.
Parameters
arg of type DOMString
Argument to be appended.
Return Value

boolean

Success or failure.

Exceptions

DOMException

DOMException.

canDeleteData
Determines if data can be deleted.
Parameters
offset of type unsigned long
Offset.
arg of type DOMString
Argument to be set.
Return Value

boolean

Success or failure.

Exceptions

DOMException

DOMException.

canInsertData
Determines if data can be inserted.
Parameters
offset of type unsigned long
Offset.
arg of type DOMString
Argument to be set.
Return Value

boolean

Success or failure.

Exceptions

DOMException

DOMException.

canReplaceData
Determines if data can be replaced.
Parameters
offset of type unsigned long
Offset.
count of type unsigned long
Replacement.
arg of type DOMString
Argument to be set.
Return Value

boolean

Success or failure.

Exceptions

DOMException

DOMException.

canSetData
Determines if data can be set.
Parameters
offset of type unsigned long
Offset.
arg of type DOMString
Argument to be set.
Return Value

boolean

Success or failure.

Exceptions

DOMException

DOMException.

isWhitespaceOnly
Determines if content is only whitespace.
Return Value

boolean

True if content only whitespace; false for non-whitespace if it is a text node in element content.

No Parameters
No Exceptions
Interface DocumentTypeAS

This interface extends the DocumentType interface with additional methods for document editing. An object implmenting this interface must also implement NodeAS interface.


IDL Definition
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);
};

Attributes
definedElementTypes of type ASDOMStringList, readonly
The list of qualified element names defined in the abstract schema.
Methods
isAttributeDefined
Determines if this attribute is defined for this element in the currently active AS.
Parameters
elemTypeName of type DOMString
Name of the element.
attrName of type DOMString
Name of the attribute.
Return Value

boolean

A boolean that is true if the attribute is defined, false otherwise.

No Exceptions
isAttributeDefinedNS
Determines if an attribute in this namespace is defined in the currently active AS.
Parameters
elemTypeName of type DOMString
Name of element.
attrName of type DOMString
Name of attribute.
namespaceURI of type DOMString
namespaceURI of namespace.
localName of type DOMString
localName of namespace.
Return Value

boolean

A boolean that is true if the attribute with is defined, false otherwise.

No Exceptions
isElementDefined
Determines if this element is defined in the currently active AS.
Parameters
elemTypeName of type DOMString
Name of element.
Return Value

boolean

A boolean that is true if the element is defined, false otherwise.

No Exceptions
isElementDefinedNS
Determines if this element in this namespace is defined in the currently active AS.
Parameters
elemTypeName of type DOMString
Name of element.
namespaceURI of type DOMString
namespaceURI of namespace.
localName of type DOMString
localName of namespace.
Return Value

boolean

A boolean that is true if the element is defined, false otherwise.

No Exceptions
isEntityDefined
Determines if an entity is defined in the document.
ISSUE: Should methods be added to the DocumentTypeAS for the complete list of defined elements and for a particular element type, the complete list of defined attributes. These two methods might return a list of strings which is a type not yet described in the DOM spec.
Parameters
entName of type DOMString
Name of entity.
Return Value

boolean

A boolean that is true if the entity is defined, false otherwise.

No Exceptions
Interface AttributeAS

This interface extends Attr to provide guided editing of an XML document. An object implmenting this interface must also implement NodeAS interface.


IDL Definition
interface AttributeAS : Attr {
  ASAttributeDeclaration getAttributeDeclaration();
  ASNotationDeclaration getNotation()
                                        raises(DOMException);
};

Methods
getAttributeDeclaration
returns the corresponding attribute declaration in the abstract schema.
Return Value

ASAttributeDeclaration

The attribute declaration corresponding to this attribute

No Parameters
No Exceptions
getNotation
Returns the notation declaration for the attributes defined of type NOTATION.
Return Value

ASNotationDeclaration

Returns the notation declaration for this attribute if the type is of notation type, null otherwise.

Exceptions

DOMException

DOMException

No Parameters

1.5. DOM Error Handler Interfaces

This section contains DOM error handling interfaces.

Interface DOMErrorHandler

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.


IDL Definition
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);
};

Methods
error
Receive notification of a recoverable error per section 1.2 of the W3C XML 1.0 recommendation. The default behavior if the user doesn't register a handler is to report conditions that are not fatal errors, and allow the calling application to continue processing.
Parameters
where of type DOMLocator
Location of the error, which could be either a source position in the case of loading, or a node reference for later validation. The public ID and system ID for the error location could be some of the information.
how of type DOMString
How the error occurred.
why of type DOMString
Why the error occurred.
Exceptions

DOMSystemException

A subclass of DOMException.

No Return Value
fatalError
Report a fatal, non-recoverable AS or Load/Save error per section 1.2 of the W3C XML 1.0 recommendation. The default behavior if the user doesn't register a handler is to throw a DOMSystemException and stop all further processing.
Parameters
where of type DOMLocator
Location of the fatal error, which could be either a source position in the case of loading, or a node reference for later validation. The public ID and system ID for the error location could be some of the information.
how of type DOMString
How the fatal error occurred.
why of type DOMString
Why the fatal error occurred.
Exceptions

DOMSystemException

A subclass of DOMException.

No Return Value
warning
Receive notification of a warning per the W3C XML 1.0 recommendation. The default behavior if the user doesn't register a handler is to report conditions that are not errors or fatal errors, and then allow the calling application to continue even after invoking this method.
Parameters
where of type DOMLocator
Location of the warning, which could be either a source position in the case of loading, or a node reference for later validation. The public ID and system ID for the error location could be some of the information.
how of type DOMString
How the warning occurred.
why of type DOMString
Why the warning occurred.
Exceptions

DOMSystemException

A subclass of DOMException.

No Return Value
Interface DOMLocator

This interface provides document location information and is similar to a SAX locator object.


IDL Definition
interface DOMLocator {
  int                getColumnNumber();
  int                getLineNumber();
  DOMString          getPublicID();
  DOMString          getSystemID();
  Node               getNode();
};

Methods
getColumnNumber
Return the column number.
Return Value

int

The column number, or -1 if none is available.

No Parameters
No Exceptions
getLineNumber
Return the line number.
Return Value

int

The line number, or -1 if none is available.

No Parameters
No Exceptions
getNode
Return the Node.
Return Value

Node

The NODE, or null if none is available.

No Parameters
No Exceptions
getPublicID
Return the public identifier.
Return Value

DOMString

A string containing the public identifier, or null if none is available.

No Parameters
No Exceptions
getSystemID
Return the system identifier.
Return Value

DOMString

A string containing the system identifier, or null if none is available.

No Parameters
No Exceptions

1.6. Editing and Generating an Abstract Schema

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.

1.7. Abstract Schema-directed Document Manipulation

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.

1.8. Validating a Document Against an Abstract Schema

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.

1.9. Well-formedness Testing

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:

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.