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 9.5.0.2 Here is my XSLT program: --------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <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> --------------------------------------------------------- And here is my XML document: --------------------------------------------------------- <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="BookCatalogue.xsl"?> <BookCatalogue> <Book> <Title>Six Great Ideas</Title> <Author>Mortimer J. Adler</Author> <Date>1981</Date> <ISBN>0-02-072020-3</ISBN> <Publisher>Macmillan Publishing Company</Publisher> </Book> <Book> <Title>Illusions</Title> <Author>Richard Bach</Author> <Date>1977</Date> <ISBN>0-440-34319-4</ISBN> <Publisher>Dell Publishing Co.</Publisher> </Book> <Book> <Title>The First and Last Freedom</Title> <Author>J. Krishnamurti</Author> <Date>1954</Date> <ISBN>0-06-064831-7</ISBN> <Publisher>Harper & Row</Publisher> </Book> </BookCatalogue> ---------------------------------------------------------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Grouping consecutive page, Wendell Piez | Thread | Re: [xsl] My first attempt at XSLT , Michael Kay |
Re: [xsl] Grouping consecutive page, David Carlisle | Date | Re: [xsl] My first attempt at XSLT , Michael Kay |
Month |