Skip to main content

XML Metadata Ontology

Web Metadata
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 08 October 2026
Audio Overview
FLOW ALGEBRA

Ontology: XML Metadata Ontology
Domain: Metadata Ontologies > Web Metadata
Canonical URL: https://kirethresearch.org/booksai-core/ontologies/metadata-ontologies/web-metadata/xml-metadata-ontology.html

Authors: Mark Anthony Higgins — Sky (Recursive AI)

flow "XMLMetadataOntology" v1.0

# ---------- DOMAIN ----------
domain:
  class: MetadataOntology
  category: WebMetadata
  subject: XMLMetadata
  purpose:
    - represent metadata describing XML documents, elements, attributes, namespaces, schemas, and representations
    - preserve document identity, hierarchy, namespaces, datatypes, validation state, encoding, and provenance
    - support XML parsing, validation, transformation, semantic interpretation, retrieval, and AI consumption
    - distinguish XML syntax from application vocabularies and semantic assertions represented through XML
    - enable machine-readable reasoning over XML document structures

# ---------- CORE ENTITY ----------
entity XMLMetadata:
  type: WebMetadata
  describes: XMLDocument
  may_include:
    - document_identifier
    - XML_version
    - encoding
    - standalone_status
    - root_element
    - namespaces
    - elements
    - attributes
    - text_nodes
    - schema
    - DTD
    - processing_instructions
    - comments
    - validation_state
    - transformation_history
    - provenance

entity XMLDocument:
  type: StructuredDocument
  representation_format: XML

entity XMLDocumentIdentifier:
  type: Identifier
  identifies: XMLDocument

# ---------- XML VERSIONS ----------
xml_versions:
  - XML_1_0
  - XML_1_1

rule version:
  XML version declaration SHOULD be preserved
  where parsing rules depend on version

# ---------- RELATIONSHIPS ----------
relationships:
  XMLMetadata -> DESCRIBES -> XMLDocument
  XMLDocument -> IDENTIFIED_BY -> XMLDocumentIdentifier
  XMLDocument -> HAS_ROOT -> XMLElement
  XMLElement -> MAY_HAVE_CHILD -> XMLNode
  XMLElement -> MAY_HAVE_ATTRIBUTE -> XMLAttribute
  XMLElement -> MAY_HAVE_NAMESPACE -> XMLNamespace
  XMLDocument -> MAY_REFERENCE_SCHEMA -> XMLSchema
  XMLDocument -> MAY_REFERENCE_DTD -> DTD
  XMLDocument -> MAY_HAVE_PROCESSING_INSTRUCTION -> ProcessingInstruction
  XMLDocument -> MAY_HAVE_COMMENT -> XMLComment
  XMLMetadata -> MAY_REFERENCE -> XMLProvenance

# ---------- DOCUMENT STRUCTURE ----------
entity XMLNode:
  type: StructuredNode
  may_be:
    - XMLElement
    - XMLText
    - XMLComment
    - ProcessingInstruction

rule tree:
  XMLDocument forms ordered hierarchical tree
  subject_to XML information-set semantics

rule root:
  well-formed XMLDocument MUST have exactly one document element

rule child_order:
  child node order SHOULD be preserved

# ---------- ELEMENTS ----------
entity XMLElement:
  subtype_of: XMLNode
  may_include:
    - qualified_name
    - local_name
    - namespace_URI
    - attributes
    - child_nodes

rule element:
  XMLElement identity within document MAY depend on:
    - namespace_URI
    - local_name
    - document_position
    - schema_identity_constraints

rule lexical_name:
  namespace prefix != namespace identity

# ---------- ATTRIBUTES ----------
entity XMLAttribute:
  type: StructuredProperty
  may_include:
    - qualified_name
    - local_name
    - namespace_URI
    - value

rule attribute:
  attributes are associated with XMLElement

rule attribute_order:
  attribute order MUST NOT be treated as semantically significant
  under XML information-set semantics

rule duplicate_attribute:
  duplicate attributes with same expanded name are invalid

