HDF

HDF Path Query Language (HDFPGL) Specification

HDFPGL is a declarative query language designed to navigate and extract data from HDF (Human Data Form) structures into Lua tables.

1. Syntax Overview

1.1 Path Navigation

- platform.database: Matches database directly under platform. - platformport: Finds all port nodes anywhere under platform. - servers.: Matches all children of the servers node.

1.2 Projections and Bindings

Projections define what data to extract from the matched nodes and how to name the keys in the resulting Lua table. - Example: servers..hostname {H} - Returns: { {H = "vh1..."}, {H = "vh2..."} } - Example: servers. ( customer {C}, hostname {H} ) - Returns: { {C = "imperial", H = "vh1..."}, ... } - Example: users. ( metadata.name {N} )

2. Command Line Interface: hq

The hq tool is a CLI utility for querying and formatting HDF data, similar to jq for JSON.

Usage

hq [options] <query> [file]

Options

Examples

# Filter and pretty-print
hq 'servers.server ( status "active", * )' inventory.hdf

# Extract a single raw value
hq -r 'server.hostname' config.hdf

3. Command Line Interface: he

The he tool is a CLI utility for editing HDF data, similar to yq for YAML.

Usage

he [options] <command> [files...]

Commands

- Updates an existing value or creates the path if it doesn't exist. - Supports strings (quoted), numbers, booleans, and null. - Removes the node at the specified path. - Deep merges multiple HDF files. - Heuristic: Overwrites simple values, merges nested fields.

Options

Examples

# Set a value and output to stdout
he '.server.port = 8080' config.hdf

# Delete a key in-place
he -i 'del(.debug)' app.hdf

# Merge two configurations
he merge base.hdf override.hdf > final.hdf

4. Extraction Rules

4. Features

4.1 Literals in Projections (Filtering)

Syntax: path ( field "literal_value", field2 {BINDING} ) Example: servers.
( customer "imperex", hostname {H} ) Purpose: Only return records where customer equals "imperex".

4.2 Wildcard Projection ()

Syntax: path ( ) or path ( key "val", ) Purpose: Extracts all sub-nodes of the matched node as key-value pairs in the result table.

4.3 Deep Navigation

Syntax: path
target Purpose: Finds target nodes at any depth under path.