qtspecs icon indicating copy to clipboard operation
qtspecs copied to clipboard

Defining a common function library for XPath, XSLT, and XQuery applications

Open michaelhkay opened this issue 1 year ago • 13 comments

This issue is motivated by Mary Holstege's talk at Balisage 2023: Adventures in Single-Sourcing XSLT and XQuery

https://www.balisage.net/Proceedings/vol28/html/Holstege01/BalisageVol28-Holstege01.html

It is also motivated by other issues that have been raised here proposing improved capabilities for writing applications in pure XPath.

I propose that we define a syntax for creating a module containing a set of function definitions that can be used to define a function library available to both XQuery and XSLT applications, and potentially also by pure XPath applications. A file should contain all the functions in one namespace. The format should be suitable for translation into other formats such as XSLT and XQuery, which means it should be in XML (though we could also consider JSON). We should provide XSLT stylesheets that convert libraries in this format into XSLT stylesheet modules or XQuery library modules.

Function signatures should be expressed in an XML syntax similar to xsl:function in XSLT.

Function bodies should generally be written in the form of a single XPath expression, though there should be fallback mechanisms to allow XSLT and XQuery implementations to be supplied in cases where XPath lacks sufficient expressive power.

There should be mechanisms to define the more important components of the static context, such as namespace bindings and dependencies on other function libraries.

We could consider using this format to publish "polyfill" implementations of many of the new XPath 4.0 functions.

michaelhkay avatar Aug 07 '23 17:08 michaelhkay