DOM Document Type Definition Module

Working Draft

This Version
<http://suika.fam.cx/www/markup/xml/domdtdef/domdtdef-work>
Latest Version
<http://suika.fam.cx/www/markup/xml/domdtdef/domdtdef>
Latest Working Draft
<http://suika.fam.cx/www/markup/xml/domdtdef/domdtdef-work>
Version History
<http://suika.fam.cx/gate/cvs/markup/xml/domdtdef/domdtdef-work.en.html>
Author
<>

Abstract

...

Status of This Document

This section describes the status of this document at the time of its publication. Other documents might supersede this document.

This document is a working draft, produced as part of the manakai project. It might be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Comments on this document are welcome and may be sent to the author.

Translations of thie document might be available. The English version of the document is the only normative version.

Introduction

This section is non‐normative.

This is a work-in-progress specification for DOM Document Type Definition module, as implemented by manakai and partially documented in the SuikaWiki.

The DOM Document Type Definition module is a set of DOM interfaces, including both new interfaces and modifications to existing DOM interfaces, over which DOM applications are able to access to the definitions of the document type.

Interfaces defined in this specification are partially modeled from early drafts of DOM level 1 @@ ref, DOM Abstract Schema level 3 @@ ref, and XML Schema API, but are not compatible with any of them as a whole.

Terminology

The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY in this document are to be interpreted as described in RFC 2119 [KEYWORDS].

All examples and notes in this specification are non‐normative, as are all sections explicitly marked non‐normative. Everything else in this specification is normative.

Algorithm is normative but non-normative. In addition, the order in which errors are raised is undefined.

A object is an object implementing A interface.

@@ ref to DOM Binding Spec

DOM Document Type Definition Module

The DOM Document Type Definition module, version 3.0, consists of three interfaces:

In addition, it adds methods, attributes, and/or constants to interfaces Node, Entity, EntityReference, and Notation. It modifies semantics of some of methods and attributes in Node and ProcessingInstruction interfaces, for the support of new interfaces.

Feature Name

In a DOM implementation that supports the version 3.0 of the DOM Document Type Definition module, the hasFeature method of a DOMImplementation object MUST return true when the parameters are set to http://suika.fam.cx/www/2006/feature/XDoctype and 3.0 respectively.

In such an implementation, the getFeature method of a Document object MUST return the (at least conceptually) same object implementing the DocumentXDoctype interface when the parameters are set to http://suika.fam.cx/www/2006/feature/XDoctype and 3.0 respectively. Likewise, any method that takes one or more feature names with or without version number, including the methods hasFeature and getFeature, MUST behave in a manner consistent with the aforementioned cases.

The DocumentXDoctype Interface

interface DocumentXDoctype {
  DocumentType createDocumentTypeDefinition
    (in DOMString name)
    raises (DOMException);
  ElementTypeDefinition createElementTypeDefinition
    (in DOMString name)
    raises (DOMException);
  AttributeDefinition createAttributeDefinition
    (in DOMString name)
    raises (DOMException);
  Entity createGeneralEntityDefinition
    (in DOMString name)
    raises (DOMException);
  Notation createNotation
    (in DOMString name)
    raises (DOMException);
}
@@ cast definition
createDocumentTypeDefinition, method

This method creates a DocumentType node with the specified name, belonging to the document.

The name parameter is the name of the document type.

When invoked, the method MUST create and return a DocumentType node with the following attributes:

attributes, parentNode
null.
elementTypes, generalEntities, and notations
Empty NamedNodeMap objects.
entities
The same value as the generalEntities attribute.
childNodes
An empty NodeList object.
internalSubset, publicId, and systemId
Empty strings.
manakaiReadOnly [manakai]
false.
nodeName
name.
ownerDocument
The Document over which the method is invoked.

In addition, the method MUST be marked as containing five general entity declarations: amp, lt, gt, quot, and apos.

createElementTypeDefinition, method

This method creates a ElementTypeDefinition node with the specified name, belonging to the document.

The name parameter is the name of the element type defined by the element type definition.

