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.