At 02:22 AM 6/5/2004, you wrote:
The variable item-elements is the root node of a temporary tree, and when
you apply-templates to it, the template rule invoked is the one with
match="/". Use apply-templates select="$var/*", or use a mode.
Note that Saxon 6.5 does not correctly enforce all the restrictions in the
XSLT 1.0 specification, which prevent you using a result tree fragment as a
node-set in this way.
To reiterate from a different direction, and expand: ordinarily you would
have to use an extension function purposefully on the variable to make this
work, as in
<xsl:apply-templates select="exsl:node-set($item-elements)"
mode="process-items"/>
But because your processor here is not perfectly conformant, it is letting
you get away with it.
This is worth noting because XSLT 1.0's restriction against processing the
results is a significant limitation on the language, which requires, if not
exactly workarounds, at least a particular philosophy of application; in
particular it limits its capabilities in upconversion, and requires an
external framework of some kind (if only the OS) to chain processes
together (as is often useful). But this boundary is being moved in XSLT
2.0. In many ways this will make XSLT 2.0 a significantly more powerful
language. Time will tell whether it is as easy (or hard) to learn and as
hard (or easy) to get into trouble with. (As here, in XSLT 2.0 you'll get
an infinite loop; in conformant XSLT 1.0 you'd get an error message unless
you invoked the function as above. Saxon 6.5 is acting like an XSLT 2
processor in this respect.)
Cheers,
Wendell
Michael Kay
> -----Original Message-----
> From: Roger L. Cauvin [mailto:roger(_at_)cauvin(_dot_)org]
> Sent: 05 June 2004 03:11
> To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
> Subject: [xsl] Select on Node List Variable
>
> I am having trouble understanding the behavior of the
> following stylesheet.
> I intended for the main template to build a node-list of
> <item> elements and
> then process them using another template, but instead Saxon
> 6.5.2 is giving
> me a stack overflow error. If I change the 'apply-templates' and
> corresponding template to use a mode, it works as intended
> (outputs 'hello'
> and 'goodbye').
>
> <?xml version="1.0" ?>
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"
> standalone="no"/>
>
> <xsl:template match="/">
> <xsl:variable name="item-elements">
> <xsl:element name="item">hello</xsl:element>
> <xsl:element name="item">goodbye</xsl:element>
> </xsl:variable>
> <xsl:apply-templates select="$item-elements"/>
> </xsl:template>
>
> <xsl:template match="item">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
>
> </xsl:stylesheet>
>
> Why the infinite loop?
>
> --
> Roger L. Cauvin
> roger(_at_)cauvin(_dot_)org
>
>
> --+------------------------------------------------------------------
> 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>
> --+--
>
>
--+------------------------------------------------------------------
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>
--+--
___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_
"Thus I make my own use of the telegraph, without consulting
the directors, like the sparrows, which I perceive use it
extensively for a perch." -- Thoreau