Well, speaking from my position as a rote amateur who nonetheless really makes use of XSL a lot, it seems that would make it difficult when you actually needed to use the current context item because (evidently) <xsl:iterate> has scoping issues that other instructions do not. In particular, I was unable to use a dummy variable to pass in the nodes I wanted:

In other words, I got an error when I tried this:

<xsl:variable name="dummy" select="preceding-sibling::element()[item]/descendant::item[@type='fact']/@id"/>
<xsl:iterate select="descendant::item">
<xsl:param name="previousfacts" select="$dummy"/>


I had tried this earlier with the script in question, and i got an error:

[
Engine name: Saxon-EE 9.3.0.5
Severity: error
Description: *** Internal Saxon error: local variable encountered whose binding has been deleted
]

-David


On Thu, Sep 6, 2012 at 11:14 PM, Michael Kay <mike@saxonica.com> wrote:

On 06/09/2012 19:02, David Rudel wrote:
Hi all,
I just figured this out... when the "xsl:param" command is executed, the context item is whatever it was before the <xsl:iterate> command occurred. I assumed the context item was already the first item being processed.
Yes, I was going to suggest that. I can't say I'm very happy with the spec here - I wonder if it would be better to evaluate the initializer with the context item "absent", so this would be an error.

Michael Kay
Saxonica

-David

On Thu, Sep 6, 2012 at 7:56 PM, David Rudel <fwqhgads@gmail.com> wrote:
Hi all,

In one of my scripts, a parameter inside xsl:iterate is not being set to its initial value.

The segment of the script in question is shown below:

<xsl:iterate select="descendant::item">
                        <xsl:param name="previousfacts" select="../preceding-sibling::element()[item]/descendant::item[@type='fact']/@id" as="xs:string*"/>
                        <debug readout1="{count($previousfacts)}"
                            readout2="{$previousfacts}"
                            readout3="{../preceding-sibling::element()[item]/descendant::item[@type='fact']/@id}"
                        />
</xsl:iterate>

When I run this script I get the following output for the first item processed:

<debug readout1="0" readout2="" readout3="15 30 171 42 14 30 3 199 222 71 172 199 79 71 42 300 199 11"/>

It seems that "previousfacts" is being initialized as an empty sequence even though the Xpath expression inside its select attribute provides a sequence of 18 items.
I've tried omitting the "as" attribute, and I've also tried creating a sequence constructor and also tried using "for $i in ../preceding-sibling::element()[item]/descendant::item[@type='fact'] return $i/@id"  None of them manage to cause the sequence to initialize as anything other than the empty sequence.

I realize I'm not sending the whole script or the source file, etc., but I'm hoping the above is enough for someone to figure out what I'm doing wrong.

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



--

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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--

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