I'm having a devil of a time getting discard-document to work properly.

I'm working with a sequence of files one at a time. The uri for the files are stored as the @file attribute for nodes in the tree.

The basic structure of my XSL is:

<xsl:for-each select="//student">

[Print some information to the output file]

<xsl:for-each select="document(sessionExtractor/@file)/pedagogicalTrace/session">
       
[Do a bunch of stuff with these nodes]

</xsl:for-each>
</xsl:for-each>

I wanted to use saxon:discard-document() to regulate memory, but when I tried using:


<xsl:for-each select="saxon:discard-document(sessionExtractor/@file)/pedagogicalTrace/session">

I got an error:

Cannot convert value class net.sf.saxon.dom.NodeWrapper of type attribute() to class net.sf.saxon.om.DocumentInfo


I don't see why this is not working. I get the same error when I set a variable equal to discard-document() and then try to use that variable in for-each statement.

I then tried using discard-document after the loop had finished:

<xsl:for-each select="//student">

[Print some information to the output file]

<xsl:for-each select="document(sessionExtractor/@file)/pedagogicalTrace/session">
       
[Do a bunch of stuff with these nodes]

</xsl:for-each>

<xsl:for-each select="discard-document(sessionExtractor/@file)"/>

</xsl:for-each>

That did not throw an error, but it also failed to regulate memory.

Could someone shed some light on why I'm getting the error in the first place and why the second option (first doing the work with the document's nodes and then setting it to be discardable) did not have the desired effect?

Thanks,
David

--

"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.