If this project saved you some time or made your day a little easier, a star would mean a lot — it helps others find it too.
Experimental. This project is at an early stage. APIs, module layout and behaviour may change without notice, also between releases. Do not use it in production yet.
A pure Java implementation of XPath 3.1 and XSLT 3.0, intended as an Apache 2.0 licensed alternative to Saxon. XML parsing is left to the JDK; everything on top of it, including an XML Schema 1.0 validator, is implemented here.
Status: initially released.
- The native XML Schema validator passes 99.99% of the applicable W3C xsdtests cases for XSD 1.0 (39,396 of 39,401) and XSD 1.1 (41,596 of 41,600); failing cases and the reasons: xsd-native.md.
- The XPath 3.1 engine runs and passes all 22,401 applicable W3C QT3 test cases; skipped cases and the reasons: qt3.md.
- The XSLT 3.0 engine passes 99.9% of the applicable W3C xslt30-test cases as a basic processor (8,640 of 8,647); failing cases and the reasons: xslt30.md.
Schema-awareness and streaming are available as opt-ins (streaming: the streamability analysis, streamed execution of guaranteed-streamable constructs and output written while it is built).
XSLT 1.0 stylesheets run with backwards compatible behaviour (claimed by default; 8,752 of 8,762 cases with the claim), with the EXSLT - Common functions exsl:node-set and exsl:object-type.
A JAXP TransformerFactory, a W3C DOM bridge and a command line client (also as Docker image) are included.
See docs/PLAN.md for the roadmap.
| Module | Content | Status |
|---|---|---|
phoxtrot-xdm |
XPath data model: node tree built from SAX, incremental StAX reader for streamed documents, names, document order, W3C DOM and SAX bridge | usable |
phoxtrot-xpath |
XPath 3.1: values, parser, evaluator, F&O 3.1 function library, regex, collations, serialisation | usable |
phoxtrot-xpath-conformance |
W3C QT3 test harness (not deployed) | usable |
phoxtrot-xslt |
XSLT 3.0: stylesheet compiler, modules, templates and modes, all instruction families, XSLT functions, packages, schema-awareness, streaming (analysis, streamed execution, output written while it is built), JAXP TransformerFactory |
usable |
phoxtrot-xslt-conformance |
W3C xslt30-test harness (not deployed) | usable |
phoxtrot-xsd |
Native XML Schema 1.0 and 1.1 validator (port of go-xslt's internal/xsd): loader, include/import/redefine/override, schema-for-schemas checks, simple types and facets, content models with open content, instance validation with identity constraints, assertions and conditional type assignment, read-only component view, validation API that reports all errors; the default schema provider for XPath and XSLT (schemas compiled as XSD 1.1) |
usable |
phoxtrot-cli |
Command line client: check and run stylesheets, check, analyse and evaluate XPath expressions, check XML Schemas and validate documents (executable JAR, not part of the BOM; Dockerfile) | usable |
phoxtrot-xsd-conformance |
W3C xsdtests (XML Schema) harness with a pluggable validator (not deployed) | usable |
phoxtrot-xslt-benchmark |
JMH benchmarks and profiling workloads for parsing, XPath, XSLT, XSD, streaming and compiling (standalone, not in the reactor, not deployed; see its README.md and docs/benchmarks) |
usable |
phoxtrot-xdm-memory-benchmark |
Retained heap of the node tree compared with ph-xml MicroDOM and Saxon TinyTree (standalone, not deployed) | usable |
Requires Java 21. CI runs on Java 21 and 25.
The deployed modules are phoxtrot-xdm, phoxtrot-xpath, phoxtrot-xslt and phoxtrot-xsd. For XSLT 3.0 add
phoxtrot-xslt (it brings phoxtrot-xpath and phoxtrot-xdm); for XPath 3.1 alone phoxtrot-xpath:
<dependency>
<groupId>com.helger.phoxtrot</groupId>
<artifactId>phoxtrot-xslt</artifactId>
<version>0.3.0</version>
</dependency>Add phoxtrot-xsd as well for schema-awareness (see below).
Schema-awareness (XsltCompileOptions.setSchemaAware (true): xsl:import-schema, [xsl:]validation/[xsl:]type,
typed sources, schema-element() and user-defined types in XPath) needs the native validator (module phoxtrot-xsd)
on the class path. Without it the engine is a basic XSLT 3.0 processor. It needs no further dependencies; imported
schemas are compiled as XSD 1.1, so assertions, conditional type assignment, open content and xs:override work.
XML parsing stays on the JDK parser. The validator reads the documents an imported schema references
(xs:include, xs:import, xs:redefine, xs:override) only from local files, never from the network, and only while
XsltCompileOptions.setReadLocalSchemaFiles allows it (default true; the JAXP adapter derives it from
ACCESS_EXTERNAL_STYLESHEET). A schema-location itself is read through the resolver of the compile options if one
is set. phoxtrot-xsd can also be used on its own to validate documents (XsdSchema.validate, which reports all
errors), against XSD 1.0 or 1.1; the xsi:schemaLocation hints of an instance are only followed with
XsdValidationOptions.setFollowSchemaLocationHints (true), because the instance then decides which local files are
read.
<dependency>
<groupId>com.helger.phoxtrot</groupId>
<artifactId>phoxtrot-xsd</artifactId>
<version>0.3.0</version>
</dependency>docs/SCHEMA.md explains how the validator is loaded and what the JDK validator cannot provide.
Plain XPath 3.1 without XSLT (e.g. a Schematron binding that evaluates rule by rule) uses phoxtrot-xpath directly:
StaticContext aSC = new StaticContext ();
aSC.declareNamespace ("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
aSC.declareVariable (new XdmQName ("limit"));
SeqType aDouble = SeqType.of (ItemType.atomic (EAtomicType.DOUBLE), EOccurrence.ONE);
aSC.setFunctionLibrary (FunctionLibrary.getDefault ().createChild ()
.register (new XdmQName ("urn:ext", "twice"), List.of (aDouble), aDouble,
(aCtx, aArgs) -> ...));
CompiledXPath aXPath = XPathCompiler.compile ("count(//cbc:ID) le $limit", aSC); // immutable, thread-safe
DynamicContext aCtx = aXPath.createDynamicContext ().withFocus (aDocNode, 1, 1)
.withVariable (new XdmQName ("limit"), XdmSequence.of (XdmAtomic.integer (10)));
aCtx.setMaxSteps (1_000_000); // optional, XPDY0130 when exceeded
Boolean aValid = LargeStackRunner.run (() -> Boolean.valueOf (aXPath.evaluateEffectiveBooleanValue (aCtx)),
"my-xpath", EThreading.THREAD_POOL);- Source compatible within 0.x (changes only with a note in "News and noteworthy"): in
com.helger.phoxtrot.xpathXPathCompiler,CompiledXPath,XPathException,EThreading,LargeStackRunner,XPathStreamabilityAnalyzer,XPathStreamabilityResult,XPathStreamabilityReason,XPathStreamabilityBinding,EStreamabilityVerdict,EStreamabilityConstructandEStreamContextMode;StaticContext,DynamicContext,IResourceResolverandResourceUri(context);FunctionLibraryandIXPathFunction(fn);SeqType,ItemTypeandEOccurrence(ast);EPosture,ESweep,PostureSweepandEStreamFunctionCategory(stream); the value types ofvalue,XPathOperators(eval) and the node model ofphoxtrot-xdm. Everything else inast(expression nodes),eval,parser,ops,patternandstreamis internal. - Extension functions:
FunctionLibrary.registerwith the signature as text ("(xs:string?) as xs:integer") or asSeqTypes; the arguments are converted by the XPath 3.1 function conversion rules before the call (seeIXPathFunction). A compiled stylesheet's library is frozen; register into acreateChild (). CompiledXPath.getFreeVariables (): the variables of the static context an expression uses, to bind only these.- Threads: a
CompiledXPath, a compiledXsltExecutableand a compiledXsdSchemamay be used by several threads at once if they are handed over safely (afinalorvolatilefield, a concurrent collection, an executor); theStaticContextof a compiled expression must not change afterwards, and aDynamicContext(with the function items an evaluation returns) is for one thread at a time. A node tree that several threads read must be numbered first: parsed trees are, a tree built with theIXdmNode.create*factories orappendChildneedsassignDocumentOrder ()on its root, because comparing nodes of an unnumbered tree numbers it without synchronisation. - Limits:
DynamicContext.setMaxSteps(loop iterations and function calls, unlimited by default), the function call depth (10,000) andLargeStackRunnerfor a thread with a large stack. - Errors:
XPathExceptionwith code, description and error object; a static error has its position in the expression (getExpressionOffset,getExpressionLine,getExpressionColumn). An error raised in anxsl:functionis anXsltExceptionnaming the function (getFunctionFrame). - Streamability:
XPathStreamabilityAnalyzertells whether an expression (analyze) or a match pattern (analyzePattern) can be evaluated while streaming, with the analysis of XSLT 3.0 section 19: posture and sweep, a verdict (motionless, consuming, free-ranging) and for a verdict other than motionless the construct that causes it (an axis step, a function, a variable, without position in the text). Options: the context node streamed, buffered with its whole tree, or in burst mode (EStreamContextMode.BURST: only its subtree is buffered, verdictBURSTfor an expression or pattern predicate that needs nothing outside it, e.g. one Schematron rule per element; the document element counts as an ancestor of a streamed context node, so/x/@ais motionless), variables bound to streamed nodes or (burst mode) to nodes outside the subtree or with a binding expression compiled once (analyzeBinding,addBoundVariable: analysed as aletaround each expression), the streamability category of extension functions (undeclared ones are not streamable).FunctionLibrary.createDefaultWithXsltSignatures ()adds the signatures of the XSLT functions (fn:key,fn:current,fn:document, ...) for compiling expressions of an XSLT-based language withoutphoxtrot-xslt. - Static typing (XPath 3.1 section 4.1, optional):
StaticContext.setStaticTyping (true)infers the static type of the expression at compile time and raises type errors (XPTY0004, XPTY0019, XPTY0020) and XPST0005 where the inferred type is not accepted, before anything is evaluated. It is pessimistic by definition: declare the context item type (setContextItemStaticType) and the variable types (declareVariable (name, SeqType)), and usetreat aswhere only you know more. Off by default; XSLT does not use it. - Stylesheet functions without Java code: compile a module with the
xsl:functions (and the keys and global variables they use) and compile the expressions againstXsltExecutable.createStaticContext (), evaluated with the dynamic context ofXsltExecutable.createEvaluation (request).createDynamicContext ().
com.helger.phoxtrot.xslt.jaxp.PhoxtrotTransformerFactory is a JAXP TransformerFactory for XSLT 3.0 (Templates
are thread-safe, a Transformer is for one thread at a time). It is deliberately not registered in
META-INF/services, which would replace the JDK transformer for every application on the class path; create it
directly or by name:
TransformerFactory aTF = new PhoxtrotTransformerFactory ();
// or: TransformerFactory.newInstance ("com.helger.phoxtrot.xslt.jaxp.PhoxtrotTransformerFactory", aClassLoader)
aTF.setURIResolver (aURIResolver); // xsl:include/import, document(), doc(), unparsed-text()
Templates aTemplates = aTF.newTemplates (new StreamSource (aXslFile));
Transformer aTransformer = aTemplates.newTransformer ();
aTransformer.setErrorListener (aErrorListener); // xsl:message arrives as warning()
aTransformer.setParameter ("phase", "#ALL");
aTransformer.transform (new DOMSource (aDoc), new DOMResult ());- Sources:
StreamSource,DOMSource,SAXSource(with or withoutXMLReader) andXdmSource(a phoxtrot tree); results:StreamResult(writer, stream orfile:system ID; written while it is built where the output definition allows it),DOMResultandSAXResult.newTransformer ()is the identity transformer. - Parameters:
Stringbecomesxs:untypedAtomic(soas="xs:integer"accepts "42"), numbers,Boolean,URI,QName, DOM nodes, phoxtrot items and sequences, arrays and collections (as sequences). Names{uri}local. - Output properties: the
OutputKeysand the other XSLT 3.0 serialization attributes exceptuse-character-mapsoverride the unnamedxsl:outputfor aStreamResult; namespaced names are accepted without effect. - Errors: compile errors are reported to
ErrorListener.fatalErrorand thrown asTransformerConfigurationException, run errors asTransformerException; the message starts with the error code, the locator has module, line and column, the cause is theXsltException.xsl:messageand failedxsl:assertgo toErrorListener.warningwhile the transformation runs, or to anIXsltMessageListener(PhoxtrotTransformer.setMessageListener, factory attributePhoxtrotTransformerFactory.ATTR_MESSAGE_LISTENER). - Tracing: an
IXsltTraceListener(PhoxtrotTransformer.setTraceListener, factory attributePhoxtrotTransformerFactory.ATTR_TRACE_LISTENER) follows the template rules, named templates, stylesheet functions and optionally instructions of each transformation; the same listener asXsltTransformRequest.setTraceListener. - Current date-time:
PhoxtrotTransformer.setCurrentDateTimefixes the value offn:current-dateTime()(its offset also being the implicit timezone) for the transformations of a transformer, e.g. for reproducible output. - Threads: compilations and transformations run on the thread the factory attribute
PhoxtrotTransformerFactory.ATTR_THREADINGchooses (anEThreadingor its name; defaultNEW_THREAD, a new thread with a large stack per call; alsoTHREAD_POOLandCALLING_THREAD), a transformer can override it withPhoxtrotTransformer.setThreading. - The
URIResolveris called as JAXP specifies: with thehrefas written and the base URI it is resolved against (the empty string if there is none, e.g. a stylesheet without system ID). XMLConstants.FEATURE_SECURE_PROCESSINGis on by default (unlike the JDK transformer): only theURIResolverand theEntityResolvergive access to other resources, andxsl:result-documentwithhrefdoes not compile. Setting it tofalsesets both access attributes below toall, setting it totruesets them to the empty string.- What the
URIResolverdoes not resolve is read directly ifXMLConstants.ACCESS_EXTERNAL_STYLESHEETallows the scheme (default empty, so nothing;allwithout secure processing; ajar:URI needs its nested URI allowed too). AURIResolverthat throws refuses the URI:xsl:include/xsl:importfail with XTSE0165,document()/doc()with FODC0002,unparsed-text()/json-doc()with FOUT1170, each with its message, and the*-availablefunctions returnfalse. - External DTDs and entities are only read with the attribute
ATTR_LOAD_EXTERNAL_ENTITIES, for stylesheets, modules, sources and documents alike: anEntityResolver(factory attributeATTR_ENTITY_RESOLVER,PhoxtrotTransformer.setEntityResolver) is asked first, and the parser opens them itself only for the schemes ofXMLConstants.ACCESS_EXTERNAL_DTD(default empty,allwithoutFEATURE_SECURE_PROCESSING). Further attributes:ATTR_SCHEMA_AWARE(theschema-locationofxsl:import-schemagoes through theURIResolverandACCESS_EXTERNAL_STYLESHEETlike a module; the documents it references are read only iffileis allowed),ATTR_MAX_STEPSandATTR_MAX_DEPTH(the nesting depth of templates and functions, default 10,000,XsltTransformRequest.UNLIMITED_DEPTHfor no limit but the stack;PhoxtrotTransformer.setMaxDepthper transformer). - Not supported:
SAXTransformerFactory(TransformerHandler,TemplatesHandler), StAX sources and results, and writing secondary results (xsl:result-document); these are available fromPhoxtrotTransformer.getLastResult (). WithFEATURE_SECURE_PROCESSINGa stylesheet with anxsl:result-documentthat has anhrefattribute does not compile (XTSE0010), as in Saxon (XsltCompileOptions.setSecondaryResultsAllowed). Initial templates, modes and functions need the phoxtrot API (PhoxtrotTemplates.getExecutable ()).
com.helger.phoxtrot.xdm.bridge converts between W3C DOM and the phoxtrot tree without serialising:
DomToXdm.convertDocument (aNode, sSystemId) builds the tree of a DOM (namespace fixup for DOMs built with
createElementNS, DOM level 1 names, entity references expanded, ID attributes, unparsed entities, the document URI)
and DomToXdm.convert returns the counterpart of a given DOM node in it; DomToXdm.convertWithMapping also keeps
the way back from every XDM node to its DOM node (DomNodeMapping.getDomNode); XdmToDom.toDocument,
toDocumentFragment and appendTo write a tree, a subtree or a parentless node into a DOM with correct namespace
declarations; XdmToSax.emit writes a tree as SAX events. XdmDomView shows a tree as a read-only DOM without
copying it (new XdmDomView (aDoc).getNode (aXdmNode), one DOM node per XDM node, XdmDomView.getXdmNode back), e.g.
to report a node an XPath expression matched to code that expects org.w3c.dom nodes.
phoxtrot-cli builds an executable JAR (phoxtrot-cli-x.y.z-shaded.jar, Java 21) for checking stylesheets,
expressions and schemas without writing Java code, e.g. in a build or CI step:
java -jar phoxtrot-cli-x.y.z-shaded.jar <group> <command> [options]
| Command | Description |
|---|---|
xslt check STYLESHEET... |
Compile stylesheets and report their static errors with module, line and column, without running them. --streamable claims streaming and enforces the streamability rules (XTSE3430) |
xslt run -s STYLESHEET [SOURCE] |
Run a stylesheet and write the principal result to -o FILE (deleted again if the run fails) or the standard output. -p NAME=VALUE and --xparam NAME=XPATH set parameters, --initial-template [NAME] and --initial-mode NAME select the start, --streamed reads the source as a stream, --result-documents DIR allows xsl:result-document with href and writes its results to DIR (UTF-8), --trace and --trace-instructions print what is entered. xsl:message and the trace go to the error output |
xpath check XPATH... / -f FILE... |
Compile expressions and report their static errors with line and column. --declare NAME[=TYPE] declares variables, --static-typing with --context-type ITEMTYPE raises type errors at compile time, --xslt-functions knows the XSLT functions |
xpath streamability XPATH... |
The streamability verdict (XSLT 3.0 section 19) with posture, sweep and the construct that causes it; --mode STREAMED|BURST|GROUNDED, --pattern for match patterns, --streamed-var NAME |
xpath eval XPATH... |
Evaluate expressions against -c FILE (optional) and print each result; --var NAME=VALUE, --xvar NAME=XPATH, --method adaptive|xml|json|text, --indent |
xsd check SCHEMA... |
Compile schema documents as one schema and report its error |
xsd validate --xsd SCHEMA FILE... |
Validate documents and report every error with line and column (--max-errors N); xsi:schemaLocation hints are not followed |
help [COMMAND], generate-completion |
The help of a command; a bash/zsh completion script |
Shared options: --ns PREFIX=URI (XPath commands), --xsd-version 1.0|1.1 (XSD commands, default 1.0),
--schema-aware, --no-backwards-compatible and --static-param NAME=VALUE (XSLT commands), --threading MODE and
--max-steps N, -q/--quiet and -v/--verbose. Names are local, prefix:local (with --ns; xsl: is
predefined for the XSLT commands), Q{uri}local or {uri}local; string values are xs:untypedAtomic, so they are
converted to the declared type.
Secure by default: only local files are read, never the network, without external entities, and only from the folders
of the files named on the command line (stylesheet, source, context document, schemas) and the --resource-dir DIR
folders. A refused access is reported as warning, and the engine then raises its error (XTSE0165 for a module, FODC0002
for a document). --allow-file-access allows any local file; only then are the schema documents that an
xsl:import-schema schema references read. xsl:result-document with href is rejected (XTSE0010) unless
--result-documents is given, and its results must stay inside that folder.
Exit codes: 0 success, 1 a check failed (static error, not streamable, invalid document) or a run raised an error,
2 invalid command line, 3 technical error (I/O, unreadable source, unusable schema, no verdict of the validator).
examples/basic has an invoice with stylesheets, XPath files and an XSD 1.1 schema, and one script per command group
(see its README.md).
phoxtrot-cli/Dockerfile builds an image with the client (Eclipse Temurin 25 JRE); the arguments of docker run
after the image name are passed to the client. Mount the files to work on to /data, the working directory of the
image:
docker run --rm -v "$PWD:/data" phelger/phoxtrot xslt check --streamable my.xsl
docker run --rm -v "$PWD:/data" phelger/phoxtrot xslt run -s to-html.xsl -o out.html invoice.xml
docker run --rm -v "$PWD:/data" phelger/phoxtrot xsd validate --xsd-version 1.1 --xsd invoice.xsd invoice.xml
Only files below the mounted folder are visible, so included modules and documents must be inside it too. The exit
code of the client is the exit code of docker run.
docker/build.sh builds the image:
| Call | Builds |
|---|---|
docker/build.sh snapshot [--mvn] |
The current -SNAPSHOT version for this machine, loaded into the local Docker, tagged <version> and snapshot, smoke tested |
docker/build.sh snapshot --push [--mvn] |
The same for linux/amd64 and linux/arm64, pushed |
docker/build.sh release [--mvn] |
A released version for linux/amd64 and linux/arm64, pushed, tagged <version> and latest |
--mvn builds the shaded JAR first; without it, phoxtrot-cli/target must contain exactly the JAR of the version in
pom.xml. IMAGE overrides the image name phelger/phoxtrot. Pushing needs a docker login first.
fn:generate-idreturnsd, the number of the node's tree in the run,nand the number of the node in that tree, both counted in the order the identifiers are first requested (d1n1,d1n2,d2n1, ...). The values differ from Saxon's (which also differ between Saxon's tree models), so output that contains them, such as theactive-pattern/@idof an SVRL created by the ISO Schematron skeleton from abstract patterns, differs between processors; compare such output with the generated IDs normalised.
This library is a port of go-xslt by Tim Riep (Apache 2.0), a from-scratch Go implementation of XSLT 3.0, XPath 3.1 and XSD. Its architecture, its test strategy and large parts of its behaviour are the basis of this project. See NOTICE.
v0.4.0 - work in progress
- New module
phoxtrot-cli: a command line client (executable JAR) withxslt check(static errors,--streamable),xslt run,xpath check(static errors, static typing),xpath streamability,xpath eval,xsd checkandxsd validate. It reads only local files from the folders named on the command line unless--allow-file-accessis given, and allowsxsl:result-documentwithhrefonly with--result-documents. With a Dockerfile (phoxtrot-cli/Dockerfile,docker/build.sh) and examples (examples/basic) - XSD: the xs:base64Binary lexical check uses a lookup table and a tight loop for the leading run of base64 characters instead of range comparisons, whose branches are mispredicted on base64 data: about 8 times faster, which halves the validation time of an e-invoice with a 200 KB attachment
XdmTreeBuilderuses a new buffer for each text node that is merged from several character events: a reused buffer that once held a non-Latin-1 character stays UTF-16, so all later text was inflated and compressed again- XSD: new
XsdSchema.assessTextvalidates instance text likevalidateTextand also reports the governing type definition of every element and attribute (XsdAssessment,XsdNodeType), withxsi:type, conditional type assignment, substitution groups and wildcards resolved. Nodes are identified by their element positions, so a caller can map them to its own parse of the same text - XSD: new
XsdSimpleTypeView.getEffectiveFacetsadds the facets XSD Datatypes defines for the built-in derived types (the bounds ofxs:byte,xs:int,xs:unsignedLong,xs:positiveIntegeretc. andfractionDigits0 ofxs:integer) to the declared ones;getFacetsstill reports only the declared facets - XSD: new
XsdSimpleTypeView.getValueError/isValidValuecheck a value against a simple type exactly as the validator does (whiteSpace, lexical space, all facets), and newXsdPatternMatchermatches the regular expression of apatternfacet without a schema - XSD:
XsdNodeType(ofXsdSchema.assessText) also reports the element declaration an element was assessed against - XSD: an undeclared
xml:*attribute (xml:lang,xml:space,xml:base,xml:id) is now invalid under 1.0 and 1.1 unless an attribute use (ref="xml:lang") or a wildcard admits it (cvc-complex-type.3.2.2, on a simple-typed element cvc-type.3.1.1); before, it was accepted under 1.0 and on every simple-typed element. Onlyxsi:type,xsi:nil,xsi:schemaLocationandxsi:noNamespaceSchemaLocationare exempt, soxsi:foois rejected too - XSLT: functions registered with
XsltExtensionRegistry.registerFunctionsare now also visible in static expressions (use-when, static variables and parameters, shadow attributes), sofunction-availableanswers there as at run time; the run-time XSLT functions (current(),key(),current-group()etc.) stay unavailable there - The classes and records of the engine modules (enums, interfaces and exceptions excepted) carry a concurrency
annotation (
@Immutable,@NotThreadSafeor@ThreadSafe);FnTransformis now@ThreadSafeinstead of@Immutable - XSLT: the lazily built in-scope namespaces of a stylesheet element (
xsl:evaluate,XsltExecutable.createStaticContext) are published safely, so concurrent transformations of one compiled stylesheet no longer race on them FunctionLibrary.registerwith an implementation for dynamic calls registers the complete definition under the write lock; before, the dynamic implementation was set afterwards without the lock and the frozen check- XSLT API change:
OutputDefinition.ATTRIBUTESis an unmodifiableList,XsltElementSpecs.STANDARD_ATTRIBUTESandElementValidator.TOP_LEVEL_DECLARATIONSare unmodifiableSets, andXsltExtensionRegistry.EXTENSION_CLASS_NAMES,XsltExtensionRegistry.CORE_DECLARATIONSandXsltFunctions.SYSTEM_PROPERTIESare private: before, any caller could change these shared tables for every thread - Documented the thread rules of
CompiledXPath,XsltExecutable,XsdSchemaand node trees (README "XPath API", Javadoc)
v0.3.0 - 2026-11-17
- JAXP: the attribute names of
PhoxtrotTransformerFactory(ATTR_PREFIX) are now URNs starting withurn:fdc:helger.com:phoxtrot:jaxp:instead ofhttp://helger.com/phoxtrot/jaxp/, andXdmSource.FEATUREisurn:fdc:helger.com:phoxtrot:jaxp:feature:xdm-source; the old names are no longer accepted - JAXP:
PhoxtrotTransformerFactorynow hasFEATURE_SECURE_PROCESSINGon by default (newDEFAULT_SECURE_PROCESSING), soACCESS_EXTERNAL_STYLESHEETandACCESS_EXTERNAL_DTDdefault to the empty string (DEFAULT_ACCESS_EXTERNAL;ACCESS_EXTERNAL_ALLisall) andxsl:result-documentwithhrefdoes not compile: includes, imports and documents need aURIResolveror an allowed scheme. Setting the feature tofalsenow sets both access attributes toall - JAXP: new
PhoxtrotTransformer.setCurrentDateTimeto fix the value offn:current-dateTime() - Schema-awareness: Apache Xerces-J is no longer supported as schema processor; the native validator (
phoxtrot-xsd) is the only one. Removed the packagecom.helger.phoxtrot.xdm.xerces, the optional dependency onxerces:xercesImpland the system propertyxdm.schemaProvider(XdmSchemaSupport.SYSTEM_PROPERTY_PROVIDER) - XPath:
fn:parse-xmlcan read the external DTD subset and external entities of the parsed string through an entity resolver (newDynamicContext.setParseXmlEntityResolver,XsltTransformRequest.setParseXmlEntityResolver; JAXP: the transformer's entity resolver when the factory loads external entities); without one nothing is read, as before. Relative references are resolved against the static base URI (newXdmParser.parse (String, String)) - XPath: the optional Static Typing Feature (
StaticContext.setStaticTyping) now infers the static type of every expression and raises a type error where the inferred type is not accepted: function arguments (after the function conversion rules, function coercion included), arithmetic, comparison, cast and range operands, path operands (XPTY0019/XPTY0020), dynamic calls and lookups, and inline function bodies against their declared return type; and XPST0005 for every expression other than()anddata(())inferred asempty-sequence(). Before, it only rejected provably empty axis steps. It is pessimistic: hosts declare the types of what they supply with the newStaticContext.setContextItemStaticTypeandStaticContext.declareVariable (name, SeqType)(otherwise the context item isitem()and a variableitem()*)
v0.2.0 - 2026-11-14
- XSLT: the static context of every expression shares the set of the global variable names instead of copying it
(Schematron stylesheets with hundreds of globals compile 30 to 40 % faster); new
StaticContext.declareSharedVariables - XPath/XSLT: the
xs:integervalues from -128 to 127 are shared instances; attribute value templates andxsl:value-oftake the string of a single atomic value directly; the serializer appends runs of characters that need no escaping in one go - XSD: identity constraints build the key of one field without a list and join, and do not cast
xs:stringvalues; the XSD 1.0 check of late schema location hints adds a namespace to its set only when it changes - XSD 1.1: with assertions in the schema, the types recorded for the typed values that assertions read are dropped whenever no element with assertions is open, so the record no longer grows with the document (10,000 invoice lines: 29 % faster, a quarter of the GC time); the per-name child counts of the dynamic EDC check are only kept for a content model with a lax or strict wildcard (from go-xslt 0.4.3)
- XPath:
fn:tokenize,fn:replaceandfn:matcheswith a pattern of plain characters (no flags and no metacharacter, or theqflag) search the string without a regular expression (44 % faster);format-date,format-dateTimeandformat-timerender pictures of ASCII digits only ([D01],[Y0001]) without parsing a digit pattern (40 % faster, 63 % less allocated) (from go-xslt 0.4.3) - XPath:
fn:pathcounts the sibling positions of the children of a parent once per run, so the paths of many siblings are linear; a predicate comparingname(),local-name()ornamespace-uri()with a value that is the same for every candidate ([name() = name(current())], also joined withand) evaluates that value once and compares the names directly (ISO Schematron locations about 4 to 7 times faster).FnAccessor.getName,getLocalNameandgetNamespaceUriare public; the XSLTcurrent()isFnContext.XSLT_CURRENT - XPath/XSD: regular expressions with category escapes (
\w,\W,\d,\p{..}) are fast again on JDK 24 and later: an input without a code point whose category changed after Unicode 15.0 is matched with the built-in classes of the JDK instead of the corrected ones (same result); newXPathRegex.getPattern (String) - XPath:
XPathStreamabilityAnalyzerhas a burst context mode (setContextMode (EStreamContextMode.BURST), verdictEStreamabilityVerdict.BURST): is an expression evaluable on the buffered subtree of the context node, and if not, which construct leaves it; addedaddExternalNodeVariable. Behaviour change:XPathStreamabilityResult.isStreamable ()istruefor motionless and consuming only;isBurstStreamable ()includes burst - XPath: in burst mode
XPathStreamabilityAnalyzer.analyzePatterngivesBURSTfor a pattern whose last-step predicates need only the subtree of the matched node (cac:Line[cbc:Quantity < 0]), and navigating from an external node variable is free-ranging also in an otherwise motionless expression. In streamed and burst mode the context node is taken to be no document node:/xis the document element, an ancestor-or-self (/x/@a,name (/*)motionless,/x/ystill free-ranging) - XPath:
XPathStreamabilityAnalyzer.analyzeBindingandaddBoundVariabledeclare a variable with a binding expression compiled once (e.g. asch:letshared by the assertions of a rule); every analysed expression gets the result of the same expression inlet $a := (...) return - XPath: added
FunctionLibrary.createDefaultWithXsltSignatures (), the built-in functions plus the signatures of the XSLT functions (fn:key,fn:current,fn:document, ...) for hosts that only compile and analyse expressions - API change: every
IResourceResolvermethod now takes aResourceUri(the resolved URI, the reference as written and its base URI) instead of the absolute URI as string; implementations useResourceUri.absoluteUri () - JAXP: the
URIResolveris now called as JAXP specifies, with thehrefas written and the base URI (the empty string without one), so a resolver can apply its own default base for a stylesheet without system ID - JAXP: a transformation into a
DOMResultorSAXResultno longer serialises the result it never uses; addedXsltTransformRequest.setPrincipalTreeOnly - Added
IXdmNode.declaredNamespaces (), a read-only view of the own namespace declarations without copying, used by the serialiser and the DOM and SAX bridges - JAXP: with
FEATURE_SECURE_PROCESSINGa stylesheet with anxsl:result-documentthat has anhrefattribute now fails to compile with XTSE0010, as in Saxon; addedXsltCompileOptions.setSecondaryResultsAllowed, inherited byfn:transform - XPath: a union of single attribute and child steps without predicates, such as
*|comment()|processing-instruction()or@*|*, is evaluated in one pass over each axis without sorting (as in the ISO Schematron skeleton) - XSLT: pattern matching creates no new dynamic context for a path pattern without predicates such as
/root/itemornode() - XSLT: the elements built by one literal result element share one map of namespace declarations until one of them
changes; added
IXdmNode.declareSharedNamespaces XdmDocumentNode.getChildElementsByNameno longer builds the name index of the whole document; it goes through the children of the parent once and keeps the resultDomToXdmallocates less than half as much per conversion (no per-node walk records, attribute and namespace objects only where needed, DOM text used without copying); addedXdmTreeBuilder.characters (String)- JAXP: added the factory attribute
ATTR_MAX_DEPTHandPhoxtrotTransformer.setMaxDepthfor the nesting depth limit of templates and functions - JAXP: the output properties are kept in the unsynchronised
NonBlockingPropertiesof ph-commons; the JAXP methods still take and returnjava.util.Properties - Behaviour change:
XsltTransformRequest.setMaxDepthcan now raise the limit above the default of 10,000; addedXsltTransformRequest.UNLIMITED_DEPTHfor no limit but the stack - Behaviour change:
fn:generate-idnow returns values of the formd1n5(tree number and node number) instead ofid5, so they no longer collide with IDs likeid1written by authors - Added
PhoxtrotVersionwith the version number and build timestamp of phoxtrot - Updated to ph-commons 12.6.0 and replaced own helpers with its new ones (code points, XML whitespace and name
characters, hex output, primitive
intcollections) - The caches of compiled regular expressions and UCA collations are now readable without locking
- JAXP: added the factory attribute
ATTR_ENTITY_RESOLVERandPhoxtrotTransformer.setEntityResolver, used for the external DTDs and entities of stylesheets, modules, sources and documents read at run time - JAXP:
XMLConstants.ACCESS_EXTERNAL_DTDis now applied (newXdmParser.setAccessExternalDtd), so secure processing also stops external DTDs and entities that only the entity resolver may then provide - JAXP: a
jar:URI is only read directly ifACCESS_EXTERNAL_STYLESHEETallowsjarand its nested URI - A
URIResolverthat refuses a URI now gives a located error with its reason: XTSE0165 forxsl:includeandxsl:import, XTSE0020 forxsl:output parameter-document, XTSE3000 forxsl:use-package, FOXT0002 forfn:transform, FODC0002 fordocument()anddoc(), FOUT1170 forunparsed-text()andjson-doc() - A document read directly that is not well-formed is now logged as a warning
- The
schema-locationofxsl:import-schemais now read through the resolver of the compile options (in JAXP theURIResolverandACCESS_EXTERNAL_STYLESHEET); addedXsltCompileOptions.setReadLocalSchemaFiles - Schema processors never read referenced schema documents from the network; added
IXdmSchemaProvider.compile (List, boolean)to forbid local reads as well, and the Xerces-J provider now uses secure processing - Behaviour change:
XsdSchema.validateno longer follows thexsi:schemaLocationhints of an instance unlessXsdValidationOptions.setFollowSchemaLocationHints (true)is set - Added
FunctionLibrary.freeze: the function libraries of a compiled stylesheet are now frozen, so a static function call no longer reads the modification stamp of the library chain on every call - Behaviour change: registering into the function library of a compiled stylesheet (e.g. the one of
XsltExecutable.createStaticContext) now throws anIllegalStateException; register into acreateChild ()instead - XPath: a call of a built-in function whose value only depends on the context item and its variables is evaluated
once while they stay the same, e.g.
normalize-space($item/a)in a predicate ornormalize-space(a)in the body of asome/every/for(loop-invariant hoisting); newDynamicContext.getVariableToken,getRunMemoandgetLoopFocus - XPath:
//namefrom the document node and a child step from a node with many children reuse one sequence of the name index per run instead of copying it on every step; newAxisNavigator.getNamedIndexList - API change:
EXsltThreadingis nowcom.helger.phoxtrot.xpath.EThreadingandLargeStackRunnermoved tocom.helger.phoxtrot.xpath(modulephoxtrot-xpath), so plain XPath evaluations can use the large-stack threads - XPath: added a step limit for plain XPath (
DynamicContext.setMaxSteps, XPDY0130 when exceeded, unlimited by default) - XPath: added
CompiledXPath.getFreeVariables(the variables of the static context an expression uses) - XPath: a static error now has its position in the expression (
XPathException.getExpressionOffset,getExpressionLine,getExpressionColumn) - XPath: added
FunctionLibrary.register (XdmQName, List, SeqType, IXPathFunction)for extension functions with typed signatures; the argument conversion is documented inIXPathFunction - XPath: the public API of
phoxtrot-xpathis listed in the README and the package documentation - XSLT: an error raised in the body of an
xsl:functionnames that function (XsltException.getFunctionFrame) - DOM bridge: added
DomToXdm.convertWithMapping, which keeps the DOM node of every XDM node (DomNodeMapping) - DOM bridge: added
XdmDomView, a read-only W3C DOM view over an XDM tree that copies nothing - XPath: added
XPathStreamabilityAnalyzer, the public streamability analysis of expressions and patterns;EPosture,ESweep,PostureSweepandEStreamFunctionCategoryofstreamare now public API
v0.1.0 - 2026-11-10
- Initial release
- XSD 1.0 and XSD 1.1 support
- XPath 3.1 support
- XSLT 3.0 support incl. streaming
Copyright (C) 2026 Philip Helger. Licensed under the Apache License, Version 2.0.
My personal Coding Styleguide | It is appreciated if you star the GitHub project if you like it.