Subject: Re: [xsl] following-sibling is evil From: "Tony Graham tgraham@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 6 Jul 2014 15:48:10 -0000 |
On Sun, July 6, 2014 11:29 am, Michael Kay mike@xxxxxxxxxxxx wrote: > Any reasonably intelligent processor will do an "early exit" on such an > expression, which means it will only scan the following-sibling axis until > it finds the first node that matches the predicates. > > However, this kind of logic is still O(n^2), and the performance is > especially bad if there are few or no duplicates. > > It's much better to use constructs such as key() or distinct-values() or > xsl:for-each-group for this kind of processing, though it may be difficult > to achieve that in Schematron. FWIW you can use key() with the default XSLT binding of Schematron. From Appendix C of ISO Schematron: The XSLT key element may be used, in the XSLT namespace, before the pattern elements. If you didn't want to use keys and you had a Schematron processor with a XSLT 3.0 binding (e.g., if you revised the ISO Schematron XSLT 2.0 stylesheet to be and produce XSLT 3.0) then you should be able to write a 'early exit' anonymous function along the lines of fold-right() and use that. But, of course, it would be better if the processor recognised the intent of the following-sibling and did the early exit for you as Mike says. With XPath 2.0, you may be able to do something with 'some ... in ... satisfies ...', but you'd be back to hoping that the processor works out what's in 'in ...' one item at a time if changing to using that is actually going to save you time and/or memory. Regards, Tony Graham tgraham@xxxxxxxxxx Consultant http://www.mentea.net Chair, Print and Page Layout Community Group @ W3C XML Guild member -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Mentea XML, XSL-FO and XSLT consulting, training and programming
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] following-sibling is evil, Michael Kay mike@xxx | Thread | Re: [xsl] following-sibling is evil, Andrew Welch andrew. |
Re: [xsl] following-sibling is evil, Wolfgang Laun wolfga | Date | Re: [xsl] following-sibling is evil, Liam R E Quin liam@x |
Month |