DOM XML Checking

Working Draft

This Version
<http://suika.fam.cx/www/markup/selectors/ssft/ssft>
Latest Version
<http://suika.fam.cx/www/markup/selectors/ssft/ssft>
Version History
<http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.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 Whatpm subproject 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.

...

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.

Algorithms

The following algorithms and definitions are applied to XML documents; especially, they are not applied to HTML documents.

If a Document node has no xml-well-formedness-error, entity-error, and unknown-error, then it is well-formed. If a well-formed Document node has no xml-validity-error, it is valid.

A well‐formed Document can be safely serialized into a well‐formed XML document. A valid Document can be easily serialized into a valid XML document.

Errors are classified into these error categories:

entity-error
@@
round-trip-error
@@
unknown-error?
@@
xml-misc-error
An XML error (XML 1.0 [XML10] error / XML 1.1 [XML11] error) that is not classified to any other error category.
xml-misc-fatal-error
An XML fatal error (XML 1.0 [XML10] fatal error / XML 1.1 [XML11] fatal error) that is not classified to any other error category. @@ What errors fall into this category?
xml-validity-error
A violation of validity constraint in XML document.
xml-well-formedness-error

If an xml-well-formedness-error is raised, it would not be possible to generate an XML serialization that would match to the appropriate production rule and that would not violate to any well‐formedness constraint in XML specification [XML10, XML11].

@@ TODO: #dt-atuseroption at user option (MAY or MUST), #dt-compat for compatibility, #dt-interop for interoperability

The XML version of a node is the XML version of the document to which the node belongs. For a Documemt node, the XML version of the document is the value of the xmlVersion attribute. For a DocumentType node whose ownerDocument is set to null, the XML version of the document is 1.0. For any other node, the XML version of the document is that of the Document node contained in the ownerDocument attribute of the node.

The algorithm to check a node (n) is defined as following:

If n is an Attr node
  1. Validate the localName attribute value as an NCName.
  2. If the prefix attribute value is different from null, then validate the prefix attribute value as an NCName.
  3. If the childNodes list of n contains a node which is not Text or EntityReference node, then it is a xml-well-formedness-error.
  4. If the childNodes list of n contains an EntityReference node, it is an entity-error.
  5. Check each node which is different from EntityReference in childNodes list of n recursively.
  6. @@ specified, manakaiAttributeType
If n is an AttributeDefinition node
If n is a CDATASection node
  1. Validate the data attribute value as an XML character data.
  2. If the data attribute value contains a string ]]>, then it is a xml-well-formedness-error.
  3. If the childNodes list of n contains any nodes, they are in xml-well-formedness-errors.
If n is a Comment node
  1. Validate the data attribute value as an XML character data.
  2. If the data attribute value contains a string --, or if it ends with a character -, then it is a xml-well-formedness-error.
  3. If the childNodes list of n contains any nodes, they are in xml-well-formedness-errors.
If n is a Document node
  1. If XML version of n is different from 1.0 or 1.1, then it is an unknown-error?.
  2. If the xmlEncoding attribute value does not match to [A-Za-z] ([A-Za-z0-9._] | '-')* @@ formal def, then it is a xml-well-formedness-error.
  3. The childNodes list of n have to consist of zero or more Comment and/or ProcessingInstruction nodes, followed by an optional DocumentType node, followed by zero or more Comment and/or ProcessingInstruction nodes, followed by an Element node, followed by zero or more Comment and/or ProcessingInstruction nodes. Any violation to this is a xml-well-formedness-error.
  4. Check each node which is different from EntityReference in childNodes list of n recursively.
  5. @@ allDeclarationsProcessed
If n is a DocumentFragment node
  1. If the childNodes list of n contains a node which is not Element, Text, CDATASection, Comment, ProcessingInstruction, or EntityReference node, then it is a xml-well-formedness-error.
  2. If the childNodes list of n contains an EntityReference node, it is an entity-error.
  3. Check each node which is different from EntityReference in childNodes list of n recursively.
