Just for clarity, it was my understanding that uri:collection just returned the names of the files, and did not even care whether the files were well-formed xml, allowing the output to be processed using, for exmaple, the unparsed-text() command.  Thus, I'm surprised to see uri-collection() causing trees to be built at all.


On Tue, May 14, 2013 at 11:45 AM, David Rudel <fwqhgads@gmail.com> wrote:
I have found the reason for one of my streaming problems.

I am using uri-collection to read in a bunch of URIs. The xslt3 documentation indicates that one of the reasons uri-collection may be favored over collection() is that the former allows streaming.

However, running the following with the -t command indicates that uri-collection() is causing entire trees to be written into memory in Saxon 9.3.0.5, run through oxYgen:

<xsl:stylesheet version="3.0"
    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="xs saxon">

    <xsl:template match="/">
<xsl:variable name="path" select="replace(base-uri(),'(.*/)[^/]+?.xml','$1')"/>
<studentData>
    <xsl:for-each select="(uri-collection(concat($path,'?select=*.xml;recurse=yes;on-error=ignore')))">
    <xsl:text>
        </xsl:text>
        <xsl:value-of select="."/>
    </xsl:for-each>
    </studentData>
</xsl:template>
</xsl:stylesheet>


I also tried using xsl:iterate and saxon:iterate [based on the information in the documentation for Saxon 9.3], and trees were being built in all cases.

I don't see how to use saxon:stream() in this case because the entire tree is being built by uri-collection() before the document ever sees saxon:stream().



--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.



--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.