When invoked, the method MUST create and return an ElementTypeDefinition node with the following attributes:

attributeDefinitions
An empty NamedNodeMap object.
attributes, parentNode
null.
childNodes
An empty NodeList object.
manakaiReadOnly [manakai]
false.
nodeName
name.
ownerDocument
The Document node over which the method is invoked.
ownerDocumentTypeDefinition
null.
@@ Ensure all attributes are defined
createAttributeDefinition, method

This method creates a AttributeDefinition node with the specified name, belonging to the document.

The name parameter is the name of the attribute defined by the attribute definition.

When invoked, the method MUST create and return an AttributeDefinition node with the following attributes:

allowedTokens
An empty DOMStringList object.
attributes, ownerElementTypeDefinition, and parentNode
null.
childNodes
An empty NodeList object.
declaredType
NO_TYPE_ATTR.
defaultType
UNKNOWN_DEFAULT.
manakaiReadOnly [manakai]
false.
nodeName
name.
ownerDocument
The Document node over which the method is invoked.
@@ Ensure all attributes are defined

@@ Should we keep these statements?: However, if the <cfg::cfg|xml-id> configuration parameter is set to true and the name is xml:id, then the [CODE(DOMa)@en[[[declaredType]]]] attribute is set to ID_ATTR. [CODE(DOMa)@en[[[defaultType]]]]?

createGeneralEntity, method

This method creates a Entity node with the specified name, which represents a general entity, belonging to the document.

The name parameter is the name of the general entity.

When invoked, the method MUST create and return an Entity node with the following attributes:

attributes, notationName, ownerDocumentTypeDefinition, and parentNode
null.
childNodes
An empty NodeList object.
manakaiDeclarationBaseURI, manakaiEntityBaseURI, and manakaiEntityURI @@ ref
No explicit value is set.
manakaiHasReplacementTree and manakaiReadOnly [manakai]
false.
nodeName
name.

It is not an error for name matching to the name of one of predefined general parsed entities in XML or HTML. For example, name might be amp, resulting in an Entity node with its nodeName attribute set to amp.

ownerDocument
The Document node over which the method is invoked.
publicId, and systemId
null.
@@ publicId and systemId should be empty string?
@@ Ensure all attributes are defined
createNotation, method

This method creates a Notation node with the specified name, belonging to the document.

The name parameter is the name of the notation.

When invoked, the method MUST create and return a Notation node with the following attributes:

attributes, ownerDocumentTypeDefinition, and parentNode
null.
childNodes
An empty NodeList object.
manakaiDeclarationBaseURI
No explicit value is set.
manakaiReadOnly [manakai]
false.
nodeName
name.
ownerDocument
The Document node over which the method is invoked.
publicId and systemId
null.
@@ publicId and systemId should be empty string?
@@ Ensure all attributes are defined

These methods MUST raise an INVALID_CHARACTER_ERR exception @@ ref if name is not a legal Name according to the XML version in use, as specified in the xmlVersion attribute of the Document node.

Non‐XML case is intentionally left unspecified for now, since DOM3 specification @@ ref does not define it for Document methods.

name does not have to be a namespace qualified name.

If the strictErrorChecking attribute of the Document node is false, the methods are not required to raise the exception [DOM3].

The DocumentTypeDefinition Interface

interface DocumentTypeDefinition {
  readonly attribute NamedNodeMap elementTypes;
  readonly attribute NamedNodeMap generalEntities;
  readonly attribute NamedNodeMap notations;

