As it happens my most recent blog posting at
was on a related subject, and proposes facilities which will be
implemented in Saxon 9.5.
The internal error is of course a Saxon bug. I'd be grateful if you
could put together a free-standing repro that we can run to reproduce
the problem in-house. From experience, it's difficult to reconstruct
these problems without complete runnable code - it often depends on
factors in the source code that aren't obviously relevant.
Have you tried using ordinary XSLT keys for this? that is
<xsl:key name="p" match="doc" use="@from to @to"/>
You might like to try replacing the expression
saxon:expression('for $n in @from to @to return $n')
by the equivalent
saxon:expression('@from to @to')
to see if this makes any difference.
On 07/02/2013 00:02, David Sewell wrote:
> To simplify my situation, I have a lot of document metatadata elements that
> provide a start page and end page for a document. Let's say they look like this:
> <doc n="d1" from="1" to="5"></doc>
> <doc n="d2" from="5" to="11"></doc>
> <doc n="d3" from="12" to="18"></doc>
> where @from and @to contain page numbers. If I want to find the document(s) that
> are found on page 9, I can use a brute-force XPath value comparison. But I'm
> operating on a large collection of documents so I'd really like to leverage
> I can successfully create an index on <doc> elements that matches either @from
> or @to, like so:
> saxon:index(collection('URI')//doc, saxon:expression('@from, @to'))
> such that saxon:find($myVar, "5") will return documents d1 and d2 as expected.
> I thought I could be clever and use a for...return expression to produce an
> inclusive range, like so:
> saxon:expression('for $n in @from to @to return $n')
> But running it throws an error: "Internal error: invalid slot number for local
> variable (9)".
> Is this a bug? In principle, should that saxon:expression() work, or am
> I pushing past the limits of what saxon:expression() can do?
> David S.