Repository navigation
feat(xpath): Parsec had no XPath, and neither does Lexbor - #104
Merged
Merged
Conversation
Adds crates/parsec-xpath, synced from Netweir's crates/netweir-xpath (netweir/netweir#341), which moved Netweir's XPath 1.0 engine onto the parser's own Document. Every axis and the core function library; steps from many context nodes worked out once for the whole set, and a work limit for the queries that stay quadratic. libxml2's expression tests run in cargo test: 231 passed, 12 skipped (libxml2's own extensions). scripts/sync-from-netweir.sh now syncs both crates, with the same header and name rewriting, and its --check covers both. The manifest is Parsec's own; the one dependency beyond parsec-html is stacker, which the evaluator uses to grow its stack on deep expressions. Also syncs Netweir ff397ba.
jamesconwaydev
enabled auto-merge (squash)
November 19, 2026 10:43
This was referenced Nov 19, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Lexbor has no XPath, which is why nokolexbor ported libxml2's (lexbor#23). Parsec had none either (#31).
Change
crates/parsec-xpath, synced from Netweir's newcrates/netweir-xpath(refactor(xpath): XPath only ran over netweir-dom's own node wrapper netweir/netweir#341), which moved Netweir's XPath 1.0 engine onto the parser's ownDocument.//div//divover 8,000 nesteddivs takes 0.2 ms, where it took 1.7 s.Indexonce per document and query throughDoc::html(&doc, &index). To see inside<template>, calladopt_template_contents()first, as lxml has it. Netweir does the same.scripts/sync-from-netweir.sh: syncs both shared crates with the same header and name rewriting, and--checkcovers both. The manifest is Parsec's own. The one dependency beyondparsec-htmlisstacker(MIT/Apache-2.0).Closes #31
Tests
test/XPath/exprsuite: 231 passed, 0 failed, 12 skipped (libxml2's own extensions: exponent literals). Plus 13 tests covering every axis, function, the hooks and the work limit.cargo test --workspace: 249 test groups, 0 failed.cargo deny check,check-headers.shandsync-from-netweir.sh --checkpass, andshellcheckis clean.