logo       


RE: Default rather than current template mode: msg#00103

Subject: RE: Default rather than current template mode
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


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe