W3C home > Mailing lists > Public > xsl-editors@w3.org > January to March 2000

RE: xsl:attribute error

From: Kay Michael <Michael.Kay@icl.com>
Date: Tue, 18 Jan 2000 10:42:47 -0000
Message-ID: <93CB64052F94D211BC5D0010A800133101FDE936@wwmess3.bra01.icl.co.uk>
To: "'Andrew Wason'" <aw@softcom.com>
Cc: "'xsl-editors@w3.org'" <xsl-editors@w3.org>
> Running Saxon 5.1 results in this error:
> At xsl:attribute on line 10 of file:/S:/projects/xsl/attr.xsl:
> Cannot write an attribute when there is no open start tag
> The XT processor sucessfully processes the document.

My view is that the stylesheet [below] is wrong. It works in xt because xt
does lazy evaluation, so by the time it evaluates the xsl:attribute
instruction there is an element node for the attribute to attach to. But the
spec doesn't require lazy evaluation, and only allows it if it gives the
same effect as immediate evaluation. The spec says that the xsl:with-param
element is instantiated to create a result tree fragment, and the
xsl:attribute element is then instantiated to add an attribute to the root
of the result tree fragment, which is an error because there is no element
node. The implementation is supposed either to signal this error or to
ignore the attribute.

Unfortunately with xsl:attribute the spec does seem to make assumptions
about order of execution: one of the errors described in section 7.1.3
actually uses the word "after".

Mike Kay

	<xsl:template match="node">
		<xsl:apply-templates select="."
			<xsl:with-param name="attrs">
				<xsl:attribute name="href">
					<xsl:value-of select="'foobar'"/>
			<xsl:apply-templates select="*"/>
	<xsl:template match="*" mode="duplicate-node-with-attrs">
		<xsl:param name="attrs"/>
		<!-- Copy node -->
			<!-- Copy existing node attrs -->
			<xsl:copy-of select="@*"/>
			<!-- Override/add param attr -->
			<xsl:copy-of select="$attrs"/>
Received on Tuesday, 18 January 2000 05:43:37 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:44:17 UTC