If n is a DocumentType node
  1. Validate the nodeName attribute value as an NCName.
  2. If the publicId attribute value contains any character that is outside of the range of #x20 | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%], or contains a leading U+0020 character, a trailing U+0020 character, or a sequence of two or more U+0020 characters, then it is a xml-well-formedness-error.
  3. If the systemId attribute value contains both " and ' characters, it is a xml-well-formedness-error.
  4. If the childNodes list of n contains a node which is not ProcessingInstruction node, then it is a xml-well-formedness-error. @@ ref to manakai's extensions
  5. Check each node which is different from EntityReference in childNodes list of n recursively.
  6. @@ entities, notations, elementTypes, externally declared?
If n is an Element node
  1. Validate the localName attribute value as an NCName.
  2. If the prefix attribute value is different from null, then validate the prefix attribute value as an NCName.
  3. If the childNodes list of n contains a node which is not Element, Text, CDATASection, Comment, ProcessingInstruction, or EntityReference node, then it is a xml-well-formedness-error.
  4. If the childNodes list of n contains an EntityReference node, it is an entity-error.
  5. Check each node which is different from EntityReference in childNodes list of n recursively.
If n is an ElementTypeDefinition node
If n is an Entity node
  1. An entity-error @@ if !notationName.
  2. Validate the nodeName attribute value as an NCName.
  3. If the publicId attribute value contains any character that is outside of the range of #x20 | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%], or contains a leading U+0020 character, a trailing U+0020 character, or a sequence of two or more U+0020 characters, then it is a xml-well-formedness-error.
  4. If the systemId attribute value contains both " and ' characters, it is a xml-well-formedness-error.
  5. @@ notationName
  6. If the childNodes list of n contains a node which is not Element, Text, CDATASection, Comment, ProcessingInstruction, or EntityReference node, then it is a xml-well-formedness-error.
  7. If the childNodes list of n contains an EntityReference node, it is an entity-error.
  8. Check each node which is different from EntityReference in childNodes list of n recursively.
If n is an EntityReference node
  1. An entity-error.
  2. Validate the nodeName attribute value as an NCName.
  3. If the childNodes list of n contains a node which is not Element, Text, CDATASection, Comment, ProcessingInstruction, or EntityReference node, then it is a xml-well-formedness-error.
  4. If the childNodes list of n contains an EntityReference node, it is an entity-error.
  5. Check each node which is different from EntityReference in childNodes list of n recursively.
If n is a Notation node
  1. Validate the nodeName attribute value as an NCName.
  2. If the publicId attribute value contains any character that is outside of the range of #x20 | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%], or contains a leading U+0020 character, a trailing U+0020 character, or a sequence of two or more U+0020 characters, then it is a xml-well-formedness-error.
  3. If the systemId attribute value contains both " and ' characters, it is a xml-well-formedness-error.
  4. If the childNodes list of n contains any nodes, they are in xml-well-formedness-errors.
If n is a ProcessingInstruction node
  1. Validate the target attribute value as an NCName.
  2. If the target attribute value matches to XML case-insensitively, then it is a xml-well-formedness-error.
  3. Validate the data attribute value as an XML character data.
  4. If the data attribute value contains a string ?>, or starts with either U+0009, U+000A, U+000D, or U+0020 character, then it is a round-trip-error.
  5. If the childNodes list of n contains any nodes, they are in xml-well-formedness-errors.
If n is a Text node
  1. Validate the data attribute value as an XML character data.
  2. If the childNodes list of n contains any nodes, they are in xml-well-formedness-errors.
Otherwise
xml-well-formedness-error? unknown-error?

The algorithm to validate an XML character data (s) is defined as following:

  1. @@

The algorithm to validate a Name (name) is defined as following:

  1. @@

The algorithm to validate an NCName (name) is defined as following:

  1. @@

Examples

This section is non‐normative.

...
...

References

Normative References

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