npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dortdb/lang-xquery

v2.1.0

Published

XQuery parser and executor for DortDB

Readme

@dortdb/lang-xquery

An XQuery language plug-in for DortDB. It adds XQuery, the language for tree-shaped and XML-like data: DOM documents, parsed XML, and similar hierarchical structures, with XPath path navigation and FLWOR transformations.

Installation

npm install @dortdb/core @dortdb/lang-xquery

@dortdb/core is a peer dependency.

Usage

import { DortDB } from '@dortdb/core';
import { defaultRules } from '@dortdb/core/optimizer';
import { XQuery, DomDataAdapter } from '@dortdb/lang-xquery';

const db = new DortDB({
  // in a browser, XQuery() picks up the global document automatically
  mainLang: XQuery({ adapter: new DomDataAdapter(document) }),
  optimizer: { rules: defaultRules },
});

const people = new DOMParser().parseFromString(
  `<people>
     <person age="30">Alice</person>
     <person age="20">Bob</person>
   </people>`,
  'text/xml',
);
db.registerSource(['people'], people);

db.query('for $p in $people/people/person[@age > 25] return string($p)');
// ['Alice']

Data adapter

The default adapter targets DOM and XML trees, and also reads JS object properties through the attribute axis (obj/@prop). In the browser the global document is used automatically; in Node.js supply a document from a DOM implementation (such as jsdom) and make the DOM globals available, or provide a custom adapter for your own tree shape.

Dialect

This is a subset of XQuery 3.0 focused on data selection: path expressions, FLWOR, and sequence operations. It deliberately omits the type system, so the following are not available and are not planned: the as keyword, typeswitch, instance of, treat, castable, validate, function types other than function(*), and named function references with arity (fnname#arity). Only cast expressions are supported.

Not implemented today, but possibly added later: try / catch, pragma expressions, the window FLWOR clause, inline functions, %private / %public annotations, and module prolog features beyond namespace definitions.

Custom plan operators

XQuery extends the DortDB unified algebra with two operators:

| Operator | Description | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | ProjectionSize | Adds an attribute holding the total number of rows in the stream (exposes $fs:last during path navigation). | | TreeJoin | Implements path steps like a/b/c. Like ProjectionConcat, but its expression yields items, and it also supplies the XQuery focus per step ($fs:dot, $fs:position, $fs:last). |

These demonstrate that the algebra is extensible; see Extending DortDB.

Documentation

See the XQuery overview and dialect reference, or the full docs at filipjezek.github.io/dortdb.