
Choosing Between XSLT XQuery and a Script for XML Jobs
The same grouping job in XSLT 1.0, XSLT 2.0, XQuery and Python gave the same revenue to the cent. How the four compare on speed, length, exactness and fit.
Tag
9 posts

The same grouping job in XSLT 1.0, XSLT 2.0, XQuery and Python gave the same revenue to the cent. How the four compare on speed, length, exactness and fit.

Query XML with XQuery in BaseX: for, let, where, order by and return, group by with exact decimals, and element constructors, on two sample files.

Compile a stylesheet once with lxml, pass parameters safely, read xsl:message from the error log, block file and network reads, and know the 1.0 limit.

Pass values into XSLT from xsltproc and lxml, and see why a param that looks like a string is read as an XPath expression and silently ignored.

Sort with xsl:sort and filter with XPath predicates in XSLT, and avoid the default text sort that put 250000 after 44.00 and 29.50. Multiple keys and case.

Group 20,000 invoices by currency with a Muenchian key in XSLT 1.0 and with for-each-group in XSLT 2.0 on Saxon, with sums, counts and timings.

How an XSLT processor decides what to run: template match patterns, apply-templates, the built-in rules that dump text, modes, and the identity template.

Five stylesheets that output nothing or the whole file as text, with the cause of each: a namespace, a built-in rule, an absolute path, and a literal id.

A working guide to XSLT 1.0, 3.0 and XQuery on the same files: templates, grouping, enrichment, JSON output, parameters, debugging, speed and which to pick.