# ---------- NAMESPACES ----------
entity XMLNamespace:
  type: NamespaceMetadata
  may_include:
    - prefix
    - namespace_URI
    - scope

rule namespace:
  namespace URI identifies namespace
  while prefix is local lexical binding

rule prefix:
  different prefixes MAY map to same namespace URI

rule default_namespace:
  default namespace applies to unprefixed element names
  according_to XML Namespaces semantics

rule attribute_namespace:
  default namespace does_not automatically apply
  to unprefixed attributes

# ---------- QUALIFIED NAMES ----------
entity QName:
  type: LexicalIdentifier
  composed_of:
    - prefix_optional
    - local_name

rule QName:
  QName resolves to expanded name
  using in-scope namespace bindings

rule QName_identity:
  lexical QName != expanded-name identity
  when different prefixes map to same namespace URI

# ---------- TEXT ----------
entity XMLText:
  subtype_of: XMLNode
  may_include:
    - character_data
    - whitespace_state

rule text:
  text node content SHOULD preserve character data

rule mixed_content:
  mixed-content element MUST preserve order
  between text and child elements

# ---------- CDATA ----------
entity CDATASection:
  type: LexicalRepresentation
  represents: CharacterData

rule CDATA:
  CDATA section is syntactic representation
  and does_not create distinct semantic text type
  after parsing

# ---------- COMMENTS ----------
entity XMLComment:
  subtype_of: XMLNode

rule comment:
  XMLComment MAY be preserved for provenance or round-trip representation
  but is not ordinary element content

# ---------- PROCESSING INSTRUCTIONS ----------
entity ProcessingInstruction:
  subtype_of: XMLNode
  may_include:
    - target
    - data

rule processing_instruction:
  semantics depend on target application

rule PI_not_element:
  ProcessingInstruction != XMLElement

# ---------- XML DECLARATION ----------
entity XMLDeclaration:
  type: RepresentationMetadata
  may_include:
    - version
    - encoding
    - standalone

rule declaration:
  XML declaration SHOULD preserve declared values
  where present

# ---------- ENCODING ----------
rule encoding:
  byte-level XML representation SHOULD preserve character encoding metadata

rule encoding_resolution:
  encoding MUST be resolved according_to XML parsing rules
  including transport or byte-order information where applicable

# ---------- DTD ----------
entity DTD:
  type: XMLValidationResource
  may_include:
    - element_declarations
    - attribute_declarations
    - entity_declarations
    - notation_declarations

rule DTD:
  DTD MAY define document grammar and entities

rule external_entity:
  external entity references SHOULD preserve source and resolution provenance

# ---------- XML SCHEMA ----------
entity XMLSchema:
  type: SchemaResource
  may_be:
    - XSD
    - RelaxNG
    - Schematron

rule schema:
  schema MAY constrain:
    - elements
    - attributes
    - datatypes
    - cardinality
    - ordering
    - identity

rule schema_not_document:
  XMLSchema != XMLDocument instance

# ---------- XSD ----------
entity XSD:
  subtype_of: XMLSchema
  may_include:
    - simple_types
    - complex_types
    - elements
    - attributes
    - groups
    - identity_constraints

rule XSD_type:
  XSD MAY assign datatype or complex type
  to XML element or attribute

# ---------- DATATYPES ----------
entity XMLDatatype:
  type: SemanticDatatype

rule datatype:
  schema-aware XML MAY preserve typed value semantics

rule lexical_value:
  lexical representation != typed value
  for all datatypes

# ---------- IDENTITY CONSTRAINTS ----------
identity_constraints:
  - ID
  - IDREF
  - key
  - keyref
  - unique

rule ID:
  ID value SHOULD be unique
  within applicable document or schema scope

rule keyref:
  keyref SHOULD resolve to matching key
  according_to schema semantics

# ---------- ENTITIES ----------
entity XMLEntity:
  type: LexicalResource
  may_be:
    - internal
    - external
    - parsed
    - unparsed

