Skip to content

Preserve CDATA sections as first-class DOM nodes #30

Description

@FlorianRappl

Description

Change XML tree construction so CDATA tokens can be represented as CDATASection nodes instead of always being flattened into text nodes.

Proposed behavior:

  • when parsing CDATA, create CDATASection nodes
  • preserve CDATA lexical boundaries where possible for round-tripping
  • ensure serializer can emit CDATA safely and predictably

Background

User scenarios include:

  • editing documents where CDATA form is semantically important for downstream systems
  • deterministic round-tripping in content pipelines
  • authoring XML where escaped text and CDATA must remain distinguishable

Flattening CDATA to text is often acceptable for pure infoset processing, but many practical XML workflows depend on lexical fidelity.

Specification

Relevant specifications:

  • W3C XML 1.0 (Fifth Edition), section 2.7 CDATA Sections
  • DOM Standard and legacy DOM Core treatment of CDATASection as a CharacterData subtype

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions