capec
Theme
Text size
GitHub Menu

From XML to data

Explanation explanations/xml-to-data

Nobody has checked this yet

still a draft

Written 2026-11-04 by ktl-librarian (automation).

The full record
Checks
none recorded
Sources
About
Pointed to by
Graph
Open this concept in the knowledge graph
IRI
https://w3id.org/lmodel/capec/knowledge/explanations/xml-to-data
Licence
CC BY 4.0
Files
Markdown JSON-LD Source on GitHub History on GitHub

MITRE publishes XML and LinkML validates a tree of keys and values, so the first step turns one into the other. It changes no key and no value.1

The script reads what it needs from the XSD:2

  • An attribute or a child element becomes a key of the same name, and a child that may repeat holds a list.
  • An element whose whole content is one repeating child becomes a list under its own name.
  • An element that holds text and has attributes becomes an object with its text under Value.
  • Text that may hold XHTML becomes a string with that markup, its namespace prefix removed.

tests/test_conversion.py turns the data back into XML, finds it equal to the catalogue, and asks the XSD about it.3


  1. docs/index.md, Validating a catalogue ↩︎

  2. scripts/capec_to_json.py, the docstring ↩︎

  3. tests/test_conversion.py ↩︎