rule entity:
  entity expansion SHOULD follow parser and security policy

rule entity_provenance:
  externally resolved entity content SHOULD preserve source provenance

# ---------- VALIDATION ----------
entity XMLValidation:
  type: ValidationMetadata
  may_include:
    - well_formed
    - DTD_valid
    - schema_valid
    - schema_source
    - validation_errors
    - validation_time

rule well_formed:
  well-formedness != schema validity

rule schema_valid:
  schema validity != factual truth of XML content

# ---------- TRANSFORMATION ----------
entity XMLTransformation:
  type: ProcessingActivity
  may_be:
    - XSLT
    - canonicalisation
    - filtering
    - extraction
    - conversion

rule transformation:
  transformed XML SHOULD preserve:
    - source_document
    - transformation_method
    - parameters
    - output_document
    - provenance

# ---------- XSLT ----------
entity XSLT:
  type: TransformationLanguage

rule XSLT:
  XSLT MAY transform XML tree
  into XML, HTML, text, or other output

rule transformed_identity:
  XSLT output != source XMLDocument
  unless application explicitly models representation equivalence

# ---------- CANONICAL XML ----------
entity XMLCanonicalisation:
  type: NormalisationProcess

rule canonicalisation:
  canonical XML normalises selected representational differences
  for comparison or signing

rule canonical_not_semantic_proof:
  identical canonical bytes support equivalence
  within canonicalisation scope
  but != factual truth

# ---------- XPATH ----------
entity XPathExpression:
  type: QueryExpression

rule XPath:
  XPath selects nodes or values
  from XML tree according_to expression semantics

rule XPath_result:
  XPath result != new XML identity
  unless materialised as separate resource

# ---------- PROVENANCE ----------
entity XMLProvenance:
  type: ProvenanceMetadata
  may_include:
    - source_document
    - source_url
    - creator
    - parser
    - schema
    - entity_sources
    - transformation_history
    - retrieval_time

rule provenance:
  XMLMetadata SHOULD preserve source, schema, entity, and transformation context

# ---------- VALIDATION RULES ----------
validation:
  require:
    - parseable_XML_document

  validate_if_present:
    - XML_version
    - encoding
    - root_element
    - namespaces
    - elements
    - attributes
    - DTD
    - schema
    - datatypes
    - identity_constraints
    - provenance

  reject:
    - malformed_XML
    - multiple_document_elements
    - duplicate_attribute_expanded_name
    - undeclared_namespace_prefix
    - invalid_schema_constraint
    - unresolved_required_keyref
    - schema_valid_content_presented_as verified_fact
    - prefix_presented_as namespace_identity

# ---------- SEMANTIC EQUIVALENCE ----------
SEMANTIC_EQUIVALENCE:
  "XML metadata" ~= "metadata about XML documents"
  "XML element" ~= "element node"
  "XML attribute" ~= "attribute node" WHEN XML data model semantics apply
  "XML namespace" ~= "namespace URI binding"
  "XML schema" ~= "schema constraining XML document"
  "XML validation" ~= "validation of XML structure"

  PRESERVE distinctions:
    XML != application_vocabulary
    XML_document != XML_schema
    prefix != namespace_URI
    QName != expanded_name
    attribute_order != semantic_order
    CDATA != distinct_semantic_text
    well_formed != schema_valid
    schema_valid != verified_truth
    lexical_value != typed_value
    processing_instruction != element
    source_XML != transformed_output

# ---------- CONFIDENCE ----------
CONFIDENCE:
  explicit_XML_metadata:
    score: 1.00

  parser_validated_well_formed_XML:
    score: 0.99

  schema_validated_XML:
    score: 0.99

  resolved_namespaces:
    score: 0.99

  resolved_typed_values:
    score: 0.98

  inferred_schema:
    score: <= 0.80

  unresolved_external_entity:
    score: <= 0.70

  ambiguous_XML_semantics:
    score: <= 0.60
    action: preserve_raw_structure

