Ragnarok: An Experimental XML environment

XML has a highly reliable, consistent, widely-supported ecosystem. Python is enormously popular, yet (perhaps surprisingly) its support for XML has weaknesses. Several parsers are available but most (including the “official” xml.parsers.expat) are not native Python, leading to issues with Python development tools. The Python DOM library (xml.dom.minidom) is native, but is barely DOM 2.0, slow, and lacks conveniences well-established elsewhere. It is also not “Pythonic,” using few modern Python features and idioms. lxml is admirably Pythonic for Elements, but text poses problems. Ragnarok is a new, pure Python XML tool suite that addresss these issues. It provides plug-compatible replacements for Python XML libraries, and is equipped with many Pythonic conveniences (the “batteries included” philosophy of Python). The parser ( Thor ), uses recursive decent: methods map directly to the XML grammar, easing debugging and extension. A validator ( Heimdall ) is in progress. Schemera handles DTDs, but its architecture is more like XML Schema. The DOM library ( Dominµs , aka Yggdrasil ) is much faster than minidom, with almost all of DOM 3 Core and many features drawn from other XML and HTML tools and from Python practice. Flexible output serializing comes via components called Gleipnir and Bifrost . Non-hierarchical structures have long been of interest to this community, but face a dilemma because XML doesn’t really support them: one can coerce to XML syntax via milestones or standoff markup; or create entirely new syntax. In either case XML tools give little help. Beside Thor, Ragnarok also includes a second parser, called Loki , which explores a middle way. Loki accepts non-hierarchical structures via syntax that includes non-XML extensions, but remains so similar that (a) no prior WF XML changes meaning, and (b) the implementation is easily constructed on top of a regular parser. This may enhance data and code re-use. Loki is a subclass (rather than brother) of Thor, and like its namesake can change its shape. Loki can be configured with many XML-adjacent options ranging from case-folding names or enabling named character entities (both difficult with many other tools), on up to extensions for olists, suspend/resume, and milestone-encoded structures. Ragnarok overall can help with everyday XML tasks in Python by being faster, more up-to-date, more Pythonic, and more fully functional. On the other hand, Loki can help with overlap and a variety of other tasks at the edge.

Authors

Publication Details

Journal
Balisage series on markup technologies
Published
2025-07-26
DOI
https://doi.org/10.4242/balisagevol30.derose01
Primary Topic
Web Data Mining and Analysis
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Ragnarok: An Experimental XML environment

Steven J. DeRose
Balisage series on markup technologies
Web Data Mining and Analysis
article

Ragnarok: An Experimental XML environment

Steven J. DeRose
article en

Abstract

XML has a highly reliable, consistent, widely-supported ecosystem. Python is enormously popular, yet (perhaps surprisingly) its support for XML has weaknesses. Several parsers are available but most (including the “official” xml.parsers.expat) are not native Python, leading to issues with Python development tools. The Python DOM library (xml.dom.minidom) is native, but is barely DOM 2.0, slow, and lacks conveniences well-established elsewhere. It is also not “Pythonic,” using few modern Python features and idioms. lxml is admirably Pythonic for Elements, but text poses problems. Ragnarok is a new, pure Python XML tool suite that addresss these issues. It provides plug-compatible replacements for Python XML libraries, and is equipped with many Pythonic conveniences (the “batteries included” philosophy of Python). The parser ( Thor ), uses recursive decent: methods map directly to the XML grammar, easing debugging and extension. A validator ( Heimdall ) is in progress. Schemera handles DTDs, but its architecture is more like XML Schema. The DOM library ( Dominµs , aka Yggdrasil ) is much faster than minidom, with almost all of DOM 3 Core and many features drawn from other XML and HTML tools and from Python practice. Flexible output serializing comes via components called Gleipnir and Bifrost . Non-hierarchical structures have long been of interest to this community, but face a dilemma because XML doesn’t really support them: one can coerce to XML syntax via milestones or standoff markup; or create entirely new syntax. In either case XML tools give little help. Beside Thor, Ragnarok also includes a second parser, called Loki , which explores a middle way. Loki accepts non-hierarchical structures via syntax that includes non-XML extensions, but remains so similar that (a) no prior WF XML changes meaning, and (b) the implementation is easily constructed on top of a regular parser. This may enhance data and code re-use. Loki is a subclass (rather than brother) of Thor, and like its namesake can change its shape. Loki can be configured with many XML-adjacent options ranging from case-folding names or enabling named character entities (both difficult with many other tools), on up to extensions for olists, suspend/resume, and milestone-encoded structures. Ragnarok overall can help with everyday XML tasks in Python by being faster, more up-to-date, more Pythonic, and more fully functional. On the other hand, Loki can help with overlap and a variety of other tasks at the edge.

Balisage series on markup technologiesVol. 30
Openalex Percentile: Top 49%
Web Data Mining and Analysis
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.