This section describes the objects that are used to represent the DTD of a document. The objects are not XML specific, though some attributes are specific to HTML DTD's. Such cases are clearly marked.
Interface DocumentTypeInterface ElementDefinitionEach document has a (possibly null) attribute that contains a reference to a
DocumentTypeobject. TheDocumentTypeclass provides an interface to access all of the entity declarations, notation declarations, and all the element type declarations.(ED: There is no way currently of accessing the list of entities declared within a DTD. This will be added once discussion about entity representation is completed.)
IDL Definition
interface DocumentType { attribute wstring name; attribute Node externalSubset; attribute Node internalSubset; attribute Node generalEntities; attribute Node parameterEntities; attribute Node notations; attribute Node elementTypes; };Attribute
nameThe
nameattribute is awstringthat holds the name of DTD; i.e. the name immediately following theDOCTYPEkeyword.Attribute
externalSubsetThe
externalSubsetattribute's children reference the list of nodes (definitions) that occurred in the external subset of a document. In this example:it would iterate over all of the declarations that occurred within the
<!DOCTYPE ex SYSTEM "ex.dtd" [ <ex/>ex.dtdexternal entity. Note: An iterator interface is used so as to not constrain implementationsAttribute
internalSubsetThe internal subset's children constitute all the definitions that occurred within the internal subset of a document (the part that appears within the document instance). For example
if would iterate over a single node: the definition of the
<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY ex "example"> ]> <ex/>exentity. Note: An iterator interface is used so as to not constrain implementationsAttribute
generalEntitiesThis is a
Nodewhose children constitute the set of general entites that were defined within the external and the internal subset. For example in:the interface would provide access to
<!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY % baz "baz"> ]> <ex/>fooandbarbut notbaz. All objects supporting theNodeinterface that are accessed though this attribute, will also support theEntityinterface (defined below).Attribute
parameterEntitiesThis is a
Nodewhose children constitute the set of parameter entites that were defined within the external and the internal subset. In the example above, the interface would provide access tobazbut notfooorbar. All objects supporting theNodeinterface that are accessed though this attribute, will also support theEntityinterface (defined below).Attribute
notationsThis is a
Nodewhose children constitute the set of notations that were defined within the external and the internal subset. All objects supporting theNodeinterface that are accessed though this attribute, will also support theNotationinterface (defined below).Attribute
elementTypesThis is a
Nodewhose children constitute the set of element types that were defined within the external and the internal subset. All objects supporting theNodeinterface that are accessed though this attribute, will also support theElementDefinitioninterface (defined below).
Interface PCDATATokenThe definition of each element defined within the external or internal subset (providing it is parsed), will be available through the
elementTypesattribute of theDocumentTypeobject. The name, attribute list, and content model are all available for inspection.IDL Definition
interface ElementDefinition : Node { // ContentType const int EMPTY = 1; const int ANY = 2; const int PCDATA = 3; const int MODEL_GROUP = 4; attribute wstring name; attribute int contentType; attribute ModelGroup contentModel; attribute Node attributeDefinitions; attribute Node inclusions; attribute Node exceptions; };Definition group
ContentType(ED: TBD)
Defined Constants
EMPTY The element is an empty element, and cannot have content.
ANY The element may have character data, or any of the other elements defined within the DTD as content, in any order and sequence.
PCDATA The element can have only PCDATA (Parsed Character Data) as content.
MODEL_GROUP The element has a specific content model associated with it. The model is accessible through the
contentModelattribute (below).Attribute
nameThis is the name of the type of element being defined.
Attribute
contentTypeThis attribute specifies the type of content of the element.
Attribute
contentModelIf the
contentTypeisMODEL_GROUP, then this will provide access to aModelGroup(below) object that is the root of the content model object heirarchy for this element. For other content types, this will be null.Attribute
attributeDefinitionsThe children of this
Nodeconsist of the attributes that were defined to be on anElementDefinition. Each object supporting theNodeinterface that is accessed through this attribute will also support theAttributeDefinitioninterface.Attribute
inclusionsThe children of this define a list of element type names that are included in the content model of this element by the SGML inclusion/exception mechanism (not available from XML, but used in HTML).
Attribute
exceptionsThe children of this node define a list of element type names that are excluded from the content model of this element by the SGML inclusion/exception mechanism (not available from XML, but used in HTML).
Interface ElementTokenToken type for the string #PCDATA
IDL Definition
interface PCDATAToken : Node { };
Interface ModelGroupToken for an element declaration.
IDL Definition
interface ElementToken : Node { // OccurrenceType const int OPT = 1; const int PLUS = 2; const int REP = 3; attribute wstring name; attribute int occurrence; };Definition group
OccurrenceType(ED: TBD)
Defined Constants
OPT The
?occurrence indicator.PLUS The
+occurrence indicator.REP The
*occurrence indicator.Attribute
nameThe element type name.
Attribute
occurrenceThe number of times this element can occur.
Interface AttributeDefinitionThe
ModelGroupobject represents the content model of anElementDefinition. The content model is represented as a tree, where each node specifies how its children are connected, and the number of times that it can occur within its parent. Leaf nodes in the tree are eitherPCDATATokenorElementToken.IDL Definition
interface ModelGroup : Node { // OccurrenceType const int OPT = 1; const int PLUS = 2; const int REP = 3; // ConnectionType const int OR = 1; const int SEQ = 2; const int AND = 3; attribute int occurrence; attribute int connector; attribute Node tokens; };Definition group
OccurrenceType(ED: TBD)
Defined Constants
OPT The
?occurrence indicator.PLUS The
+occurrence indicator.REP The
*occurrence indicator.Definition group
ConnectionType(ED: TBD)
Defined Constants
OR The
|connection indicator.SEQ The
,connection indicator.AND The
??connection indicator.Attribute
occurrenceThe number of times this model can occur.
Attribute
connectorDescribes how the
tokensare connected together.Attribute
tokensThe children of this node define the list of tokens in this model group.
Interface NotationThe
AttributeDefinitioninterface is used to access information about a particular attribute definition on a given element. Object supporting this interface are available from theElementDefinitionobject through theattributeDefinitionsattribute.IDL Definition
interface AttributeDefinition : Node { // DeclaredValueType const int CDATA = 1; const int ID = 2; const int IDREF = 3; const int IDREFS = 4; const int ENTITY = 5; const int ENTITIES = 6; const int NMTOKEN = 7; const int NMTOKENS = 8; const int NOTATION = 9; const int NAME_TOKEN_GROUP = 10; // DefaultValueType const int FIXED = 1; const int REQUIRED = 2; const int IMPLIED = 3; attribute wstring name; attribute StringList allowedTokens; attribute int declaredType; attribute int defaultType; attribute Node defaultValue; };Definition group
DeclaredValueType(ED: TBD)
Defined Constants
CDATA (ED: TBD)
ID (ED: TBD)
IDREF (ED: TBD)
IDREFS (ED: TBD)
ENTITY (ED: TBD)
ENTITIES (ED: TBD)
NMTOKEN (ED: TBD)
NMTOKENS (ED: TBD)
NOTATION (ED: TBD)
NAME_TOKEN_GROUP (ED: TBD)
Definition group
DefaultValueType(ED: TBD)
Defined Constants
FIXED (ED: TBD)
REQUIRED (ED: TBD)
IMPLIED (ED: TBD)
Attribute
nameThe name of the attribute.
Attribute
allowedTokensThe list of tokens that are allowed as values. For example, in
this would hold
<!DOCTYPE ex [ <!ELEMENT ex (#PCDATA) > <!ATTLIST ex test (FOO|BAR) "FOO" > ]> <ex></ex>FOOandBAR.Attribute
declaredTypeThis attribute indicates the type of values the attribute may contain.
Attribute
defaultTypeThis specifies whether the attribute must be specified in the instance, and if it is not, what the attribute value will be if not provided.
Attribute
defaultValueThis provides an interface to a
Nodewhose children make up the default value for an attribute. This value is used if the attribute was not given an explicit value in the document instance.
The
Notationobject is used to represent the definition of a notation within a DTD.IDL Definition
interface Notation : Node { attribute wstring name; attribute boolean isPublic; attribute string publicIdentifier; attribute string systemIdentifier; };Attribute
nameThis is the name of the notation.
Attribute
isPublicIf a public identifier was specified in the notation declaration, this will be
TRUE, and thepublicIdentifierattribute will contain the string for the public identifier.Attribute
publicIdentifierIf a public identifier was specified in the notation declaration, this will hold the public identifier string, otherwise it will be null.
Attribute
systemIdentifierIf a system identifier was specified in the notation declaration, this will hold the system identifier string, otherwise it will be null.