Skip to main content

dclq

[!WARNING] Experimental: dclq is experimental. Its commands, options, output formats, exit codes, and functionality may change in breaking ways without prior warning.

Query structured documents.
Grep, list, outline, and XPath over headings, sections, lists, and tables—and get an XPath back for every result.

What is dclq?

dclq brings the familiar grep workflow to DocLang documents. It queries semantic document units and returns bounded evidence with reusable XPath addresses.

$ dclq grep 'GPU|CPU' paper.dclg \
    --within-xpath '/heading[13]' --section -n
/list[4]/ldiv[1]:- AWS EC2 VM ... Nvidia L4 GPU ...
/text[42]:All experiments ... GPU acceleration ... x86 CPU ...

Features

  • 🔎 Semantic search across headings, paragraphs, captions, footnotes, list items, table cells, formulas, code, and metadata
  • 🧭 Structural context with section-aware neighbours, list siblings, table headers, captions, and document reading order
  • 🔗 Reusable XPath addresses for every result
  • 🎯 Precise filters for sections, XPath regions, pages, layers, and semantic types
  • 📑 Document navigation with structural inventory, heading outlines, semantic retrieval, and raw XPath selection
  • 📦 DocLang input from .dclg, .dclg.xml, .xml, .dclx, or standard input
  • 🤖 Pipeline-friendly output in text, JSON, and JSONL
  • grep-compatible behavior with regular expressions, fixed strings, context flags, counts, file listing, quiet mode, and exit codes
  • 🔒 Local, deterministic, read-only execution with bounded output

Quickstart

1. Install from PyPI

pip install dclq

2. Convert source documents to DocLang

python -m pip install docling
docling report.pdf handbook.docx --to dclx --output converted

3. Search

dclq grep -i 'termination|cancellation' converted/report.dclx

Without a pattern, dclq list enumerates units instead:

dclq list converted/report.dclx --type table_cell --page 3

Examples

Inspect a document

$ dclq inspect paper.dclx
paper.dclx
Type: dclx
Pages: 9
Semantic units: 612
Elements: caption=9, code=3, formula=4, heading=18, list=5, picture=6, table=5, text=434
Metadata: author=2, date=1, keywords=1

Navigate the heading hierarchy

$ dclq outline paper.dclg
Docling: An Efficient Open-Source Toolkit for AI-driven Document Conversion  /heading[1]
  Abstract                                      /heading[2]
  1 Introduction                               /heading[3]
  ...
  3 Design and Architecture                    /heading[5]
  5 Performance                                /heading[11]
  5.2 System Configurations                    /heading[13]
  ...
  6 Applications                               /heading[16]
  ...
  References                                   /heading[19]

Retrieve a section by XPath

$ dclq show paper.dclg '/heading[13]' --section --max-chars 220 -n
/heading[13]:5.2 System Configurations
/text[41]:We schedule our benchmark experiments each on two different systems...
/list[4]/ldiv[1]:- AWS EC2 VM (g6.xlarge)...
/list[4]/ldiv[2]:- MacBook Pro M3 Max (ARM)...
/text[42]:All experiments on the AWS EC2 VM...
/table[1]/ched[1]:Asset
/table[1]/ched[2]:Version
...

Each section element keeps its own reusable XPath.

Query the source XML

JSON includes document identity alongside scalar results:

$ dclq select paper.dclg 'count(//page_break) + 1' --format json
{
  "document": "paper.dclg",
  "sha256": "284b9b63bf3e11a75ffd2ad23c7505a9b5e75407531a13044ceae001e0d1550e",
  "value": 8.0
}

$ dclq select paper.dclg \
    'normalize-space(string(//table[1]/caption))'
Table 1: Versions and configuration options considered for each tested asset. * denotes the default setting.

Search a table cell with its structural context

The direct JSON record includes document identity, match offsets, and contributing document items; the relevant fields are shown here:

$ dclq grep -F '2.73 5.39' paper.dclx --format json
[
  {
    ...
    "xpaths": ["/d:doclang/d:table[1]/d:fcel[8]"],
    "logical_type": "table_cell",
    "text": "2.73 5.39",
    "pages": [1],
    "cell_context": {
      "column_headers": ["Inference time (secs)"],
      "caption": "Table 1. HPO performed in OTSL and HTML representation on the same transformer-based TableFormer..."
    }
  }
]

