Skip to main content

Module validation

Module validation 

Source
Expand description

DTD validation (§27, §85 Phase 6).

DTD validation against element/attribute declarations:

  1. Element content model validation — does the element’s child sequence match its declared content model?
  2. Attribute value validation — does each attribute’s value conform to its declared type (CDATA, ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS, ENUMERATION, NOTATION)?
  3. ID/IDREF consistency — are all ID values unique? Does each IDREF reference a valid ID?
  4. Required attributes — are all REQUIRED attributes present?
  5. NOTATION validation — are NOTATION attributes referencing declared notations?
  6. Well-formedness constraints — additional validity constraints

§UPSTREAM-PARITY

This module follows libxml2’s valid.c implementation. The validation context (xmlValidCtxt) accumulates ID/IDREF tables across the document and checks consistency in xmlValidateDocumentFinal.

§Phase 6 status

Complete — all core DTD validation functions are implemented. Edge-case behavior for degenerate DTDs matches upstream.

Functions§

free_valid_ctxt
Free a validation context.
is_empty_element
Check if an element is declared as EMPTY.
is_mixed_element
Check if an element has a mixed content model.
new_valid_ctxt
Create a new validation context.
set_valid_errors
Set error and warning callbacks on a validation context.
validate_attribute_decl
Validate an attribute’s value against its declaration.
validate_attribute_value
Validate an attribute value against its declared type.
validate_content
Validate the content of an element node against its content model.
validate_document
Validate an entire document against its DTD.
validate_document_final
Final validation: check that all IDREFs resolve to existing IDs.
validate_dtd
Validate a DTD’s declarations (element/attribute declarations).
validate_dtd_final
Final DTD validation — checks ID/IDREF consistency.
validate_element
Validate a single element node against its DTD element and attribute declarations.
validate_enumeration
Validate that value is one of the values in the enumeration.
validate_id
Validate an ID value: check that the value is a valid XML Name and that no duplicate ID values exist in the document.
validate_id_ref
Validate an IDREF value: check that the referenced ID exists in the document.
validate_id_refs
Validate IDREFS (whitespace-separated list of IDREF values).
validate_name
Validate whether value is a valid XML Name.
validate_names
Validate whether value is a whitespace-separated list of XML Names.
validate_nmtoken
Validate whether value is a valid XML NMTOKEN.
validate_nmtokens
Validate whether value is a whitespace-separated list of XML NMTOKENs.
validate_notation_use
Validate that notationName is a declared notation in the document’s DTD.
validate_root
Validate the root element of a document.