[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] My first attempt at XSLT streaming -- it works! But why?

Subject: [xsl] My first attempt at XSLT streaming -- it works! But why?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Wed, 21 Aug 2013 19:47:43 +0000

Hi Folks,

I have an XML document that contains a bunch of <Book> elements. I want my
XSLT program to use streaming to count the number of Books. I mimicked the
example in the XSLT spec, section 19.1.1 (Examples of xsl:stream).

My XSLT program produced the correct result. Yea! But then I read this at the
top of section 19.1.1 in the XSLT spec:

	These examples no longer work; it is no longer
	possible to compute an aggregate over descendant
	values using a path expression. Instead, traversal
	using templates is required.

Hmm, apparently my XSLT program should not have worked. So why did it work?

What is the "right" way to write the streaming code?

I am using oXygen XML, which uses Saxon

Here is my XSLT program:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    <xsl:output method="xml" />

    <xsl:template match="/">
        <xsl:stream href="BookCatalogue.xml">
                <xsl:for-each select="BookCatalogue">
                    <xsl:iterate select="Book">
                        <xsl:param name="count" select="0" as="xs:decimal"/>
                            <xsl:with-param name="count" select="$count+1"/>
                            <xsl:value-of select="$count"/>


And here is my XML document:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="BookCatalogue.xsl"?>
                <Title>Six Great Ideas</Title>
                <Author>Mortimer J. Adler</Author>
                <Publisher>Macmillan Publishing Company</Publisher>
                <Author>Richard Bach</Author>
                <Publisher>Dell Publishing Co.</Publisher>
                <Title>The First and Last Freedom</Title>
                <Author>J. Krishnamurti</Author>
                <Publisher>Harper &amp; Row</Publisher>

Current Thread