Get list-aware context

$ dclq grep -F 'Third item with numId 2' handbook.dclx \
    -C 1 --context-scope auto -n
/list[7]/ldiv[2]-2. Second item with numId 2
/list[7]/ldiv[3]:3. Third item with numId 2
/list[7]/ldiv[4]-4. Fourth item with numId 2

Use dclq in shell pipelines

# List matching documents.
dclq grep -i 'human annotation' documents/*.dclx -l

# Count matching semantic units.
dclq grep -i 'inference|runtime' documents/*.dclx -c

# Emit bounded records for an agent or data pipeline.
dclq grep -i 'accuracy|performance' documents/*.dclx \
  --page 1-4 \
  --type text,table_cell \
  --limit 10 \
  --format jsonl

# Check for a match without output.
if dclq grep -q -F 'CONFIDENTIAL' document.dclx; then
  echo "classified"
fi

Commands

Command Description
dclq grep PATTERN INPUT... Search semantic document units
dclq list INPUT... Enumerate semantic document units
dclq inspect INPUT... Print a structural inventory
dclq outline INPUT Print the heading hierarchy with XPaths
dclq show INPUT XPATH Retrieve semantic content at an XPath
dclq select INPUT XPATH Evaluate XPath against the source XML

Query options

Option Description
-e PATTERN Add a search pattern; repeatable
-f FILE Read patterns from a file
-F Match fixed strings
-i Ignore case
-w Match whole words
-A N, -B N, -C N Include semantic context
--context-scope SCOPE Use auto, container, section, or document context
--type TYPE Filter semantic unit types
--layer LAYER Filter body, furniture, or background content
--page LIST Filter pages and ranges such as 2-4,7
--within-xpath XPATH Restrict the query to an XPath selection
--section Expand a selected heading to its section
--limit N Limit the number of results
-n, --with-xpath Prefix text output with XPath addresses
--format FORMAT Emit text, json, or jsonl
-c, -l, -q Count, list matching files, or run quietly

Run dclq COMMAND --help for the complete option set.

XPath input may omit the namespace and document root: /formula[1], /doclang/formula[1], and /d:doclang/d:formula[1] are equivalent.

Exit codes

Code Meaning
0 At least one result
1 No results
2 Input, query, or usage error

Development

dclq lives in the docling-core repository as a workspace member under packages/dclq, and is released in lockstep with docling-core (same version, exact dependency pin). Work on it from the repository root:

uv sync --all-extras --all-packages
uv run pytest packages/dclq/tests
uv run pre-commit run --all-files

License

dclq is available under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dclq-2.94.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dclq-2.94.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file dclq-2.94.0.tar.gz.

File metadata

  • Download URL: dclq-2.94.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dclq-2.94.0.tar.gz
Algorithm Hash digest
SHA256 fa1b87d57c8487d9929f790b056c5b91e8f871af72da3d2df1bd37813a23cc15
MD5 82590f5909c2864685ee699a74bafa2e
BLAKE2b-256 9468c02b12848355b3b1da95750d99caf86b2589cf24f477f4ab8802ad8c5a46

See more details on using hashes here.

Provenance

The following attestation bundles were made for dclq-2.94.0.tar.gz:

Publisher: pypi.yml on docling-project/docling-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dclq-2.94.0-py3-none-any.whl.

File metadata

  • Download URL: dclq-2.94.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dclq-2.94.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1306daa61fe9de4b2046bc626611dd591f04dfe60e3f8c251457bfabb6737ac4
MD5 07355935192e9bbea093c4d78eacf3ce
BLAKE2b-256 4d3b55855412575ffb0711a1a54a0471517e553f1522734210ae3753ea7f9253

See more details on using hashes here.

Provenance

The following attestation bundles were made for dclq-2.94.0-py3-none-any.whl:

Publisher: pypi.yml on docling-project/docling-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.96.0

2 files

2.95.0

2 files

2.94.1

2 files

This release

2.94.0 This release

2 files

2.93.0

2 files

2.92.0

2 files

2.91.0

2 files

2.90.0

2 files

2.89.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page