Pure-Veko YAML 1.2 subset parser/serializer, XML/XHTML DOM & query helpers, RSS 2.0, and Atom 1.0 feed codecs.
Pure-Veko YAML 1.2, XML 1.0, RSS 2.0, and Atom 1.0 parser, query engine, and serializer suite.
data_formats provides zero-dependency, deterministic codecs for structured configuration, markup documents, and syndication feeds:
data_formats/yaml: Indentation-aware YAML 1.2 Core Schema parser and canonical emitter supporting nested mappings (key: val), sequences (- item, including Kubernetes-style compact maps under - ), inline flow collections ([a, b], {k: v}), single- and double-quoted strings with escapes, literal (|, |-, |+) and folded (>, >-, >+) multiline block scalars, # comments, ---/... document markers, bool, i64 (decimal & hex), f64, and null/~ mapped to .null.data_formats/xml: Recursive-descent XML 1.0 parser, tree query helpers, single-pass entity codec (&, <, >, ", ', decimal &#...;, hex &#x...;), <![CDATA[...]]> preservation, namespace-aware tag queries, and pretty/compact serializer, plus full RSS 2.0 and Atom 1.0 (RFC 4287) feed builders and parsers.data_formats: Unified facade re-exporting YAML, XML, RSS 2.0, and Atom 1.0 entrypoints from a single import.veko pkg add data_formats@1.0.0Import the unified facade or individual submodules:
use [
df = data_formats
yaml = data_formats/yaml
xml = data_formats/xml
]data_formats, data_formats/yaml, and data_formats/xml operate purely in memory with zero filesystem, clock, or network capability requirements.data_formats/xml skips <!DOCTYPE ...> prologs without resolving external entities or recursive DTD entity macros, eliminating XML External Entity (XXE) and quadratic entity expansion vectors by construction.&lt; decodes strictly to '<' and is never double-unescaped into markup.err with 1-based line numbers, and yaml/encode + xml/render sort map/attribute keys deterministically in byte-lexicographic order.data_formats/yaml| Signature | Description |
|---|---|
decode = fn [src str] any | Parses YAML 1.2 text into Veko map, block, str, i64, f64, bool, or .null. |
encode = fn [val any] str | Serializes a Veko value into canonical 2-space indented YAML 1.2 text. |
data_formats/xml| Type / Signature | Description |
|---|---|
XmlNode = struct { tag str, attrs map[str] = {}, children block = [], text str = '' } | Element node in an XML 1.0 tree. |
RssItem, RssChannel | Structured RSS 2.0 item and channel definitions. |
AtomEntry, AtomFeed | Structured RFC 4287 Atom 1.0 entry and feed definitions. |
parse = fn [src str] XmlNode | Parses an XML 1.0 document (stripping BOM, prolog, DOCTYPE, and comments). |
render = fn [node XmlNode /pretty pretty bool = false /decl with_decl bool = false] str | Renders an XmlNode tree to XML 1.0 text. |
find-first = fn [node XmlNode, tag str] XmlNode | Depth-first search for the first element matching tag (or err if absent). |
find-all = fn [node XmlNode, tag str] block[XmlNode] | Collects all elements matching tag in document order. |
child-text = fn [node XmlNode, tag str] str | Returns the text of the first direct child matching tag (or ''). |
attr = fn [node XmlNode, name str, default_val str] str | Returns attribute name or default_val. |
escape-text = fn [s str] str / escape-attr = fn [s str] str / unescape = fn [s str] str | XML 1.0 entity escaping and unescaping helpers. |
build-rss = fn [ch RssChannel] str / parse-rss = fn [xml_str str] RssChannel | Builds and parses RSS 2.0 XML feeds. |
build-atom = fn [feed AtomFeed] str / parse-atom = fn [xml_str str] AtomFeed | Builds and parses Atom 1.0 XML feeds. |
data_formats (Facade)Re-exports yaml-decode, yaml-encode, xml-parse, xml-render, xml-find-first, xml-find-all, xml-child-text, xml-attr, xml-escape, xml-unescape, build-rss, parse-rss, build-atom, and parse-atom.
use [yaml = data_formats/yaml]
raw = '
apiVersion: apps/v1
kind: Deployment
metadata:
name: veko-worker
spec:
replicas: 4
containers:
- name: worker
image: ghcr.io/veko-lang/worker:1.0.0
ports: [8080, 9090]
'
manifest = yaml/decode/or raw [e ->
println `Invalid YAML: {mold e}`
return e
]
spec = map/get manifest 'spec'
println `Replicas: {map/get spec 'replicas'}`
println (yaml/encode manifest)use [xml = data_formats/xml]
doc = xml/parse '<project name="veko"><module>yaml</module><module>xml</module></project>'
mods = xml/find-all doc 'module'
println `Project {xml/attr doc 'name' ''} has {len mods} modules`
feed_xml = xml/build-atom (xml/AtomFeed {
id = 'urn:veko:releases'
title = 'Veko Releases'
updated = '2026-12-05T00:00:00Z'
link = 'https://veko-lang.org/atom.xml'
author_name = 'Veko Team'
entries = [
(xml/AtomEntry {
id = 'urn:veko:1.0.0'
title = 'Veko 1.0.0'
updated = '2026-12-05T00:00:00Z'
link = 'https://veko-lang.org/releases/1.0.0'
summary = 'Initial 1.0 release.'
})
]
})
println feed_xmlveko check --strict-types packages/data_formats/src/yaml.vk
veko check --strict-types packages/data_formats/src/xml.vk
veko check --strict-types packages/data_formats/src/mod.vk
veko check packages/data_formats/examples/demo.vk
veko run -C all packages/data_formats/examples/demo.vkhttps://veko-lang.org/pkg/data_formats/1.0.0.vkp2f0c1557ddb761735edd4d8ac3d2f96564383ee682578106d3643db56ed871cc202839c7c97d16b42c924c483bbdf1bb797494aba7f6661d73b3607a4d6451b1ed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70{"name":"data_formats","version":"1.0.0","tier":1.0,"tier_label":"Tier 1: Backend Essentials","category":"YAML, XML & Syndication","description":"Pure-Veko YAML 1.2 subset parser/serializer, XML/XHTML DOM & query helpers, RSS 2.0, and Atom 1.0 feed codecs.","modules":["data_formats","data_formats/xml","data_formats/yaml"],"homepage":"https://veko-lang.org/packages/data_formats"}| Bundle Entry Path | Size | Leaf SHA-256 Digest |
|---|---|---|
| README.md | 6 KB | 6f7697041f86e0af1448eb95ab5c2a80aae3bd394eb2aad13cd20268fcdef2cc |
| examples/demo.vk | 9 KB | 58f9f4f79219e808ce46b86eb4a0b522e96d111142ffca59b2e1823d53eb8157 |
| mod.vk | 1 KB | 03e7171127f3d23866205ef5a734157204bbd0043f4d7572f2e5a4ccd1286b53 |
| xml.vk | 20 KB | 5f9afd928c766a13b021527fa5ef4d4b2061cd25b167982367e0627ce1ed21eb |
| yaml.vk | 22 KB | 786c6175bc20e41a16b6484fd3c7e27d022495a99596e92d65f78a44566b63f2 |