← Back to Official Package Registry
Tier 1: Backend Essentials • YAML, XML & Syndicationv1.0.0 • 59 KB • Ed25519 Verified

data_formats@1.0.0

Pure-Veko YAML 1.2 subset parser/serializer, XML/XHTML DOM & query helpers, RSS 2.0, and Atom 1.0 feed codecs.

use [data_formats]use [data_formats/xml]use [data_formats/yaml]
veko pkg add data_formats@1.0.0
Run in Browser PlaygroundDownload 1.0.0.vkpRaw demo.vk

data_formats

Pure-Veko YAML 1.2, XML 1.0, RSS 2.0, and Atom 1.0 parser, query engine, and serializer suite.

Overview

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 (&amp;, &lt;, &gt;, &quot;, &apos;, 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.

Installation

powershell
veko pkg add data_formats@1.0.0

Import the unified facade or individual submodules:

rebol
use [
    df   = data_formats
    yaml = data_formats/yaml
    xml  = data_formats/xml
]

Architecture & Security Notes

  1. Zero Capabilities Required: All parsers, query helpers, and emitters in data_formats, data_formats/yaml, and data_formats/xml operate purely in memory with zero filesystem, clock, or network capability requirements.
  2. No XXE or Billion-Laughs Expansion: 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.
  3. Single-Pass Entity Decoding: XML entity decoding runs in a single linear pass so escaped entity text such as &amp;lt; decodes strictly to '&lt;' and is never double-unescaped into markup.
  4. Strict YAML 1.2 Tab Rejection & Deterministic Key Ordering: Leading tab indentation in YAML block contexts returns a descriptive err with 1-based line numbers, and yaml/encode + xml/render sort map/attribute keys deterministically in byte-lexicographic order.

Complete API Reference

data_formats/yaml

SignatureDescription
decode = fn [src str] anyParses YAML 1.2 text into Veko map, block, str, i64, f64, bool, or .null.
encode = fn [val any] strSerializes a Veko value into canonical 2-space indented YAML 1.2 text.

data_formats/xml

Type / SignatureDescription
XmlNode = struct { tag str, attrs map[str] = {}, children block = [], text str = '' }Element node in an XML 1.0 tree.
RssItem, RssChannelStructured RSS 2.0 item and channel definitions.
AtomEntry, AtomFeedStructured RFC 4287 Atom 1.0 entry and feed definitions.
parse = fn [src str] XmlNodeParses an XML 1.0 document (stripping BOM, prolog, DOCTYPE, and comments).
render = fn [node XmlNode /pretty pretty bool = false /decl with_decl bool = false] strRenders an XmlNode tree to XML 1.0 text.
find-first = fn [node XmlNode, tag str] XmlNodeDepth-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] strReturns the text of the first direct child matching tag (or '').
attr = fn [node XmlNode, name str, default_val str] strReturns attribute name or default_val.
escape-text = fn [s str] str / escape-attr = fn [s str] str / unescape = fn [s str] strXML 1.0 entity escaping and unescaping helpers.
build-rss = fn [ch RssChannel] str / parse-rss = fn [xml_str str] RssChannelBuilds and parses RSS 2.0 XML feeds.
build-atom = fn [feed AtomFeed] str / parse-atom = fn [xml_str str] AtomFeedBuilds 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.

Idiomatic Veko Examples

Parsing & Emitting Kubernetes / CI YAML Manifests

rebol
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)

Querying XML & Building an Atom 1.0 Release Feed

rebol
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_xml

Verification

powershell
veko 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.vk
packages/data_formats/examples/demo.vkSelf-contained runnable example & assertion suite
Raw .vk
// packages/data_formats/examples/demo.vk
// Runnable verification suite for `data_formats` (YAML 1.2, XML 1.0, RSS 2.0, and Atom 1.0).

use [
	df   = data_formats
	yaml = data_formats/yaml
	xml  = data_formats/xml
]

assert-eq = fn [actual any, expected any, label str] any [
	if actual != expected [
		return (err (str/join ['ASSERT FAILED [' label ']: got ' (mold actual) ', expected ' (mold expected)] ''))
	]
	.ok
]

assert-true = fn [cond bool, label str] any [
	if not cond [
		return (err (str/join ['ASSERT FAILED [' label ']'] ''))
	]
	.ok
]

