Subject: Re: [xsl] General rule for designing XPath expressions to return items in document order? From: Michael Kay <mike@xxxxxxxxxxxx> Date: Fri, 10 Jan 2014 12:01:23 +0000 |
On 10 Jan 2014, at 10:56, Costello, Roger L. <costello@xxxxxxxxx> wrote: > David wrote: > > I haven't checked the streaming rules in detail > but I would expect //head to be streamable. > (You might not be able to access any of the > child nodes in a streamable way but for example > count(//head) ought to be able to count all the > head in the document in a single pass. > > Michael responded: > > That's a fair summary. //head is "consuming" > (it reads the input stream), and "crawling" > (it accesses all the nodes in the subtree). When > you get an expression that is consuming and > crawling, you are allowed to do "inspection" > operations on the result, for example count() > > But Michael doesn't that contradict section 19.1 of the XSLT 3.0 specification: > > For example <xsl:value-of select="//head"/> will > still fail the streamability tests, because of the > possibility that one head element is a child of > another. This problem can be remedied by > writing <xsl:value-of select="//head/text()"/>. > > No, there's no contradiction: (1) <xsl:value-of select="//head"/> isn't allowed for the same reasons that //head/data() isn't allowed: xsl:value-of is an "absorption" operation. (2) The fact that <xsl:value-of select="//head/text()"/> is allowed doesn't contradict anything I said. It's allowed because a) Under section 19.1, it gets turned into //text()[parent::head] or equivalent b) Unlike //head, //text() is "striding" - the nodes it selects are non-overlapping (because text nodes never overlap). So absorption operations like data(), string(), and <xsl:value-of> are allowed. I suspect you're making the mistake of thinking that //head/text() is very similar to //head/string(). But that's only true when every <head> element has a single text node child. Michael Kay Saxonica
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] General rule for designin, Andrew Welch | Thread | Re: [xsl] General rule for designin, David Carlisle |
Re: [xsl] General rule for designin, Andrew Welch | Date | Re: [xsl] How to avoid adding defau, David Carlisle |
Month |