Hi Folks,
I want to count the number of Book elements in BookCatalogue.
I want to do it using XSLT Streaming.
Below are two solutions. One uses <xsl:stream>, the other uses <xsl:mode>.
Two Questions Please:
1. Are my two solutions equivalent?
2. I ran my solutions and they produced the correct result. They ran fast, but
the input document is small (only 3 Books). How do I know that the input
document was actually processed in a streaming fashion?
I am running the transformations using the latest version of oXygen XML.
/Roger
----------------------------------------------------------------------------------------------
Specify that stream processing is desired by embedding the
instructions within a <xsl:stream> element:
----------------------------------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:stream href="BookCatalogue.xml">
<count>
<xsl:for-each select="BookCatalogue">
<xsl:iterate select="Book">
<xsl:param name="count" select="0" as="xs:decimal"/>
<xsl:next-iteration>
<xsl:with-param name="count" select="$count+1"/>
</xsl:next-iteration>
<xsl:on-completion>
<xsl:value-of select="$count"/>
</xsl:on-completion>
</xsl:iterate>
</xsl:for-each>
</count>
</xsl:stream>
</xsl:template>
</xsl:stylesheet>
----------------------------------------------------------------------------------------------
Specify that stream processing is desired by specifying streaming
in the initial mode:
----------------------------------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
version="3.0">
<xsl:output method="xml" />
<xsl:mode streamable="yes" />
<xsl:template match="BookCatalogue">
<count>
<xsl:iterate select="Book">
<xsl:param name="count" select="0" as="xs:decimal"/>
<xsl:next-iteration>
<xsl:with-param name="count" select="$count+1"/>
</xsl:next-iteration>
<xsl:on-completion>
<xsl:value-of select="$count"/>
</xsl:on-completion>
</xsl:iterate>
</count>
</xsl:template>
</xsl:stylesheet>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--