main = fn [] any [
	println '=== data_formats 1.0.0 Verification Suite ==='

	// 1. Kubernetes-style YAML 1.2 Deployment manifest + roundtrip encode/decode
	k8s_yaml = str/join [
		'---\n'
		'# Veko Control Plane Kubernetes Deployment\n'
		'apiVersion: apps/v1\n'
		'kind: Deployment\n'
		'metadata:\n'
		'  name: veko-gateway\n'
		'  namespace: production\n'
		'  labels:\n'
		'    "app.kubernetes.io/name": veko-gateway\n'
		'    "app.kubernetes.io/version": \'1.0.0\'\n'
		'spec:\n'
		'  replicas: 3 # active replicas\n'
		'  paused: false\n'
		'  canaryWeight: 0.25\n'
		'  rollbackTo: ~\n'
		'  architectures: [amd64, arm64]\n'
		'  resources: { cpu: "500m", memory: "256Mi" }\n'
		'  notes: >-\n'
		'    Zero-dependency Veko edge gateway\n'
		'    running on shared-nothing workers.\n'
		'  startupScript: |\n'
		'    #!/bin/sh\n'
		'    exec /bin/veko-gateway --port=8080\n'
		'  containers:\n'
		'    - name: gateway\n'
		'      image: ghcr.io/veko-lang/gateway:1.0.0\n'
		'      readOnlyRoot: true\n'
		'      ports:\n'
		'        - containerPort: 8080\n'
		'          protocol: TCP\n'
		'        - containerPort: 8443\n'
		'          protocol: TCP\n'
		'    - name: metrics\n'
		'      image: ghcr.io/veko-lang/otel:1.0.0\n'
		'      readOnlyRoot: true\n'
		'...\n'
	] ''

	doc = yaml/decode k8s_yaml
	if err? doc [ return doc ]
	r1 = assert-eq (map/get doc 'apiVersion') 'apps/v1' 'yaml apiVersion'
	if err? r1 [ return r1 ]
	meta = map/get doc 'metadata'
	labels = map/get meta 'labels'
	r2 = assert-eq (map/get labels 'app.kubernetes.io/version') '1.0.0' 'yaml quoted version string'
	if err? r2 [ return r2 ]

	spec = map/get doc 'spec'
	r3 = assert-eq (map/get spec 'replicas') 3 'yaml i64 replicas'
	if err? r3 [ return r3 ]
	r4 = assert-eq (map/get spec 'paused') false 'yaml bool paused'
	if err? r4 [ return r4 ]
	r5 = assert-eq (map/get spec 'canaryWeight') 0.25 'yaml f64 canaryWeight'
	if err? r5 [ return r5 ]
	r6 = assert-eq (map/get spec 'rollbackTo') .null 'yaml ~ -> .null'
	if err? r6 [ return r6 ]
	r7 = assert-eq (map/get spec 'architectures') ['amd64' 'arm64'] 'yaml inline flow sequence'
	if err? r7 [ return r7 ]
	res_m = map/get spec 'resources'
	r8 = assert-eq (map/get res_m 'cpu') '500m' 'yaml inline flow map'
	if err? r8 [ return r8 ]
	r9 = assert-eq (map/get spec 'notes') 'Zero-dependency Veko edge gateway running on shared-nothing workers.' 'yaml folded >- block scalar'
	if err? r9 [ return r9 ]
	r10 = assert-eq (map/get spec 'startupScript') '#!/bin/sh\nexec /bin/veko-gateway --port=8080\n' 'yaml literal | block scalar'
	if err? r10 [ return r10 ]

	containers = map/get spec 'containers'
	r11 = assert-eq (len containers) 2 'yaml containers sequence len'
	if err? r11 [ return r11 ]
	c0 = containers[0]
	r12 = assert-eq (map/get c0 'image') 'ghcr.io/veko-lang/gateway:1.0.0' 'yaml unquoted colon in image'
	if err? r12 [ return r12 ]
	ports0 = map/get c0 'ports'
	r13 = assert-eq (map/get ports0[1] 'containerPort') 8443 'yaml nested sequence map port'
	if err? r13 [ return r13 ]

	// Roundtrip YAML encode -> decode
	emitted_yaml = df/yaml-encode doc
	redecoded = df/yaml-decode emitted_yaml
	if err? redecoded [ return redecoded ]
	re_spec = map/get redecoded 'spec'
	re_conts = map/get re_spec 'containers'
	r14 = assert-eq (map/get re_conts[0] 'name') 'gateway' 'yaml roundtrip container name'
	if err? r14 [ return r14 ]
	r15 = assert-eq (map/get re_spec 'startupScript') (map/get spec 'startupScript') 'yaml roundtrip multiline script'
	if err? r15 [ return r15 ]
	r16 = assert-eq (map/get re_spec 'rollbackTo') .null 'yaml roundtrip .null'
	if err? r16 [ return r16 ]
	println '  [PASS] YAML 1.2 Kubernetes manifest decode & canonical roundtrip encode'

	// 2. XML 1.0 namespaces, prolog, comments, entities, numeric refs & CDATA
	xml_src = str/join [
		'<?xml version="1.0" encoding="UTF-8"?>\n'
		'<!-- Configuration & Catalog -->\n'
		'<catalog xmlns="https://veko-lang.org/ns/catalog" xmlns:dc="http://purl.org/dc/elements/1.1/" region="eu-west-1">\n'
		'  <dc:creator>Veko &amp; Contributors &#x41;&#66;</dc:creator>\n'
		'  <service id="gw-1" tls="true">\n'
		'    <title>Edge &lt;Gateway&gt; &quot;v1&quot;</title>\n'
		'    <filter><![CDATA[latency_ms < 50 && status == "ok"]]></filter>\n'
		'  </service>\n'
		'  <service id="gw-2" tls="true">\n'
		'    <title>Replica &apos;Node&apos;</title>\n'
		'  </service>\n'
		'</catalog>\n'
	] ''

	xroot = df/xml-parse xml_src
	if err? xroot [ return xroot ]
	r17 = assert-eq xroot.tag 'catalog' 'xml root tag'
	if err? r17 [ return r17 ]
	r18 = assert-eq (df/xml-attr xroot 'region' '') 'eu-west-1' 'xml root attribute'
	if err? r18 [ return r18 ]
	r19 = assert-eq (df/xml-child-text xroot 'dc:creator') 'Veko & Contributors AB' 'xml namespace child + hex/dec entities'
	if err? r19 [ return r19 ]

	svcs = df/xml-find-all xroot 'service'
	r20 = assert-eq (len svcs) 2 'xml find-all count'
	if err? r20 [ return r20 ]
	r21 = assert-eq (df/xml-child-text svcs[0] 'title') 'Edge <Gateway> "v1"' 'xml entity unescaping'
	if err? r21 [ return r21 ]
	r22 = assert-eq (df/xml-child-text svcs[0] 'filter') 'latency_ms < 50 && status == "ok"' 'xml CDATA raw preservation'
	if err? r22 [ return r22 ]

	// XML render -> parse roundtrip (also testing &amp;lt; non-double-unescape!)
	tricky_node = xml/XmlNode {
		tag      = 'note'
		attrs    = { 'expr' = 'a < b & "c"' }
		children = []
		text     = 'Literal entity &lt;stays&gt; intact'
	}
	rendered_xml = df/xml-render/pretty/decl tricky_node true true
	reparsed_xml = df/xml-parse rendered_xml
	r23 = assert-eq reparsed_xml.text 'Literal entity &lt;stays&gt; intact' 'xml single-pass entity safety'
	if err? r23 [ return r23 ]
	r24 = assert-eq (df/xml-attr reparsed_xml 'expr' '') 'a < b & "c"' 'xml attribute escape roundtrip'
	if err? r24 [ return r24 ]
	println '  [PASS] XML 1.0 parser, namespaces, CDATA, numeric refs & serializer roundtrip'

	// 3. RSS 2.0 Feed build & parse roundtrip
	rss_in = xml/RssChannel {
		title           = 'Veko Language Releases'
		link            = 'https://veko-lang.org/releases'
		description     = 'Official compiler & ecosystem updates'
		language        = 'en-us'
		last_build_date = 'Sat, 05 Dec 2026 01:00:00 GMT'
		items = [
			(xml/RssItem {
				title       = 'Veko 1.0.0 Released'
				link        = 'https://veko-lang.org/releases/1.0.0'
				description = '64-bit VKO VM, Wasm 3.0 & Native PE32+/ELF64/Mach-O.'
				guid        = 'tag:veko-lang.org,2026:1.0.0'
				pub_date    = 'Sat, 05 Dec 2026 00:00:00 GMT'
				author      = 'team@veko-lang.org'
				categories  = ['compiler' 'release']
			})
			(xml/RssItem {
				title       = 'Official Ecosystem Packages'
				link        = 'https://veko-lang.org/pkg'
				description = 'Pure-Veko cloud_s3, data_formats, openapi, smtp_mail & webauthn.'
				guid        = 'tag:veko-lang.org,2026:ecosystem-1'
				pub_date    = 'Sat, 05 Dec 2026 01:00:00 GMT'
				author      = 'team@veko-lang.org'
				categories  = ['packages']
			})
		]
	}
	rss_xml = df/build-rss rss_in
	rss_out = df/parse-rss rss_xml
	if err? rss_out [ return rss_out ]
	r25 = assert-eq rss_out.title 'Veko Language Releases' 'rss channel title'
	if err? r25 [ return r25 ]
	r26 = assert-eq (len rss_out.items) 2 'rss items len'
	if err? r26 [ return r26 ]
	r27 = assert-eq rss_out.items[0].guid 'tag:veko-lang.org,2026:1.0.0' 'rss item guid'
	if err? r27 [ return r27 ]
	r28 = assert-eq rss_out.items[0].categories ['compiler' 'release'] 'rss item categories'
	if err? r28 [ return r28 ]
	println '  [PASS] RSS 2.0 feed codec build & parse roundtrip'

	// 4. Atom 1.0 Feed build & parse roundtrip
	atom_in = xml/AtomFeed {
		id          = 'urn:uuid:veko-releases-feed'
		title       = 'Veko Security & Release Advisories'
		updated     = '2026-12-05T01:00:00Z'
		subtitle    = 'Signed VKP1 package advisories'
		link        = 'https://veko-lang.org/atom.xml'
		author_name = 'Veko Core Team'
		entries = [
			(xml/AtomEntry {
				id          = 'urn:veko:release:1.0.0'
				title       = 'Veko 1.0.0 GA'
				updated     = '2026-12-05T00:00:00Z'
				link        = 'https://veko-lang.org/releases/1.0.0'
				summary     = 'General availability across Windows, Linux, macOS, and Wasm.'
				content     = '<p>Deterministic single-owner memory &amp; gradual types.</p>'
				author_name = 'Veko Core Team'
			})
		]
	}
	atom_xml = df/build-atom atom_in
	atom_out = df/parse-atom atom_xml
	if err? atom_out [ return atom_out ]
	r29 = assert-eq atom_out.id 'urn:uuid:veko-releases-feed' 'atom feed id'
	if err? r29 [ return r29 ]
	r30 = assert-eq atom_out.author_name 'Veko Core Team' 'atom feed author'
	if err? r30 [ return r30 ]
	r31 = assert-eq (len atom_out.entries) 1 'atom entries len'
	if err? r31 [ return r31 ]
	r32 = assert-eq atom_out.entries[0].link 'https://veko-lang.org/releases/1.0.0' 'atom entry link href'
	if err? r32 [ return r32 ]
	r33 = assert-eq atom_out.entries[0].content '<p>Deterministic single-owner memory &amp; gradual types.</p>' 'atom entry HTML content'
	if err? r33 [ return r33 ]
	println '  [PASS] Atom 1.0 (RFC 4287) feed codec build & parse roundtrip'

	println 'ALL data_formats TESTS PASSED'
	.ok
]

