xsl-list
[Top] [All Lists]

RE: [xsl] current()/self::* vs "."

2007-10-26 01:23:19
Saxon is implementing XPath 2.0, the others are implementing XPath 1.0. For
some reason (almost certainly an oversight), the XPath 1.0 grammar does not
allow "." or ".." to be followed by a predicate. (Although "." is defined
semantically as an abbreviation for self::node(), the syntax is such that it
cannot appear in all contexts where self::node() can appear. This was fixed
in 2.0.

Michael Kay
http://www.saxonica.com/

 

-----Original Message-----
From: Alan Stroop [mailto:alan(_dot_)stroop(_at_)gmail(_dot_)com] 
Sent: 26 October 2007 00:35
To: xsl-list
Subject: [xsl] current()/self::* vs "."

I've recently run into an issue where the self:: axis abbreviation "."
didn't work as expected when trying to apply-templates to the 
current node.  The stylesheet was tested against Saxon8.9b, 
Xalan-J, Xalan-C and MSXML with Saxon being the only one that 
didn't have an issue.
Errors returned were syntax errors to could not compile 
stylesheet.  I was able to get the stylesheet to work in all 
processors by using
current() or self::* or self::node() instead of the self::
abbreviation.

I find it hard to believe that the same bug is found in the 
three failing processors, but stranger things have happened.  
Does Mr. Kay have some insider knowledge that the authors of 
the other processors do not about the intricacies of "."?  
Following is a simplified version of the stylesheet and source xml:

XSL:
<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<!--
Template Name: bugtester.xsl
Author:        Alan Stroop
-->

    <xsl:template match="mcijis">
        <xsl:call-template name="IJISComplaint"/>
    </xsl:template>

    <xsl:template name="IJISComplaint">
        <Complaint>
            <xsl:apply-templates/>
        </Complaint>
    </xsl:template>

    <xsl:template match="complaintant">
        <CaseInitiatingParty.Person >
            <!-- change . to current(), self::*, self::node() 
or self::complaintant -->
            <xsl:apply-templates select=".[not(@alias) or 
@alias!='true'] " mode="personname" />
        </CaseInitiatingParty.Person>
    </xsl:template>

    <xsl:template match="complaintant" mode="personname">
        <PersonName>
            <xsl:value-of select="concat(first,' ',last)"/>
        </PersonName>
    </xsl:template>

</xsl:stylesheet>

XML:
<mcijis>
    <complaintant>
        <last>Roberts</last>
        <first>Bob</first>
    </complaintant>
</mcijis>

Can someone fill me in on what I could be missing or why 
Saxon seems to be the only voice of reason?

Thanks

--
<alan/>

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>