This chapter describes the optional DOM Level 3 Abstract Schemas
(AS) feature. This module provides a representation for XML
abstract schemas, e.g., DTDs [XML 1.0] and XML Schemas [XML
Schema Part 0], 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.
A DOM application can use the hasFeature
method of the
DOMImplementation
interface defined in DOM Core 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 Document Object Model Load and Save. 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 uses the error-reporting mechanism allowing user-registered error callbacks introduced in [DOM Level 3 Core]. Note that this may not imply that the parser actually calls the DOM's validation code -- it may be able to achieve better performance via its own -- but the appearance to the user should probably be "as if" the DOM has been asked to validate the document, and parsers should probably be able to validate newly loaded documents in terms of a previously loaded DOM AS.
Finally, this chapter will have separate sections to address the needs of the document-editing and AS-editing worlds, along with a section that details overlapping areas such as validation. In this manner, the document-editing world's focuses on editing aspects and usage of information in the AS are made distinct from the AS-editing world's focuses on defining and manipulating the information in the AS.
In the October 9, 1997 DOM requirements document, the following appeared: "There will be a way to determine the presence of a DTD. There will be a way to add, remove, and change declarations in the underlying DTD (if available). There will be a way to test conformance of all or part of the given document against a DTD (if available)." In later discussions, the following was added, "There will be a way to query element/attribute (and maybe other) declarations in the underlying DTD (if available)," supplementing the primitive support for these in Level 1.
That work was deferred past Level 2, in the hope that XML Schemas would be addressed as well. It is anticipated that lowest common denominator general APIs generated in this chapter can support both DTDs and XML Schemas, and other XML abstract schemas down the road.
The kinds of information that an Abstract Schema must make available are mostly self-evident from the definitions of Infoset, DTDs, and XML Schemas. Note that some kinds of information on which the DOM already relies, e.g., default values for attributes, will finally be given a visible representation here.
The abstract schema referenced in these use cases/requirements is an abstraction and does not refer solely to DTDs or XML Schemas.
For the AS-editing and document-editing worlds, the following use cases and requirements are common to both and could be labeled as the "Validation and Other Common Functionality" section:
Use Cases:
Requirements:
Specific to the AS-editing world, the following are use cases and requirements and could be labeled as the "AS-editing" section:
Use Cases:
Requirements:
Specific to the document-editing world, the following are use cases and requirements and could be labeled as the "Document-editing" section:
Use Cases:
Requirements:
General Issues:
QName
, e.g.,
foo:bar
, whereas the latter will report its namespace
and local name, e.g., {http://my.namespace}bar
. We
have added the NamespaceAware
attribute to the generic
AS object to help applications determine which of these fields are
important, but we are still analyzing this challenge. Nonetheless,
after much discussion, we have made the decision that only 1 active
ASModel is allowed, even on ASDOMBuilder (the parser would set the
1 active schema).NodeEditAS.can*()
,
CharacterDataEditAS.can*()
, and
ElementEditAS.can*()
methods throw exceptions like the
isNodeValid()
method. Resolution: no exceptions should
be thrown; it should be allowed if it's not forbidden. Better
descriptions are in order for the true/false returns.ASModel
is activated, will there be cleanup done to remove the previous
ASModel's default attributes and entity definitions, if any? AS ET
members felt that whatever is done implementation-wise, correct
behavior should result.ASModel
container of other ASModels.ASModel
and ASContentModel, if operations modify the ASElementDecl.
Documentation was added in the ASElementDecl editing methods to
reflect this.ASModel
internal/external subset and "global" attributes. Need to also
introduce the concept of a dummy element declaration and dummy
constant for element types not yet declared but appearing in the
content model of another element type.A list of the proposed Abstract Schema data structures and
functions follow, starting off with the data structures and
"AS-editing" methods. Note that operations on the ASModel
that could result in its being invalid will be discovered during
document validation and not during the AS editing operation, for
example, removeNode
. Finally, note that an example
element declaration: for (A, (B* | C), D+)
can be
described by the following:
ASElementDecl example = { strictMixedContent = false; elementType = STRING_DATATYPE; isPCDataOnly = false; contentType = ELEMENTS_CONTENTTYPE; ASContentModel = exE; ASAttributeDecls = null; } ASContentModel exE = { listOperator = AS_SEQUENCE; minOccurs = 1; maxOccurs = 1; subModels = {(ASElementDecl A), (ASContentModel exBC), (ASContentModel exD)}; } ASElementDecl A = { strictMixedContent = false; elementType = STRING_DATATYPE; isPCDataOnly = false; contentType = ELEMENTS_CONTENTTYPE; ASContentModel = null; ASAttributeDecls = null; } ASContentModel exBC = { listOperator = AS_CHOICE; minOccurs = 1; maxOccurs = 1; subModels = {(ASContentModel exB), (ASElementDecl C)}; } ASContentModel exB = { listOperator = AS_NONE; minOccurs = 0; maxOccurs = AS_UNBOUNDED; subModels = {(ASElementDecl B)}; } ASElementDecl B = { strictMixedContent = false; elementType = STRING_DATATYPE; isPCDataOnly = false; contentType = ELEMENTS_CONTENTTYPE; ASContentModel = null; ASAttributeDecls = null; } ASElementDecl C = { strictMixedContent = false; elementType = STRING_DATATYPE; isPCDataOnly = false; contentType = ELEMENTS_CONTENTTYPE; ASContentModel = null; ASAttributeDecls = null; } ASContentModel exD = { listOperator = AS_NONE; minOccurs = 1; maxOccurs = AS_UNBOUNDED; subModels = {(ASElementDecl D)}; } ASElementDecl D = { strictMixedContent = false; elementType = STRING_DATATYPE; isPCDataOnly = false; contentType = ELEMENTS_CONTENTTYPE; ASContentModel = null; ASAttributeDecls = null; }
Abstract Schemas operations may throw a
DOMSystemException
as described in their
descriptions.
exception ASException { unsigned short code; }; // ASExceptionCode const unsigned short DUPLICATE_NAME_ERR = 1; const unsigned short TYPE_ERR = 2; const unsigned short NO_AS_AVAILABLE = 3; const unsigned short WRONG_MIME_TYPE_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short VALIDATION_ERR = 6;
An integer indicating the type of error generated.
DUPLICATE_NAME_ERR
AS_CHOICE
operator.INVALID_CHARACTER_ERR
NO_AS_AVAILABLE
DocumentEditAS
related to the node does not have any active ASModel
and wfValidityCheckLevel
is set to
PARTIAL
or STRICT_VALIDITY_CHECK
.TYPE_ERR
ASObject
is neither an
ASContentModel
nor an ASElementDecl
.VALIDATION_ERR
WRONG_MIME_TYPE_ERR
mimeTypeCheck
is true
and the
input source has an incorrect MIME Type. See the attribute
mimeTypeCheck
.To begin with, an abstract schema is a generic structure that
could contain both internal and external subsets. An
ASModel
is an abstract object that could map to a DTD
[XML
1.0], an XML Schema [XML Schema Part 0], a
database schema, etc. An ASModel
could represent
either an internal or an external subset; hence an abstract schema
could be composed of an ASModel
representing the
internal subset and an ASModel
representing the
external subset. Note that the ASModel
representing
the external subset could consult the ASModel
representing the internal subset. Furthermore, the
ASModel
representing the internal subset could be set
to null
by the setInternalAS() method as a mechanism
for "removal". In addition, only one ASModel
representing the external subset can be specified as "active" and
it is possible that none are "active". Finally, the
ASModel
contains the factory methods needed to create
a various types of ASObjects like ASElementDecl
,
ASAttributeDecl
, etc.
interface ASModel : ASObject { // ASMODEL_TYPES const unsigned short INTERNAL_SUBSET = 1; const unsigned short EXTERNAL_SUBSET = 2; const unsigned short NOT_USED = 3; readonly attribute boolean NamespaceAware; readonly attribute unsigned short usage; attribute DOMString location; attribute DOMString hint; readonly attribute boolean container; readonly attribute ASNamedObjectMap elementDecls; readonly attribute ASNamedObjectMap attributeDecls; readonly attribute ASNamedObjectMap notationDecls; readonly attribute ASNamedObjectMap entityDecls; readonly attribute ASNamedObjectMap contentModelDecls; void addASModel(in ASModel abstractSchema); ASObjectList getASModels(); void removeAS(in ASModel as); boolean validate(); void importASObject(in ASObject asobject); void insertASObject(in ASObject asobject); ASElementDecl createASElementDecl(in DOMString namespaceURI, in DOMString name) raises(ASException); ASAttributeDecl createASAttributeDecl(in DOMString namespaceURI, in DOMString name) raises(ASException); ASNotationDecl createASNotationDecl(in DOMString namespaceURI, in DOMString name, in DOMString systemId, in DOMString publicId) raises(ASException); ASEntityDecl createASEntityDecl(in DOMString name) raises(ASException); ASContentModel createASContentModel(in DOMString name, in DOMString namespaceURI, in unsigned long minOccurs, in unsigned long maxOccurs, in unsigned short operator) raises(ASException); };
A code representing how the ASModel
is used.
EXTERNAL_SUBSET
ASModel
is used as an external subset.INTERNAL_SUBSET
ASModel
is used as an internal subset.NOT_USED
ASModel
is neither used as an internal or
external subset.NamespaceAware
of type boolean
, readonlytrue
if this ASModel
defines the
document structure is namespace-aware [XML Namespaces];
false
if the document structure is
non-namespace-aware.attributeDecls
of type ASNamedObjectMap
,
readonlyASObject
with ASModel
methods, have discernible top-level
attribute declarations, i.e., not bound to sepecific element types
but bound to the ASModel
. If one attempts to add, set,
or remove a object type other than the intended one, a hierarchy
exception (or equivalent) is thrown. In addition, these attribute
declarations can be associated with an incomplete element
declaration, essentially an element with an undefined content
model, indicated by the AS_UNDEFINED constant.container
of type
boolean
, readonlyusage
is EXTERNAL_SUBSET or NOT_USED, and the
ASModel
is simply a container of other ASModels.contentModelDecls
of type ASNamedObjectMap
,
readonlyASObject
with ASModel
methods, have discernible top-level
content model declarations. If one attempts to add, set, or remove
a object type other than the intended one, a hierarchy exception
(or equivalent) is thrown.elementDecls
of type ASNamedObjectMap
,
readonlyASObject
with ASModel
methods, have discernible top-level
(appearing directly on the ASModel
) element
declarations. If one attempts to add, set, or remove a object type
other than the intended one, a hierarchy exception (or equivalent)
is thrown. In addition, these element declarations can be
incomplete, meaning that elements declared through an attribute
list but without any corresponding element declarations can be
represented and their content models undefined, as noted by the
AS_UNDEFINED constant.entityDecls
of type ASNamedObjectMap
,
readonlyASObject
with ASModel
methods, have discernible top-level
entity declarations. If one attempts to add, set, or remove a
object type other than the intended one, a hierarchy exception (or
equivalent) is thrown.hint
of type
DOMString
ASModel
modeled a DTD, this could represent the public
identifier; if an ASModel
modeled a XML schema, this
could represent a target namespace of a schema document. This
attribute can also be NULL.location
of type
DOMString
ASModel
modeled a DTD, this could represent the system identifier; if an
ASModel
modeled a XML schema, this could act as a hint
to the location of a schema document. In addition, if a system
identifier doesn't exist for an internet subset, then this
attribute can be NULL.notationDecls
of type ASNamedObjectMap
,
readonlyASObject
with ASModel
methods, have discernible top-level
notation declarations. If one attempts to add, set, or remove a
object type other than the intended one, a hierarchy exception (or
equivalent) is thrown.usage
of type
unsigned short
, readonlyaddASModel
abstractSchema
of type ASModel
ownerASModel
.createASAttributeDecl
namespaceURI
of type
DOMString
name
of type
DOMString
A new
|
INVALID_CHARACTER_ERR: Raised if the input |
createASContentModel
ASElementDecl
's
content model.
name
of type
DOMString
ASContentModel
.namespaceURI
of type
DOMString
ASContentModel
.minOccurs
of type
unsigned long
ASContentModel
.maxOccurs
of type
unsigned long
ASContentModel
.operator
of type
unsigned short
AS_CHOICE
,
AS_SEQUENCE
, AS_ALL
or
AS_NONE
.
A new
|
A |
createASElementDecl
namespaceURI
of type
DOMString
namespace URI
of the element type being
declared.name
of type
DOMString
A new |
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createASEntityDecl
name
of type
DOMString
A new |
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
createASNotationDecl
namespaceURI
of type
DOMString
name
of type
DOMString
systemId
of type
DOMString
publicId
of type
DOMString
A new |
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. |
getASModels
A list of ASModels. |
importASObject
insertASObject
removeAS
ASModel
from the list of ASModel
s.
as
of type ASModel
validate
ASModel
itself is
valid, i.e., confirming that it's well-formed and valid per its own
formal grammar.
|
|
The ASObject
interface is analogous to a
Node
in [DOM Level 3 Core], e.g., an
element declaration.
interface ASObject { // ASObjectType 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_CONTENTMODEL = 5; const unsigned short AS_MODEL = 6; readonly attribute unsigned short ASObjectType; readonly attribute ASModel ownerASModel; attribute DOMString objectName; attribute DOMString prefix; attribute DOMString localName; attribute DOMString namespaceURI; ASObject cloneASObject(in boolean deep); };
An integer indicating which type of ASObject
this
is.
AS_ATTRIBUTE_DECLARATION
ASAttributeDecl
.AS_CONTENTMODEL
ASContentModel
.AS_ELEMENT_DECLARATION
ASElementDecl
.AS_ENTITY_DECLARATION
ASEntityDecl
.AS_MODEL
ASModel
.AS_NOTATION_DECLARATION
ASNotationDecl
.ASObjectType
of type
unsigned short
, readonlylocalName
of type
DOMString
ASObject
.namespaceURI
of type
DOMString
null
if it is
unspecified. [XML Schema Part 1] defines
how a namespace
URI is attached to schema components.objectName
of type
DOMString
name
of this ASObject
depending
on the ASObject
type.ownerASModel
of type ASModel
,
readonlyASModel
object associated with this ASObject
. For a object of
type AS_MODEL
, this is null
.prefix
of type
DOMString
null
if it is
unspecified.cloneASObject
ASObject
.
See text for cloneNode
off of Node
but
substitute AS functionality.
deep
of type
boolean
deep
flag on, causes the whole subtree
to be duplicated. Setting it to false
only duplicates
its immediate child nodes.
Cloned |
The ASObjectList
interface provides the abstraction
of an ordered collection of AS objects, without defining or
constraining how this collection is implemented.
ASObjectList
objects in the DOM AS are live.
interface ASObjectList { readonly attribute unsigned long length; ASObject item(in unsigned long index); };
item
index
th item in the
collection. The index starts at 0. If index
is greater
than or equal to the number of objects in the list, this returns
null
.
index
of type
unsigned long
The ASObject at the |
Objects implementing the ASNamedObjectMap
interface
are used to represent collections of abstract schema objects that
can be accessed by name. Note that ASNamedObjectMap
does not inherit from ASObjectList
;
ASNamedObjectMaps
are not maintained in any particular
order. Objects contained in an object implementing
ASNamedObjectMap
may also be accessed by an ordinal
index, but this is simply to allow convenient enumeration of the
contents of a ASNamedObjectMap
, and does not imply
that the DOM specifies an order to these ASObjects
.
ASNamedObjectMap
object in the DOM are live.
interface ASNamedObjectMap { readonly attribute unsigned long length; ASObject getNamedItem(in DOMString name); ASObject item(in unsigned long index); ASObject removeNamedItem(in DOMString name) raises(DOMException); ASObject setNamedItem(in ASObject newASObject) raises(DOMException, ASException); };
length
of
type unsigned long
, readonlyASObjects
in the ASObjectList
.
The range of valid child object indices is
0 to length-1
inclusive.getNamedItem
item
index
th item in the
map. The index starts at 0. If index
is greater than
or equal to the number of objects in the list, this returns
null
.
index
of type
unsigned long
removeNamedItem
setNamedItem
ASObject
using its objectName
attribute. If an ASObject
with that name is already present in this map, it is replaced by
the new one.
If the new object replaces an existing one, the replaced object
is returned, otherwise |
|
WRONG_DOCUMENT_ERR: Raised if NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. NOT_SUPPORTED_ERR: Raised if implementation doesn't support AS-editing. HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a
node doesn't belong in this |
The datatypes supported by DOM AS implementations. Further datatypes may be added in the Schema/PSVI spec.
interface ASDataType { readonly attribute unsigned short dataType; // DATA_TYPES const unsigned short STRING_DATATYPE = 1; const unsigned short NOTATION_DATATYPE = 10; const unsigned short ID_DATATYPE = 11; const unsigned short IDREF_DATATYPE = 12; const unsigned short IDREFS_DATATYPE = 13; const unsigned short ENTITY_DATATYPE = 14; const unsigned short ENTITIES_DATATYPE = 15; const unsigned short NMTOKEN_DATATYPE = 16; const unsigned short NMTOKENS_DATATYPE = 17; const unsigned short BOOLEAN_DATATYPE = 100; const unsigned short FLOAT_DATATYPE = 101; const unsigned short DOUBLE_DATATYPE = 102; const unsigned short DECIMAL_DATATYPE = 103; const unsigned short HEXBINARY_DATATYPE = 104; const unsigned short BASE64BINARY_DATATYPE = 105; const unsigned short ANYURI_DATATYPE = 106; const unsigned short QNAME_DATATYPE = 107; const unsigned short DURATION_DATATYPE = 108; const unsigned short DATETIME_DATATYPE = 109; const unsigned short DATE_DATATYPE = 110; const unsigned short TIME_DATATYPE = 111; const unsigned short GYEARMONTH_DATATYPE = 112; const unsigned short GYEAR_DATATYPE = 113; const unsigned short GMONTHDAY_DATATYPE = 114; const unsigned short GDAY_DATATYPE = 115; const unsigned short GMONTH_DATATYPE = 116; const unsigned short INTEGER = 117; const unsigned short NAME_DATATYPE = 200; const unsigned short NCNAME_DATATYPE = 201; const unsigned short NORMALIZEDSTRING_DATATYPE = 202; const unsigned short TOKEN_DATATYPE = 203; const unsigned short LANGUAGE_DATATYPE = 204; const unsigned short NONPOSITIVEINTEGER_DATATYPE = 205; const unsigned short NEGATIVEINTEGER_DATATYPE = 206; const unsigned short LONG_DATATYPE = 207; const unsigned short INT_DATATYPE = 208; const unsigned short SHORT_DATATYPE = 209; const unsigned short BYTE_DATATYPE = 210; const unsigned short NONNEGATIVEINTEGER_DATATYPE = 211; const unsigned short UNSIGNEDLONG_DATATYPE = 212; const unsigned short UNSIGNEDINT_DATATYPE = 213; const unsigned short UNSIGNEDSHORT_DATATYPE = 214; const unsigned short UNSIGNEDBYTE_DATATYPE = 215; const unsigned short POSITIVEINTEGER_DATATYPE = 216; const unsigned short OTHER_SIMPLE_DATATYPE = 1000; const unsigned short COMPLEX_DATATYPE = 1001; };
An integer indicating which datatype this is.
ANYURI_DATATYPE
BASE64BINARY_DATATYPE
BOOLEAN_DATATYPE
BYTE_DATATYPE
COMPLEX_DATATYPE
DATETIME_DATATYPE
DATE_DATATYPE
DECIMAL_DATATYPE
DOUBLE_DATATYPE
DURATION_DATATYPE
ENTITIES_DATATYPE
ENTITY_DATATYPE
FLOAT_DATATYPE
GDAY_DATATYPE
GMONTHDAY_DATATYPE
GMONTH_DATATYPE
GYEARMONTH_DATATYPE
GYEAR_DATATYPE
HEXBINARY_DATATYPE
IDREFS_DATATYPE
IDREF_DATATYPE
ID_DATATYPE
INTEGER
INT_DATATYPE
LANGUAGE_DATATYPE
LONG_DATATYPE
NAME_DATATYPE
NCNAME_DATATYPE
NEGATIVEINTEGER_DATATYPE
NMTOKENS_DATATYPE
NMTOKEN_DATATYPE
NONNEGATIVEINTEGER_DATATYPE
NONPOSITIVEINTEGER_DATATYPE
NORMALIZEDSTRING_DATATYPE
NOTATION_DATATYPE
OTHER_SIMPLE_DATATYPE
POSITIVEINTEGER_DATATYPE
QNAME_DATATYPE
SHORT_DATATYPE
STRING_DATATYPE
TIME_DATATYPE
TOKEN_DATATYPE
UNSIGNEDBYTE_DATATYPE
UNSIGNEDINT_DATATYPE
UNSIGNEDLONG_DATATYPE
UNSIGNEDSHORT_DATATYPE
dataType
of type
unsigned short
, readonlyThe element name along with the content specification in the
context of an ASObject
.
interface ASElementDecl : ASObject { // CONTENT_MODEL_TYPES const unsigned short EMPTY_CONTENTTYPE = 1; const unsigned short ANY_CONTENTTYPE = 2; const unsigned short MIXED_CONTENTTYPE = 3; const unsigned short ELEMENTS_CONTENTTYPE = 4; attribute boolean strictMixedContent; attribute ASDataType elementType; attribute boolean isPCDataOnly; attribute unsigned short contentType; attribute ASContentModel ASContentModel; attribute ASNamedObjectMap ASAttributeDecls; void addASAttributeDecl(in ASAttributeDecl attributeDecl); ASAttributeDecl removeASAttributeDecl(in ASAttributeDecl attributeDecl); };
A code representing the type of content model.
ANY_CONTENTTYPE
ELEMENTS_CONTENTTYPE
EMPTY_CONTENTTYPE
MIXED_CONTENTTYPE
isPCDataOnly
would also need to checked, in
addition to this, if an element's content model was simply text, as
an example.ASAttributeDecls
of type ASNamedObjectMap
ASNamedObjectMap
containing
ASAttributeDecls
for all the attributes that can
appear on this type of element.ASContentModel
of type
ASContentModel
contentType
of type unsigned short
elementType
of type
ASDataType
isPCDataOnly
of type boolean
true
if the element is of type PCDATA only. Relevant
only for mixed content type elements.strictMixedContent
of type boolean
addASAttributeDecl
ASAttributeDecl
for the element being declared.
attributeDecl
of type
ASAttributeDecl
ASModel
and
ASContentModel
should be kept in sync after this
operation.
removeASAttributeDecl
ASAttributeDecl
from the element being declared.
attributeDecl
of type
ASAttributeDecl
|
The content model of a declared element.
interface ASContentModel : ASObject { const unsigned long AS_UNBOUNDED = MAX_VALUE; // ASContentModelType const unsigned short AS_SEQUENCE = 0; const unsigned short AS_CHOICE = 1; const unsigned short AS_ALL = 2; const unsigned short AS_NONE = 3; const unsigned short AS_UNDEFINED = 4; attribute unsigned short listOperator; attribute unsigned long minOccurs; attribute unsigned long maxOccurs; attribute ASObjectList subModels; void removesubModel(in ASObject oldObject); ASObject insertBeforeSubModel(in ASObject newObject, in ASObject refObject) raises(ASException); unsigned long appendsubModel(in ASObject newObject) raises(ASException); };
MAX_VALUE
value is 0xFFFFFFFF FFFFFFFF
.
An integer indicating which type of ASContentModel
this is.
AS_ALL
AS_CHOICE
AS_NONE
AS_SEQUENCE
AS_UNDEFINED
listOperator
of type unsigned short
AS_CHOICE
, AS_SEQUENCE
,
AS_ALL
or AS_NONE
. The operator is
applied to all the components(ASObjects) 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
0
, a positive integer, or AS_UNBOUNDED
to
indicate that no upper limit has been set.minOccurs
of type unsigned long
subModels
of type ASObjectList
ASObject
s
such as ASElementDecl
s and further
ASContentModel
s.appendsubModel
subModels
.
newObject
of type ASObject
|
the length of the |
DUPLICATE_NAME_ERR:Raised if a element declaration already
exists with the same name within an TYPE_ERR:Raised if type is neither an
|
insertBeforeSubModel
The object being inserted. |
DUPLICATE_NAME_ERR:Raised if a element declaration already
exists with the same name within an TYPE_ERR:Raised if type is neither an
|
removesubModel
An attribute declaration in the context of a ASObject
.
interface ASAttributeDecl : ASObject { // VALUE_TYPES const unsigned short NONE = 0; const unsigned short DEFAULT = 1; const unsigned short FIXED = 2; const unsigned short REQUIRED = 3; attribute ASDataType DataType; attribute DOMString DataValue; attribute DOMString enumAttr; attribute ASObjectList ownerElements; attribute unsigned short defaultType; };
DataType
of type
ASDataType
DataValue
of type
DOMString
null
if there is
none.defaultType
of type
unsigned short
enumAttr
of type
DOMString
ownerElements
of type
ASObjectList
ASObject
of attribute, meaning that an attribute declaration can be shared
by multiple elements.Models a general entity declaration in an abstract schema.
interface ASEntityDecl : ASObject { // EntityType const unsigned short INTERNAL_ENTITY = 1; const unsigned short EXTERNAL_ENTITY = 2; attribute unsigned short entityType; attribute DOMString entityValue; attribute DOMString systemId; attribute DOMString publicId; };
An integer indicating which type of entity this is.
EXTERNAL_ENTITY
INTERNAL_ENTITY
entityType
of type unsigned short
INTERNAL_ENTITY
or
EXTERNAL_ENTITY
.entityValue
of type DOMString
EXTERNAL_ENTITY
this is
null
.publicId
of
type DOMString
null
otherwise.systemId
of
type DOMString
null
otherwise.This interface represents a notation declaration.
interface ASNotationDecl : ASObject { attribute DOMString systemId; attribute DOMString publicId; };
This section contains "Validation and Other" methods common to
both the document-editing and AS-editing worlds
(DOMImplementation
methods).
This interface extends the Document
interface with
additional methods for both document and AS editing.
interface DocumentAS : Document { attribute ASModel activeASModel; attribute ASObjectList boundASModels; ASModel getInternalAS(); void setInternalAS(in ASModel as) raises(DOMException); void addAS(in ASModel as); void removeAS(in ASModel as); ASElementDecl getElementDecl() raises(DOMException); void validate() raises(ASException); };
activeASModel
of type ASModel
ASModel
.
Validation is responsible for not only validating the document
instance against the active external ASModel
but also for consulting the internal ASModel
,
so if an attribute is declared in the internal ASModel
and the corresponding ownerElements
points to a ASElementDecl
s
defined in the active external ASModel
,
changing the active external ASModel
will cause the ownerElements
to be recomputed during
the validation of the document instance. If the
ownerElements
is not defined in the newly active
external ASModel
,
the ownerElements
will be an empty object list.boundASModels
of type ASObjectList
ASObject
s
of type AS_MODEL
s associated with a document. The
addAS
method associates an ASModel
with a document.addAS
getElementDecl
ASElementDecl object if the implementation supports AS-EDIT
feature. Otherwise |
|
NOT_FOUND_ERR: Raised if no |
getInternalAS
removeAS
setInternalAS
validate
ASModel
.
If the document is mutated during validation, a warning will be
issued.
VALIDATION_ERR: Raised if an error occurs when the document is being validated against the abstract schema. |
This interface allows creation of an ASModel
.
It extends the DOMImplementation
interface. An object
that implements DOMImplementationAS
is obtained by
doing a binding specific cast from DOMImplementation
to DOMImplementationAS
.
interface DOMImplementationAS : DOMImplementation { readonly attribute boolean container; attribute DOMString schemaType; ASModel createAS(in boolean NamespaceAware, in DOMString schemaType); };
container
of type boolean
, readonlyschemaType
of type DOMString
This section contains "Document-editing" methods (includes
Node
, Element
, Text
and
Document
methods).
A DOM application may use the hasFeature(feature,
version)
method of the DOMImplementation
interface with parameter values "AS-DOC" and "3.0" (respectively)
to determine whether or not the Document-Editing interfaces of the
Abstract Schemas module are supported by the implementation.
This interface extends the NodeEditAS
interface with additional methods for both document and AS
editing.
interface DocumentEditAS : NodeEditAS { attribute boolean continuousValidityChecking; };
continuousValidityChecking
of type boolean
true
will result in an exception being thrown, i.e.,
VALIDATION_ERR
,
for documents that are invalid at the time of the call. If the
document is invalid, then this attribute will remain
false
. This attribute is false
by
default.This interface extends a Node
from [DOM Level 3
Core] with additional methods for guided document editing.
The expectation is that an instance of the
DOMImplementationAS
interface can be obtained by using
binding-specific casting methods on an instance of the
DOMImplementation
interface when the DOM
implementation supports the feature "AS-DOC
".
interface NodeEditAS : Node { // ASCheckType const unsigned short WF_CHECK = 1; const unsigned short NS_WF_CHECK = 2; const unsigned short PARTIAL_VALIDITY_CHECK = 3; const unsigned short STRICT_VALIDITY_CHECK = 4; boolean canInsertBefore(in Node newChild, in Node refChild); boolean canRemoveChild(in Node oldChild); boolean canReplaceChild(in Node newChild, in Node oldChild); boolean canAppendChild(in Node newChild); boolean isNodeValid(in boolean deep, in unsigned short wFValidityCheckLevel) raises(ASException); };
An integer indicating which type of validation this is.
NS_WF_CHECK
WF_CHECK
.PARTIAL_VALIDITY_CHECK
NS_WF_CHECK
.STRICT_VALIDITY_CHECK
NS_WF_CHECK
.WF_CHECK
canAppendChild
AppendChild
.
newChild
of type
Node
Node
to be appended.
|
|
canInsertBefore
Node::insertBefore
operation would make this document
not partially valid with respect to the currently active AS.
newChild
of type
Node
Node
to be inserted.refChild
of type
Node
Node
.
|
|
canRemoveChild
RemoveChild
.
oldChild
of type
Node
Node
to be removed.
|
|
canReplaceChild
ReplaceChild
.
newChild
of type
Node
Node
.oldChild
of type
Node
Node
to be replaced.
|
|
isNodeValid
deep
of type
boolean
deep
flag on causes the
isNodeValid
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. The
validate
method on the DocumentAS
interface, however, checks to determine whether the entire document
is valid.wFValidityCheckLevel
of
type unsigned short
|
|
NO_AS_AVAILABLE: Exception is raised if the DocumentEditAS
related to this node does not have any active |
This interface extends the Element
interface with
additional methods for guided document editing. An object
implementing this interface must also implement NodeEditAS
interface.
interface ElementEditAS : NodeEditAS { readonly attribute NodeList definedElementTypes; unsigned short contentType(); boolean canSetAttribute(in DOMString attrname, in DOMString attrval); boolean canSetAttributeNode(in Attr attrNode); boolean canSetAttributeNS(in DOMString name, in DOMString attrval, in DOMString namespaceURI); boolean canRemoveAttribute(in DOMString attrname); boolean canRemoveAttributeNS(in DOMString attrname, in DOMString namespaceURI); boolean canRemoveAttributeNode(in Node attrNode); NodeList getChildElements(); NodeList getParentElements(); NodeList getAttributeList(); boolean isElementDefined(in DOMString elemTypeName); boolean isElementDefinedNS(in DOMString elemTypeName, in DOMString namespaceURI, in DOMString name); };
definedElementTypes
of type NodeList
, readonlycanRemoveAttribute
attrname
of type
DOMString
|
|
canRemoveAttributeNS
attrname
of type
DOMString
namespaceURI
of type
DOMString
|
|
canRemoveAttributeNode
attrNode
of type
Node
Attr
node to remove from the attribute
list.
|
|
canSetAttribute
attrname
of type
DOMString
attrval
of type
DOMString
|
|
canSetAttributeNS
setAttributeNS
.
name
of type
DOMString
attrval
of type
DOMString
namespaceURI
of type
DOMString
namespaceURI
of namespace.
|
|
canSetAttributeNode
attrNode
of type
Attr
Node
in which the attribute can possibly be
set.
|
|
contentType
|
Constant for one of |
getAttributeList
NodeList
containing all
the possible Attr
s that can appear with this type of
element.
|
List of possible attributes of this element. |
getChildElements
NodeList
containing the
possible Element
nodes that can appear as children of
this type of element.
|
List of possible children element types of this element. |
getParentElements
NodeList
containing the
possible Element
nodes that can appear as a parent of
this type of element.
|
List of possible parent element types of this element. |
isElementDefined
elemTypeName
is
defined in the currently active AS.
elemTypeName
of type
DOMString
|
A boolean that is |
isElementDefinedNS
elemTypeName
in this
namespace is defined in the currently active AS.
elemTypeName
of type
DOMString
namespaceURI
of type
DOMString
namespaceURI
of namespace.name
of type
DOMString
|
A boolean that is |
This interface extends the NodeEditAS
interface with additional methods for document editing. An object
implementing this interface must also implement NodeEditAS
interface.
interface CharacterDataEditAS : NodeEditAS { readonly attribute boolean isWhitespaceOnly; boolean canSetData(in unsigned long offset, in unsigned long count); boolean canAppendData(in DOMString arg); boolean canReplaceData(in unsigned long offset, in unsigned long count, in DOMString arg); boolean canInsertData(in unsigned long offset, in DOMString arg); boolean canDeleteData(in unsigned long offset, in unsigned long count); };
isWhitespaceOnly
of type boolean
, readonlytrue
if content only whitespace;
false
for non-whitespace.canAppendData
arg
of type
DOMString
|
|
canDeleteData
offset
of type
unsigned long
count
of type
unsigned long
|
|
canInsertData
offset
of type
unsigned long
arg
of type
DOMString
|
|
canReplaceData
offset
of type
unsigned long
count
of type
unsigned long
arg
of type
DOMString
|
|
canSetData
offset
of type
unsigned long
count
of type
unsigned long
|
|
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 3
Core] where we assume that the DocumentType
will
be created before the Document
, which is fine for
newly-constructed documents but not a good match for the order in
which an XML parser encounters this data; being able to "rebind" a
Document
to a new AS, after it has been created may be
desirable.
As noted earlier, questions about whether one can alter the content of the AS via its syntax, via higher-level abstractions, or both, exist. It's also worth noting that many of the editing concepts from the Document tree still apply; users should probably be able to clone part of an AS, remove and re-insert parts, and so on.
In addition to using the abstract schema to validate a document instance, applications would like to be able to use it to guide construction and editing of documents, which falls into the document-editing world. Examples of this sort of guided editing already exist, and are becoming more common. The necessary queries can be phrased in several ways, the most useful of which may be a combination of "what does the DTD allow me to insert here" and "if I insert this here, will the document still be valid". The former is better suited to presentation to humans via a user interface, and when taken together with sub-tree validation may subsume the latter.
It has been proposed that in addition to asking questions about specific parts of the abstract schema, there should be a reasonable way to obtain a list of all the defined symbols of a given type (element, attribute, entity) independent of whether they're valid in a given location; that might be useful in building a list in a user-interface, which could then be updated to reflect which of these are relevant for the program's current state.
Remember that namespaces also weigh in on this issue, in the case of attributes, a "can-this-go-there" may prompt a namespace-well-formedness check and warn you if you're about to conflict with or overwrite another attribute with the same namespaceURI/localName but different prefix, or same nodeName but different namespaceURI.
We have to deal with the fact that "the shortest distance between two valid documents may be through an invalid one". Users may want to know several levels of detail (all the possible children, those which would be valid given what precedes this point, those which would be valid given both preceding and following siblings). Also, once XML Schemas introduce context sensitive validity, we may have to consider the effect of children as well as the individual node being inserted.
The most obvious use for an abstract schema (DTD or XML Schema or any Abstract Schema) is to use it to validate that a given XML document is in fact a properly constructed instance of the document type described by this AS. This again falls into the document-editing world. The XML spec only discusses performing this test at the time the document is loaded into the "processor", which most of us have taken to mean that this check should be performed at parse time. But it is obviously desirable to be able to validate again a document -- or selected subtrees -- at other times. One such case would be validating an edited or newly constructed document before serializing it or otherwise passing it to other users. This issue also arises if the "internal subset" is altered -- or if the whole Abstract Schema changes.
In the past, the DOM has allowed users to create invalid
documents, and assumed the serializer would accept the task of
detecting problems and announcing/repairing them when the document
was written out in XML syntax... or that they would be checked for
validity when read back in. We considered adding validity checks to
the DOM's existing editing operations to prevent creation of
invalid documents, but are currently inclined against this for
several reasons. First, it would impose a significant amount of
computational overhead to the DOM, which might be unnecessary in
many situations, e.g., if the change is occurring in a context
where we know the result will be valid. Second, "the shortest
distance between two good documents may be through a bad document".
Preventing a document from becoming temporarily invalid may impose
a considerable amount of additional work on higher-level code and
users Hence our current plan is to continue to permit editing to
produce invalid DOMs, but provide operations which permit a user to
check the validity of a node on demand. If needed one can use
continuousValidityChecking
flag to ensure that the DOM
remains valid during the editing process.
Note that validation includes checking that ID attributes are unique, and that IDREFs point to IDs which actually exist.
XML defined the "well-formed" (WF) state for documents which are parsed without reference to their DTDs. Knowing that a document is well-formed may be useful by itself even when a DTD is available. For example, users may wish to deliberately save an invalid document, perhaps as a checkpoint before further editing. Hence, the AS feature will permit both full validity checking (see previous section) and "lightweight" WF checking, as requested by the caller, as well as processing entity declarations in the AS even if validation is not turned on. This falls within the document-editing world.
While the DOM inherently enforces some of XML's well-formedness conditions (proper nesting of elements, constraints on which children may be placed within each node), there are some checks that are not yet performed. These include:
In addition, Namespaces introduce their own concepts of well-formedness. Specifically:
namespaceNormalize
operation, which would
create the implied declarations and reconcile conflicts in some
reasonably standardized manner. This may be a major undertaking,
since some DOMs may be using the namespace to direct subclassing of
the nodes or similar special treatment; as with the existing
normalize
method, you may be left with a
different-but-equivalent set of node objects.In the past, the DOM has allowed users to create documents which violate these rules, and assumed the serializer would accept the task of detecting problems and announcing/repairing them when the document was written out in XML syntax. We considered adding WF checks to the DOM's existing editing operations to prevent WF violations from arising, but are currently inclined against this for two reasons. First, it would impose a significant amount of computational overhead to the DOM, which might be unnecessary in many situations (for example, if the change is occurring in a context where we know the illegal characters have already been prevented from arising). Second, "the shortest distance between two good documents may be through a bad document" -- preventing a document from becoming temporarily ill-formed may impose a considerable amount of additional work on higher-level code and users. (Note possible issue for Serialization: In some applications, being able to save and reload marginally poorly-formed DOMs might be useful -- editor checkpoint files, for example.) Hence our current plan is to continue to permit editing to produce ill-formed DOMs, but provide operations which permit a user to check the well-formedness of a node on demand, and possibly provide some of the primitive (e.g., string-checking) functions directly.
The module extends the Document Object Model Load and
Save module to permit to load a Document
using a
specific ASModel
and to load an ASModel
from an URI or DOMInputSource
.
A DOM application may use the hasFeature(feature,
version)
method of the DOMImplementation
interface with parameter values "LS-AS" and "3.0" (respectively) to
determine whether or not the Load and Save for Abstract Schemas
module is supported by the implementation. In order to fully
support this module, an implementation must also support the
"AS-EDIT
" features defined in this specification.
An Abstract Schema parser interface.
ASDOMBuilder
provides an API for parsing Abstract
Schemas and building the corresponding ASModel
tree. The actual ASDOMBuilder can be created by appropriately
casting the object created by an implementation that supports
AS.
interface ASDOMBuilder : ls::DOMBuilder { attribute ASModel abstractSchema; ASModel parseASURI(in DOMString uri, in DOMString schemaType) raises(ASException, DOMSystemException); ASModel parseASInputSource(in ls::DOMInputSource is) raises(ASException, DOMSystemException); };
abstractSchema
of type ASModel
ASModel
associated with a document instance. Note that the parser should
set the one active ASModel
.parseASInputSource
DOMInputSource
.
is
of type
ls::DOMInputSource
DOMInputSource
from which the source Abstract Schema is to be read.
Exceptions raised by WRONG_MIME_TYPE_ERR: Raised when |
|
|
Exceptions raised by |
parseASURI
uri
of type
DOMString
schemaType
of type
DOMString
null
if
the implementation can infer a schema type.
The newly created |
Exceptions raised by Raise a WRONG_MIME_TYPE_ERR when |
|
|
Exceptions raised by |
A Abstract Schema serialization interface.
DOMASWriters provides an API for serializing Abstract Schemas out in the form of a source Abstract Schema. The Abstract Schema is written to an output stream, the type of which depends on the specific language bindings in use.
DOMASWriter is a generic Abstract Schema serialization
interface. It can be applied to both an internal Abstract Schema
and/or an external Abstract Schema. DOMASWriter is applied to
serialize a single Abstract Schema. Serializing a document with an
active Internal Abstract Schema will serialize this internal
Abstract Schema with the document as it is part of the Document
(see DOMWriter
).
interface DOMASWriter : ls::DOMWriter { void writeASModel(in DOMOutputStream destination, in ASModel model) raises(DOMSystemException); };
writeASModel
destination
of type
DOMOutputStream
model
of type ASModel
|
This exception will be raised in response to any sort of IO or system error that occurs while writing to the destination. It may wrap an underlying system exception. |