KMMR Online Tools

XPath 2.0+ Planning

XPath Tester

Dedicated page for XML, XPath expressions, and namespace mapping. The XPath 2.0+ execution engine has been compared already, and the public UI and sample cases are being finalized first.

XPath input

The page is designed to show node sequences and scalar values clearly.

Namespace support

Prefix lines are used to handle default namespaces and multi-prefix XML.

Current status

This patch publishes the UI and spike result first, then enables the runtime next.

XPath execution is the next step

This patch ships xml-formatter first. xpath-tester currently publishes the UI, fixed sample cases, and engine-comparison result. Actual XPath 2.0+ execution will be enabled in the next integration step.

Need to clean up the XML first?

If formatting or validation comes first, open XML Formatter / Validator

Input set

Keep XML, the XPath expression, and namespace lines separate.

Result area

Public UI preview

XPath 2.0+ execution is not enabled yet

This page currently publishes the input UI, fixed sample cases, namespace format, and result-layout design first. Runtime execution will appear here once the engine is integrated.

Selected candidate

SaxonJS is the primary choice after the comparison.

Planned v1 scope

  • Browser-only XML paste, XPath input, namespace mapping, and reproducible sample cases.
  • Result views for node sequences and scalar values.
  • No XML storage, no XML to JSON conversion, and no server-side XPath execution in v1.

Fixed XPath examples

Use these cases for attributes, multiple matches, string, number, boolean, and namespace-aware queries.

Fixed XML samples

These four XML samples stay fixed for the spike and acceptance checks.

Well-formed XML

Simple invoice XML for formatting, validation, and scalar XPath samples.

Broken XML

Mismatched closing tag to verify parse errors and location hints.

Default namespace

Feed XML that needs a prefix mapping before XPath can match elements.

Multiple prefixes

SOAP-style payload with several namespaces for prefix-based XPath tests.

Engine comparison spike

Comparison between SaxonJS and Saxon/C using the same evaluation axes.

Conclusion

Adopt SaxonJS as the primary XPath 2.0+ candidate for this site. It fits browser-side privacy, avoids server-side XML payload handling, and is easier to add to the current PHP pages than a native PHP extension.

Why the other option is not first

Saxon/C remains technically strong, but it adds native runtime packaging, PHP extension deployment, and operational overhead that do not match this lightweight PHP site.

Axis SaxonJS Saxon/C
XPath 2.0+ support Official SaxonJS materials describe XPath 3.1 coverage and a direct browser API. Saxon/C also exposes XPath 3.1 through the PHP XPathProcessor API.
Namespace handling Works with explicit static context and prefix mappings on the browser side. Strong explicit namespace APIs are available in the PHP integration.
Integration with this PHP site Fits the current browser-heavy tools and keeps user XML off the server. Requires server-side integration and extension management before the page can run.
Deployment difficulty Serve a JS runtime asset with page-specific loading. Install and maintain native Saxon/C binaries and PHP bindings.
License notes Available free of charge under the Saxonica Public License, but not open source. Saxon/C HE is open source under MPL 2.0; PE and EE are commercial.
Performance Adequate for pasted XML and interactive browser testing. Likely stronger for large server-side workloads, but heavier than needed for v1.

Install outline

  • Download the SaxonJS browser package and serve the runtime JS from a versioned asset path under the public directory.
  • Load the runtime only on the xpath-tester page and evaluate XPath against the pasted XML DOM in the browser.
  • Parse namespace lines such as prefix=https://example.com/ns and pass them into the SaxonJS evaluation context.
  • Render node sequences, strings, numbers, and booleans in separate result layouts without sending XML to the server.

Current environment

  • PHP 8.3 with dom, SimpleXML, xmlreader, and xmlwriter is available.
  • Node.js is not installed in the current environment, so a browser-served runtime is easier to introduce than a build-heavy integration.

If you found this tool helpful, we’d love for you to share it on social media!