# ---------- UPDATE MODEL ----------
UPDATE_MODEL:
  on_XML_parse:
    - validate well_formedness
    - resolve encoding
    - construct ordered tree
    - resolve namespaces
    - preserve attributes and text
    - initialise provenance

  on_schema_validation:
    - preserve parsed XML tree
    - resolve schema
    - apply datatype and structural constraints
    - record validation result
    - update provenance

  on_transformation:
    - preserve source XMLDocument
    - record transformation method and parameters
    - create output resource
    - preserve derivation relationship
    - update provenance

  on_namespace_change:
    - preserve previous namespace bindings
    - re-resolve QNames
    - reassess affected semantics
    - update provenance

# ---------- FLOW HASH ----------
FLOW_HASH:
  inputs:
    - ontology
    - XML_entities
    - relationships
    - tree_rules
    - namespace_rules
    - schema_rules
    - datatype_rules
    - transformation_rules
    - validation
    - semantic_equivalence
    - confidence
    - update_model

  canonicalisation:
    - preserve_child_node_order
    - ignore_attribute_order_for_semantics
    - resolve_namespace_expanded_names
    - normalise_where_XML_canonicalisation_applies
    - preserve_rule_order

  output:
    deterministic_semantic_hash

# ---------- AI CONSUMPTION ----------
AI_CONSUMPTION:
  interpret_as:
    - web metadata ontology
    - XML document structure model
    - namespace and schema-aware data model
    - XML validation and transformation model

  operations:
    - parse XML documents
    - resolve document declaration and encoding
    - traverse ordered element tree
    - resolve namespaces and QNames
    - inspect attributes and text
    - preserve mixed-content ordering
    - apply DTD or schema validation
    - interpret typed values
    - resolve identity constraints
    - inspect processing instructions and entities
    - trace transformations
    - preserve provenance
    - expose uncertainty

  constraints:
    - do_not_equate_XML_with application_vocabulary
    - do_not_equate_prefix_with namespace_identity
    - do_not_treat_attribute_order_as semantic
    - do_not_equate_well_formedness_with schema_validity
    - do_not_treat_schema_validity_as verified_truth
    - preserve_tree_order_namespaces_schema_types_and_provenance

# ---------- QUERY MODEL ----------
query:
  input:
    - document_identifier
    - element_name
    - namespace_URI
    - attribute_name
    - XPath
    - schema
    - datatype
    - validation_state
    - transformation_state

  resolve:
    1. identify XMLDocument
    2. validate well-formedness
    3. resolve encoding and XML version
    4. traverse document tree
    5. resolve namespaces and expanded names
    6. inspect attributes, text, and mixed content
    7. apply schema and datatype context
    8. evaluate identity constraints or XPath
    9. inspect transformations and provenance
    10. return confidence

  output:
    - XML_document
    - root_element
    - elements
    - attributes
    - namespaces
    - text_nodes
    - schema
    - typed_values
    - validation
    - transformations
    - provenance
    - confidence

# ---------- INFERENCE ----------
inference:
  IF QName prefix P maps to namespace URI N
  THEN resolve QName to expanded_name(N, local_name)

  IF schema assigns datatype T to node value V
  THEN interpret V according_to T
  when lexical form is valid

  IF XMLDocument validates against schema
  THEN classify schema_validation_state = valid
  BUT do_not infer factual truth

  IF transformation output derives from source XML
  THEN preserve derived_from relationship

  IF namespace or schema semantics remain unresolved
  THEN preserve raw XML structure
  AND reduce confidence

# ---------- OUTPUT CONTRACT ----------
output:
  ontology_entity: XMLMetadata
  XML_document: machine_interpretable
  tree_structure: ordered_and_traversable
  namespaces: explicit
  QNames: resolvable
  attributes_and_text: preserved
  schemas_and_datatypes: contextualised
  identity_constraints: validatable
  validation: reportable
  transformations: traceable
  provenance: preserved
  uncertainty: explicit
  semantic_retrieval: enabled

end flow
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