Thanks Michael,
You mention that the Saxon 9.5 implementation is less restrictive, so I went to the Saxon documentation. The Saxon:stream documentation referred me to the xsl:stream function --- which is what I'm sure you are referring to, as I notice you use xsl:stream in your example.

However, I did not see a documentation entry for xsl:stream in the saxon XSL reference. Will an entry for xsl:stream be added to the interactive Saxon documentation?

The W3C Working draft for xsl:stream is a bit confusing because it gives several examples [http://www.w3.org/TR/xslt-30/#stream-examples] of how xsl:stream may be used, but prefaces those examples by a disclaimer saying they no longer work. It is not clear if the "they" here refers just to the next group (dealing with aggregate functions) or if it refers to all the examples.

-David



On Sat, May 11, 2013 at 6:52 PM, Michael Kay <mike@saxonica.com> wrote:

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="."/>
    <xsl:break/>
  </xsl:iterate>
</xsl:stream>

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
Saxonica



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.

<screenplay>
<title>Fight Club</title>
<author> ....</author>
<anita> ....</anita>
<bob>....</bob>
<anita>....</anita>
<julie>....</julie>
</screenplay>

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?

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.
------------------------------------------------------------------------------
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/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help


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