Skip to content

Add xpath to validation error details - #168

Merged
jameslan merged 4 commits into
jameslan:masterfrom
msrose:add-xpath-to-error
Aug 20, 2026
Merged

jameslan merged 4 commits into
jameslan:masterfrom
msrose:add-xpath-to-error

Conversation

@msrose

@msrose msrose commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds xpath of the error node to the error details.

I have a use case with very large & interconnected XSDs from a third-party -- this library is working great, but it's often tricky to figure out exactly where errors are coming from since I don't control the schemas and (as far as I can tell) there's no way to get the xpath of the error node using existing APIs.

I'm not very familiar with wasm & libxml so please let me know of anything that can be improved here -- the changes make sense to me based on the existing patterns in the codebase, but there are a few tweaks to details that could make sense:

  • Exposing the node on the error object instead and then having the client call _xmlGetNodePath (not sure how expensive it is performance-wise to resolve the xpath to string by default)
  • Only add xpath to the error details if the user passes a flag when validating (once again with performance in mind)

Testing

  • Linting and tests all pass

@github-actions

Copy link
Copy Markdown

Coverage after merging add-xpath-to-error into master will be

100.00%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   c14n.mts100%100%100%100%
   diag.mts99.51%100%90.91%100%
   disposable.mts100%100%100%100%
   disposeShim.mts100%100%100%100%
   document.mts100%100%100%100%
   dtd.mts100%100%100%100%
   index.mts100%100%100%100%
   libxml2.mts100%100%100%100%
   metadataShim.mts100%100%100%100%
   nodejs.mts100%100%100%100%
   nodes.mts99.92%99.22%100%100%76
   utils.mts100%100%100%100%
   validates.mts100%100%100%100%
   xpath.mts100%100%100%100%

@msrose

msrose commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@jameslan let me know if I can do anything to help this along -- thanks

@jameslan
jameslan merged commit 3b26d92 into jameslan:master Aug 20, 2026
14 checks passed
github-actions Bot pushed a commit that referenced this pull request Aug 20, 2026
@jameslan

Copy link
Copy Markdown
Owner

@msrose Thanks you for your contribution!

jameslan pushed a commit that referenced this pull request Sep 5, 2026
* Add xpath to validation error details

* Coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants