Hi Michael
...
> > and got the same results. However the further improvement to
> >
> > <xsl:template match="/ | node()" mode="create-ids:define-id">
> > <xsl:copy>
> > <xsl:apply-templates select="@*"/>
> > <xsl:attribute name="xmi:id">
> > <xsl:value-of select="generate-id()"/>
> > </xsl:attribute>
> > <xsl:apply-templates select="node()"/>
> > </xsl:copy>
> > </xsl:template>
> >
> > fails. It seems that when the stylesheet function is called,
> > the current mode has not become the default.
> >
>
> Yes, that's correct. The default mode is still the "unnamed" mode, not
> the current mode. Your "further improvement" is pure XSLT 1.0 code, so
> it must have the XSLT 1.0 semantics.
Perhaps this should transfer to the XSLT spec list to discuss editorial
clarification, since Saxon is clearly doing what you think XSLT 2.0
says it should.
It seems to me that XSLT 2.0 12 Nov 2003, 6.5
"Modes are identified by a QName, except for the default mode, which is
unnamed"
"The xsl:apply-templates element also has an optional mode attribute. The
value ... If the attribute is omitted, the default mode is used."
implies the behaviour that you call correct, but then
"[Definition: ... When a stylesheet function is called, the current mode
becomes the default mode. ...]"
suggests that in my 'further improvement' each invocation of apply-templates
is invoking the default mode.
But on more detailed reading "is called, the current" suggests that it is
the
current mode immediately prior to the call, (that of the caller), rather
than that
of the callee that becomes the default. This could give very strange
behaviours,
the execution of a template with unnamed mode would then be subtly dependent
on
the calling path ...
Even this fails as demonstrated by the following hybrid
<xsl:template match="/ | node()" mode="create-ids:define-id">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="xmi:id">
<xsl:value-of select="generate-id()"/>
</xsl:attribute>
<xsl:apply-templates select="node()" mode="#current"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*" mode="create-ids:define-id">
<xsl:copy-of select="."/>
</xsl:template>
The "@*" rule is invoked from a tree traversal by the "node()" rule, so at
each level of descent, (except possibly at the entry level) the default mode
has been set to the current mode which is create-ids:define-id. Therefore
when
apply-templates is performed for attributes the current mode is
create-ids:define-id and so should be used as the default. It isn't.
The possible editorial ambuiguity is that:
"the default mode, which is unnamed"
implies a permanaent equivalence which Saxon implements.
"the current mode becomes the default mode"
undermines the equivalence justifying my expectation.
Regards
Ed Willink
------------------------------------------------------------------------
E.D.Willink, Email:
mailto:EdWillink-7KbaBNvhQFM@xxxxxxxxxxxxxxxx
Thales Research and Technology (UK) Ltd, Tel: +44 118 923 8278 (direct)
Worton Drive, or +44 118 986 8601 (ext 8278)
Worton Grange Business Park, Fax: +44 118 923 8399
Reading, RG2 0SB
ENGLAND http://www.computing.surrey.ac.uk/personal/pg/E.Willink
------------------------------------------------------------------------
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
|