[ 
http://issues.apache.org/jira/browse/XALANJ-1651?page=comments#action_12356629 
] 

Warren Omohundro commented on XALANJ-1651:
------------------------------------------

Another example that fails due to using 'last()'  --  the template 
create-button-panel produces erroneous  duplicate  elements, 
while the template create-button-panel2 (which does not use last()) produces 
the proper elements

<?xml version="1.0" encoding="UTF-8"?>
<TOP>
    <ONE/>
    <TWO/>
    <LINK>AA: no align</LINK>
    <LINK align='left'>BB: align left</LINK>
    <LINK align='right'>CC: align right</LINK>
    <LINK>DD: no align</LINK>
    <LINK align='left'>EE: align left</LINK>
</TOP>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>
    <xsl:template match='/'>
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match='TOP'>
        <xsl:call-template name='create-button-panel'>
            <xsl:with-param name='link' select='LINK'/>
        </xsl:call-template>
        <xsl:call-template name='create-button-panel2'>
            <xsl:with-param name='link' select='LINK'/>
        </xsl:call-template>
    </xsl:template>

        <xsl:template name='create-button-panel'>
                <xsl:param name="link"/>
        <LEFT-GROUP>
            <xsl:for-each select="[EMAIL PROTECTED]'left']" >
                <xsl:call-template name="create-button"/>
                <xsl:if test='position()!=last()'><SPACER/></xsl:if>
            </xsl:for-each>
        </LEFT-GROUP>
        <RIGHT-GROUP>
            <xsl:for-each select="$link[not(@align) or (@align='right')]" >
                <xsl:call-template name="create-button"/>
                <xsl:if test='position()!=last()'><SPACER/></xsl:if>
            </xsl:for-each>
        </RIGHT-GROUP>
        </xsl:template>
        
        <xsl:template name='create-button-panel2'>
                <xsl:param name="link"/>
        <LEFT-GROUP>
            <xsl:for-each select="[EMAIL PROTECTED]'left']" >
                <xsl:call-template name="create-button"/>
            </xsl:for-each>
        </LEFT-GROUP>
        <RIGHT-GROUP>
            <xsl:for-each select="$link[not(@align) or (@align='right')]" >
                <xsl:call-template name="create-button"/>
            </xsl:for-each>
        </RIGHT-GROUP>
        </xsl:template>

    <xsl:template name='create-button'>
                <BUTTON><xsl:value-of select='text()'/></BUTTON>
        <xsl:message>BUTTON: <xsl:value-of select='@align'/> - <xsl:value-of 
select='text()'/></xsl:message>
    </xsl:template>

</xsl:stylesheet>

> Error with node sets and [last()] predicate
> -------------------------------------------
>
>          Key: XALANJ-1651
>          URL: http://issues.apache.org/jira/browse/XALANJ-1651
>      Project: XalanJ2
>         Type: Bug
>   Components: transformation, Xalan-interpretive
>     Versions: 2.5Dx
>  Environment: Operating System: Other
> Platform: Other
>     Reporter: Brian Minchau
>     Assignee: Xalan Developers Mailing List
>  Attachments: Bug22949Expr.txt
>
> This test was originally posted by Brian Lalonde under bug 15327 which is
> against XSLTC, but it didn't fail with XSLTC.  It does however fail for
> Xalan-J interpretive.
> Here is the stylesheet:
> ------------------------------------------
> <?xml version="1.0" ?><?xml-stylesheet type="text/xsl" ?><!-- self-test -->
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="text" encoding="utf-8" media-type="text/plain"/>
> <xsl:param name="one">first</xsl:param>
> <xsl:param name="two">second</xsl:param>
> <xsl:template match="/">
>   <xsl:variable name="params" select="//xsl:param"/>
>   <xsl:variable name="params1" select="$params[1]"/>
>   <xsl:variable name="expression1"><xsl:value-of select="$params1[last
> ()]"/></xsl:variable>
>   <xsl:variable name="expression2"><xsl:value-of select="$params[1][last
> ()]"/></xsl:variable>
>   <xsl:text>Testing: </xsl:text>
>   <xsl:value-of select="system-property('xsl:vendor')"/><xsl:text> </xsl:text>
>   <xsl:value-of select="system-property('xsl:vendor-url')"/><xsl:text>
>   </xsl:text>
>   <xsl:choose>
>     <xsl:when test="$expression1=$expression2">OK</xsl:when>
>     <xsl:otherwise>Fail!</xsl:otherwise>
>   </xsl:choose>
>   <xsl:text>
> </xsl:text>
> </xsl:template>
> </xsl:stylesheet>
> ------------------------------------------
> The same document is used as input (so it acts as XSL and input XML at the 
> same 
> time).  One difference from the original is that I've removed an 
> href="test.xml"
> in the xml-stylesheet processing instruction and I've renamed a few things.
> Analysis: When fed as input to itself "params" should take on the list of two 
> parameters, "one" and "two". "params1" should take on the first of those, 
> just "one".  "expression1" should be the last one in "params1",  but since 
> there is only a single node it is just "one". "expression2" is just 
> like "expression1" except that the calculation happens in a single select, 
> not 
> across 2 selects as it does for expression1. There is a final 
> test="$expression1=$expression2" which outputs OK or Fail!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to