  more members come here...
}
[1] In an implementation that supports the 
[CODE(URI)@en[[[http://suika.fam.cx/www/2006/feature/XDoctype]]]]
feature, a [CODE(DOMi)@en[[[DocumentType]]]] node
must implement the [CODE(DOMi)@en[[[DocumentTypeDefinition]]]]
interface.  See [[DOM XML Document Type Definition]>>3] for
details.
elementTypes of type NamedNodeMap, read‐only

A live NamedNodeMap object that contains all the element type definitions belonging to the DocumentType node.

On getting, the attribute MUST return the NamedNodeMap object that contains all the ElementTypeDefinition nodes belonging to the DocumentType node. The NamedNodeMap object MUST be read‐only if and only if the node is read‐only. The NamedNodeMap object MUST be live and the same object MUST be returned for any invocation.

If the DocumentType node is created during the process to create a DOM from an XML document, the following requirements are applied: The NamedNodeMap object in the elementType attribute MUST be so transformed that the object contains the ElementTypeDefinition nodes for the element types whose name is presented as the Name of the element type or attribute definition list declarations processed by the XML processor. If there is more than one element type declarations for an element type, then the declarations other than the first one MUST be ignored for the purpose of constructing the NamedNodeMap object.

generalEntities of type NamedNodeMap, read‐only

A live NamedNodeMap object that contains all the general entities belonging to the DocumentType node.

On getting, the attribute MUST return the same value as the entities attribute (defined in the DocumentType interface) of the same node.

This attribute is part of the interface for historical reason.

notations of type notations, read‐only

A live NamedNodeMap object that contains all the notations belonging to the DocumentType node.

On getting, the attribute MUST return the same value as the notations attribute (defined in the DocumentType interface) of the same node.

This attribute is part of the interface for historical reason.

Implementations are not required to implement the notations attribute twice (for DocumentType and DocumentTypeDefinition interfaces); they share exactly same definition.

@@ other members...

A future version of this interface might define the parameterEntities and getter/setter for parameter entities.

The ElementTypeDefinition Interface

interface ElementTypeDefinition : Node {
  readonly attribute ownerDocumentTypeDefinition;

  @@ more
}
** Modifications to [CODE(DOMi)@en[[[Node]]]] members

[3] The getter of the [CODE(DOMa)@en[[[attributes]]]] attribute
of an [CODE(DOMi)@en[[[ElementTypeDefinition]]]] object
[['''MUST''']] return [CODE(IDL)@en[[[null]]]].

[4] The getter of the [CODE(DOMa)@en[[[baseURI]]]] attribute
of an [CODE(DOMi)@en[[[ElementTypeDefinition]]]] object
[['''MUST''']] return the [CODE(DOMa)@en[[[baseURI]]]]
of the [CDOE(DOMa)@en[[[ownerDocument]]]] of the
[CODE(DOMi)@en[[[ElementTypeDefinition]]]] object.
Note that it might be [CODE(IDL)@en[[[null]]]].

[1] The getter of the [CODE(DOMa)@en[[[nodeName]]]] attribute
of an [CODE(DOMi)@en[[[ElementTypeDefinition]]]] object
[['''MUST''']] return the name of the element type.

[2] The getters of the [CODE(DOMa)@en[[[nodeValue]]]] 
and [CODE(DOMa)@en[[[textContent]]]] attributes
of an [CODE(DOMi)@en[[[ElementTypeDefinition]]]]
object [['''MUST''']] return [CODE(IDL)@en[[[null]]]].

;; Thus, the setter of these attributes do nothing.

The setter of the [CODE(DOMa)@en[[[textContent]]]]
attribute of an [CODE(DOMi)@en[[[ElementTypeDefinition]]]]
object [['''MUST NOT''']] throw a 
[CODE(DOMc)@en[[[NO_MODIFICATION_ALLOWED_ERR]]]].

** The [CODE(DOMi)@en[ElementTypeDefinition]] Interface

[5] The 
[DFN@en[[CODE(DOMa)@en[[[ownerDocumentTypeDefinition]]]] attribute]]
of the [CODE(DOMi)@en[[[ElementTypeDefinition]]]]
interface is defined in [[manakai//DOM Extensions]>>50].

The AttributeDefinition Interface

interface AttributeDefinition : Node {
  // DeclaredValueType
  const unsigned short NO_TYPE_ATTR = 0;
  const unsigned short CDATA_ATTR = 1;
  const unsigned short ID_ATTR = 2;
  const unsigned short IDREF_ATTR = 3;
  const unsigned short IDREFS_ATTR = 4;
  const unsigned short ENTITY_ATTR = 5;
  const unsigned short ENTITIES_ATTR = 6;
  const unsigned short NMTOKEN_ATTR = 7;
  const unsigned short NMTOKENS_ATTR = 8;
  const unsigned short NOTATION_ATTR = 9;
  const unsigned short ENUMERATION_ATTR = 10;
  const unsigned short UNKNOWN_ATTR = 11;
  
  readonly attribute ElementTypeDefinition ownerElementTypeDefinition;

  readonly attribute unsigned short declaredType;
  readonly attribute unsigned short defaultType;

  ...
}
** Modifications to [CODE(DOMi)@en[[[Node]]]] members

[3] The getter of the [CODE(DOMa)@en[[[attributes]]]] attribute
of an [CODE(DOMi)@en[[[AttributeDefinition]]]] object
[['''MUST''']] return [CODE(IDL)@en[[[null]]]].

[9] The getter of the [CODE(DOMa)@en[[[baseURI]]]] attribute
of an [CODE(DOMi)@en[[[AttributeDefinition]]]] object
[['''MUST''']] return the [CODE(DOMa)@en[[[baseURI]]]]
of the [CDOE(DOMa)@en[[[ownerDocument]]]] of the
[CODE(DOMi)@en[[[AttributeDefinition]]]] object.
Note that it might be [CODE(IDL)@en[[[null]]]].

[1] The getter of the [CODE(DOMa)@en[[[nodeName]]]] attribute
of an [CODE(DOMi)@en[[[AttributeDefinition]]]] object
[['''MUST''']] return the name of the attribute.

[2] The getter of the [CODE(DOMa)@en[[[nodeValue]]]] attribute
of an [CODE(DOMi)@en[[[AttributeDefinition]]]] object
[['''MUST''']] return the normalized default value
of the attribute.

@@

[4] The getter of the [CODE(DOMa)@en[[[textContent]]]]
attribute of an [CODE(DOMi)@en[[[AttributeDefinition]]]] 
object [['''MUST''']] behave as if it were an
[CODE(DOMi)@en[[[Attr]]]] object.

The setter of the [CODE(DOMa)@en[[[textContent]]]] attribute
of an [CODE(DOMi)@en[[[AttributeDefinition]]]] object
[['''MUST''']] behave as if the following algorithm
is performed:
= If the [CODE(DOMi)@en[[[AttributeDefinition]]]]
object is read-only, then throw an
[CODE(DOMc)@en[[[NO_MODIFICATION_ALLOWED_ERR]]]].
= Remove any child node the node has.
= If the new value is not empty and not [CODE(IDL)@en[[[null]]]],
then create a [CODE(DOMi)@en[[[Text]]]] node
whose [CODE(DOMa)@en[[[data]]]] is the new value
and append it to the [CODE(DOMi)@en[[[AttributeDefinition]]]].
ownerElementTypeDefinition of type ElementTypeDefinition, read‐only

The ElementTypeDefinition to which the AttributeDefinition node belongs.

On getting, the attribute MUST return an ElementTypeDefinition node. It MUST be such a node that whose attributeDefinitions attribute contains the NamedNodeMap object that contains the AttributeDefinition node. If there is no such an ElementTypeDefinition node, then null MUST be returned.

declaredType of type unsigned short

The declared type @@ ref of the attribute. It is expected that this attribute contains a value from the definition group DeclaredValueType.

On getting, the attribute MUST return the value associated to this attribute.

On setting, the attribute MUST raise a NO_MODIFICATION_ALLOWED_ERR @@ ref exception if the AttributeDefinition node is read‐only @@ ref. Otherwise, it MUST set the specified value as the value associated to this attribute.

If the AttributeDefinition node is created during the process to create a DOM from an XML document, an appropriate value from the DeclaredValueType constant group MUST be set to the attribute.

The definition group DeclaredValueType contains integers indicating the declared type of attributes. The definition group contains the following constants:

NameValueDescription
NO_TYPE_ATTR 0No value [INFOSET].
CDATA_ATTR 1CDATA [XML].
ID_ATTR 2ID [XML].
IDREF_ATTR 3IDREF [XML].
IDREFS_ATTR 4IDREFS [XML].
ENTITY_ATTR 5ENTITY [XML].
ENTITIES_ATTR 6ENTITIES [XML].
NMTOKEN_ATTR 7NMTOKEN [XML].
NMTOKENS_ATTR 8NMTOKENS [XML].
NOTATION_ATTR 9NOTATION [XML].
ENUMERATION_ATTR 10Enumeration [XML].
UNKNOWN_ATTR 11Unknown, because no declaration for the attribute has been read but the [all declaration processed] property [INFOSET] would be false.

If no attribute type information is available, or if the source of the information does not distinguish no value and unknown [INFOSET], then the value NO_TYPE_ATTR MUST be used.

An AttributeDefinition node created by the createAttributeDefinition method has its declaredType attribute set to NO_TYPE_ATTR.

If the source of the information does not distinguish no value and/or unknown [INFOSET] and CDATA [XML], then the value CDATA_ATTR MUST be used.

In Perl binding [PERLBINDING], the Attr nodes MUST implement the DeclaredValueType definition group.

defaultType of type unsigned short

The type of the default for the attribute. It is expected that this attribute contains a value from the definition group DefaultValueType.

On getting, the attribute MUST return the value associated to this attribute.

On setting, the attribute MUST raise a NO_MODIFICATION_ALLOWED_ERR @@ ref exception if the AttributeDefinition node is read‐only @@ ref. Otherwise, it MUST set the specified value as the value associated to this attribute.

If the AttributeDefinition node is created during the process to create a DOM from an XML document, an appropriate value from the DefaultValueType definition group MUST be set to the attribute.

The definition group DefaultValueType contains integers indicating the type of the default for the attribute. The definition group contains the following constans:

NameValueDescription
UNKNOWN_DEFAULT 0Unknown.
FIXED_DEFAULT 1Provided explicitly and fixed @@ ref to that value.
REQUIRED_DEFAULT 2No default value and the attribute have to be explicitly specified.
IMPLIED_DEFAULT 3Implied @@ ref.
EXPLICIT_DEFAULT 4Provided explicitly.

If the source of the default type does not distinguish implied and unknown default types, then the value IMPLIED_DEFAULT MUST be used.

An AttributeDefinition node created by the createAttributeDefinition method has its defaultType attribute set to UNKNOWN_DEFAULT.

References

Normative References

DOM3CORE
@@ W3C DOM Level 3 Core
DOMDTDEF
@@ manakai's extension to DOM for document type definitions
KEYWORDS
Key words for use in RFCs to Indicate Requirement Levels, IETF BCP 14, RFC 2119, . This version of the specification is referenced.
INFOSET
@@
XML10
Extensible Markup Language (XML) 1.0 (Fourth Edition), W3C Recommendation, , edited in place . Tje latest version of the specification is available at <http://www.w3.org/TR/xml>. This version of the specification is referenced.
XML11
@@

Non‐normative References

CSS
Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification, W3C Candidate Recommendation, . Work in progress. The latest version of the specification is available at <http://www.w3.org/TR/CSS21>.
CSSOM
Cascading Style Sheets Object Model (CSSOM), W3C Editor's Draft, . Work in progress. The latest Editor's Draft of the specification is available at <http://dev.w3.org/csswg/cssom/Overview.html>.
HTML5
HTML 5, WHATWG Working Draft. Work in progress.
SAPI
Selectors API, W3C Editor's Draft, . Work in progress. The latest Editor's Draft of the specification is available at <http://dev.w3.org/2006/webapi/selectors-api/Overview.html>. The latest published version of the specification is available at <http://www.w3.org/TR/selectors-api/>.
XBL2
XBL 2.0, Mozilla.org, . Work in progress. The latest W3C‐published version of the specification is available at <http://www.w3.org/TR/xbl/>.
XML5
@@