I think the most reliable way to achieve this is using xsl:iterate and xsl:break. Something like

<xsl;stream href="input.xml">
  <xsl:iterate select="/screenplay/title">
    <xsl:value-of select="."/>

I think this should work but would need to test it to be 100% sure.

You're quoting the 9.4 documentation, but 9.5 is quite a bit more flexible in what it allows in streamable expressions.

Michael Kay

On 11 May 2013, at 15:42, David Rudel wrote:

Hi all,
I'm trying to use saxon:stream to read in short snippets of several small documents. However, after reading the documentation on saxon:stream [http://saxonica.com/documentation9.4-demo/html/sourcedocs/streaming/streamable-xpath.html], I don't know how to limit how much of the streamed document gets read when I know the information is near the top of the file.

The issue (for me) is how to limit the reading without using position()-based predicates.

Example, imagine a source file contains biographical information for a screenplay followed by the full text of the script broken apart into lines of dialogue with each the name of an element being the character speaking the line.

<title>Fight Club</title>
<author> ....</author>
<anita> ....</anita>

Now, let's say I just wanted to pull the "title" information from each of many such files. I know that there is only one <title> child to element <screenplay> and I know it is the very first child, but I don't see how to convey that information to the processor so it knows it does not have to look through all the (many) children of <screenplay> to find the title.

Of course, I would like to do something like saxon:stream(document(source.xml))/screenplay/element(title)[1], but the documentation says that predicates cannot evaluate to numbers or otherwise use the "position()" function.

Are there some tips or tricks that can be used to limit the amount of the source file that is read when one knows the information is near the top?



"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.
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/