Re: [xsl] General rule for designing XPath expressions to return items in document order?

Subject: Re: [xsl] General rule for designing XPath expressions to return items in document order?
From: John Lumley <john@xxxxxxxxxxxx>
Date: Sat, 11 Jan 2014 14:09:17 +0000
On 10/01/2014 16:33, Costello, Roger L. wrote:
For those of us who will not be attending XML Prague, how can we learn the streaming stuff that Michael and Alex will be presenting?

It remains to be seen I think how far just having a naive mental model
>of the kind of things that ought to work in a streaming context will
>lead to expressions that are in fact defined to be streaming in the spec
>(or are streaming in the implementations).
Indeed. I think this is the topic of Abel Braaksma's talk at XML Prague: from what I've seen, I believe his aim is to show that the horrendously complex rules in the spec can be reduced for practical programming purposes to a few easily remembered rules of thumb. Let's wait and see.
I have been working on a static analysis tool that runs the streamability rules over an XSLT transform (and the associated XPaths) and displays the results in terms of a decorated tree where all the properties described in the rules (type, role, posture, sweep, etc...) have been calculated, and thus the /guaranteed streamability/ of templates determined.

The first phase produces a decorated AST (XSLT tree plus parsed XPath trees inserted /in place/) with all these properties attached as namespaced attributes, as well as the specific cases that have been applied in areas such as the general streamability rules and hyperlinks to the appropriate sections of the spec.

A further phase serializes this tree into an HTML page, which with Saxon-CE interaction, enables selective exploration of these properties, and displays the rules on streaming that are directly relevant to the fragment of program being examined.

Some of the XSLT Working Group will have seen an early version of this during some of its meetings. We should be able to demonstrate the tool at XMLPrague. All the examples covered in the specification (and many in the testsuite) have been analysed and can be examined.

We intend to complete this tool and make it available as a web-based service from the Saxonica site, where (fragments of) stylesheets can be uploaded and the resulting analysed trees examined. Most of the main instructions and expression constructs should be covered, but don't expect first off for absolutely everything to be supported.

[Please note that these ASTs can get very big indeed - even comparatively trival XPath expressions such as //section/head[matches(.,$noteworthy-words)] can generate sizeable buried trees. So don't expect to be able to analyse the whole of your 20k line XSLT program at one go!]

John

--
*John Lumley* MA PhD CEng FIEE
john@xxxxxxxxxxxx <mailto:john@xxxxxxxxxxxx>
on behalf of Saxonica Ltd

Current Thread