Project

Profile

Help

Is early exit of input parsing occuring during use of items-x functions reported with -t option?

Added by Martin Honnen about 4 years ago

The documentation of the new functions like items-before (in http://saxonica.com/documentation/index.html#!functions/saxon/items-before) explains

Where possible, reading and parsing of the source document will be abandoned when an item matching the predicate is encountered

Would such an early exit be reported by the -t option, like it is the case for xsl:break?

I don't get any indication with code like

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/"
    exclude-result-prefixes="#all" version="3.0">
    
    <xsl:output indent="yes"/>
    
    <xsl:mode streamable="yes" on-no-match="shallow-skip"/>
    
    <xsl:template match="/">
        <items>
            <xsl:sequence
                select="saxon:items-before(root/items/item, function ($i) { $i/@cat = 'bar' })"
            />
        </items>
    </xsl:template>
    
</xsl:stylesheet>

and a sample like

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <items>
        <item cat="foo">
            <value>item 1</value>
        </item>        
        <item cat="foo">
            <value>item 2</value>
        </item>
        <item cat="foo">
            <value>item 3</value>
        </item>
        <item cat="foo">
            <value>item 4</value>
        </item>
        <item cat="foo">
            <value>item 5</value>
        </item>
        <item cat="bar">
            <value>item 6</value>
        </item>
        <item cat="bar">
            <value>item 7</value>
        </item>
        <item cat="bar">
            <value>item 8</value>
        </item>
        <item cat="bar">
            <value>item 9</value>
        </item>
    </items>
</root>

The -t option indicates streaming but doesn't report an early exit. However, the resulting document is correct.


Replies (1)

RE: Is early exit of input parsing occuring during use of items-x functions reported with -t option? - Added by Michael Kay about 4 years ago

This set me on a train of thought about early exit, and the first observation was that we're not actually checking our test results carefully enough to see that tests that are expected to do early exit are actually doing so. I've raised that as a bug on the test driver (#4494) and I'll pursue it under that heading. Initial results show that many tests where early exit is expected are not reporting early exit, but I don't yet know if that's a failure to perform early exit or a failure to report it.

    (1-1/1)

    Please register to reply