Question about which XPaths can be evaluated on a DOM as it is beingbuilt by a stream
A question.
My scenario is I have a SAX stream, which comes in and builds a DOM. I want to get Schematron validation results ASAP but chunked to the element not the start-tag: for this, just running as many assertions for an element as soon as its end-tag arrives is good enough. I.e. progressive bottom-up validation.
(Yes, I am aware that there are other categories possible, such as what can be known at start-tag. I guess I should re-read XPath3/XSLT3 to see if they have defined anything here for their streaming.)
So I want to categorize the assertions and rules into two buckets: those that can always be assessed right away at the end-tag, and those that may not. And hopefully without having to fully parse the XPath, or to minimally parse them.
For minimal Schematron, this would be rule/@context, assert/@test, let/@value. (Lets leave keys, value-of, etc. off.) For XSLT, this would be the equivalent of the xsl:template/@match and xsl:template//*/@test and xsl:variable/@select.
So to get those that can be reliably assessed, is this enough:
- The XPath does not contain
- "following" or
- "position(" or
- have a upward axis followed by a downward axis or
- a predicate with a positional indicator AND
- It does not contain a reference to any variable (or function, or named xsl:template) which does, at any depth
The first three of the tests are trivial string matching, but the last one is more difficult: it looks like it requires a parse with awareness of resulting type.
So my questions are: is there some missing case, and is there some cheapo way to determine if a numeric positional predicate is being used?
Cheers
Rick