res = main
if err? res [
	println (mold res)
	os/exit 1
]
Cryptographic Provenance

Ed25519 Signature & Merkle Integrity

Registry URL: https://veko-lang.org/pkg/data_formats/1.0.0.vkp
Archive SHA-256: 2f0c1557ddb761735edd4d8ac3d2f96564383ee682578106d3643db56ed871cc
Merkle Root: 202839c7c97d16b42c924c483bbdf1bb797494aba7f6661d73b3607a4d6451b1
Signer Trust Key: ed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70
Embedded VKP1 Manifest

manifest.json

{"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 PathSizeLeaf SHA-256 Digest
README.md6 KB6f7697041f86e0af1448eb95ab5c2a80aae3bd394eb2aad13cd20268fcdef2cc
examples/demo.vk9 KB58f9f4f79219e808ce46b86eb4a0b522e96d111142ffca59b2e1823d53eb8157
mod.vk1 KB03e7171127f3d23866205ef5a734157204bbd0043f4d7572f2e5a4ccd1286b53
xml.vk20 KB5f9afd928c766a13b021527fa5ef4d4b2061cd25b167982367e0627ce1ed21eb
yaml.vk22 KB786c6175bc20e41a16b6484fd3c7e27d022495a99596e92d65f78a44566b63f2