You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Joe (JIRA)" <xa...@xml.apache.org> on 2007/04/17 16:36:15 UTC

[jira] Created: (XALANJ-2379) Empty node text comparisons failing

Empty node text comparisons failing
-----------------------------------

                 Key: XALANJ-2379
                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
             Project: XalanJ2
          Issue Type: Bug
    Affects Versions: 2.7
         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
            Reporter: Joe
            Priority: Critical


When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
    <xsl:variable name="testcase1" select="text()=''"/>
this will always return false.

Yet, if I do:
    <xsl:variable name="testcase1" select="string-length(text())=0"/>
This returns the correct result.

I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Closed: (XALANJ-2379) Empty node text comparisons failing

Posted by "Joe (JIRA)" <xa...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XALANJ-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe closed XALANJ-2379.
-----------------------

    Resolution: Invalid

> Empty node text comparisons failing
> -----------------------------------
>
>                 Key: XALANJ-2379
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
>            Reporter: Joe
>            Priority: Critical
>         Attachments: test.xml, test.xsl, test_output.xml
>
>
> When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
>     <xsl:variable name="testcase1" select="text()=''"/>
> this will always return false.
> Yet, if I do:
>     <xsl:variable name="testcase1" select="string-length(text())=0"/>
> This returns the correct result.
> I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2379) Empty node text comparisons failing

Posted by "David Bertoni (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489438 ] 

David Bertoni commented on XALANJ-2379:
---------------------------------------

There are no empty text nodes in the XPath data model, so Xalan-J's behavior is correct.

As Joe pointed out, you need to understand how XPath treats empty node sets, before you can understand this behavior.

> Empty node text comparisons failing
> -----------------------------------
>
>                 Key: XALANJ-2379
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
>            Reporter: Joe
>            Priority: Critical
>         Attachments: test.xml, test.xsl, test_output.xml
>
>
> When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
>     <xsl:variable name="testcase1" select="text()=''"/>
> this will always return false.
> Yet, if I do:
>     <xsl:variable name="testcase1" select="string-length(text())=0"/>
> This returns the correct result.
> I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2379) Empty node text comparisons failing

Posted by "David Marston (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489422 ] 

David Marston commented on XALANJ-2379:
---------------------------------------

I believe that the current behavior is correct. The element
<param></param>
with no characters between the start and end tags, has no children.
A test like count(text()) would return zero. This is a more accurate view of the situation than
string-length(text()) returning zero, because the string-length behavior when given an empty node-set depends on the XPath spec defining that behavior as an exception. By contrast, the count() function is intended to report the number of members of a node-set.

As for the compare between an empty node-set and a null string, see part 3.4 of the XPath 1.0 spec, in particular the 5th paragraph. The complaint is about comparing a node-set, text(), to a string, ''. But there is no node in the node-set that has that string value because there is no node in the node-set. In other words, when one comparand is an empty node-set, the result is always false.

> Empty node text comparisons failing
> -----------------------------------
>
>                 Key: XALANJ-2379
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
>            Reporter: Joe
>            Priority: Critical
>         Attachments: test.xml, test.xsl, test_output.xml
>
>
> When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
>     <xsl:variable name="testcase1" select="text()=''"/>
> this will always return false.
> Yet, if I do:
>     <xsl:variable name="testcase1" select="string-length(text())=0"/>
> This returns the correct result.
> I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2379) Empty node text comparisons failing

Posted by "Joe (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489468 ] 

Joe commented on XALANJ-2379:
-----------------------------

After reading part of the X-Path specification and looking at the output from Xalan-J and MS XML, I see that you are correct.  This is the behavior it should be exibiting.  But, if this is the case, then why does this work:

<xsl:variable name="testcase1" select=".=''"/>

Logically looking at this expression, I would think that it grabs the content of the current node, and converts it to a string.  But, since there is no content within the tags, it should always return false (based on the explanation you just gave me.)  Yet, using either Xalan-J or MS XML, it will return true if the node is empty.

My thought is, shouldn't "text()" do the same thing?  If not, then I feel this is an inconsistency in the X-Path specification itself.


By the way...have you ever noticed how many run-on sentences the X-Path specification contains?  It would make an English major cry...lol.

> Empty node text comparisons failing
> -----------------------------------
>
>                 Key: XALANJ-2379
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
>            Reporter: Joe
>            Priority: Critical
>         Attachments: test.xml, test.xsl, test_output.xml
>
>
> When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
>     <xsl:variable name="testcase1" select="text()=''"/>
> this will always return false.
> Yet, if I do:
>     <xsl:variable name="testcase1" select="string-length(text())=0"/>
> This returns the correct result.
> I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2379) Empty node text comparisons failing

Posted by "David Marston (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489472 ] 

David Marston commented on XALANJ-2379:
---------------------------------------

At any given point in the XSLT processing, . represents the current context node. In the 1.0 view, this item is always one node, never the empty node-set. The path expression text() is actually short for
./child::text()
or the set of all text nodes that are children of the current context node. That set could be empty, have one member, or have several members.

A test like .='' or .='foo' is trying to compare the current context node with a string. If that current node is an element, then XPath wants to obtain the string value of the current element (see part 5.2 of the XPath spec)
and compare that to the string on the other side. The string value of an empty element is an empty string.

> Empty node text comparisons failing
> -----------------------------------
>
>                 Key: XALANJ-2379
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
>            Reporter: Joe
>            Priority: Critical
>         Attachments: test.xml, test.xsl, test_output.xml
>
>
> When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
>     <xsl:variable name="testcase1" select="text()=''"/>
> this will always return false.
> Yet, if I do:
>     <xsl:variable name="testcase1" select="string-length(text())=0"/>
> This returns the correct result.
> I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2379) Empty node text comparisons failing

Posted by "Joe (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489530 ] 

Joe commented on XALANJ-2379:
-----------------------------

Ooooh...text() returns a set of text nodes instead of a string...that makes sense now.  I had thought that it returned the text of the current node in a similar fashion as ".".

So, if doing a text comparison, it returns a concatenated string of all the child text nodes and compares it against the second operand, unless there are no children, in which case the logic test would fail (because there are no child text nodes.)  I think I understand it now.

Sorry to waste your time with this bug report, but thank you for explaining why this is the correct method for X-Path.

> Empty node text comparisons failing
> -----------------------------------
>
>                 Key: XALANJ-2379
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2379
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>         Environment: Windows XP SP2, Eclipse 3.2.2 (build M20070212-1330)
>            Reporter: Joe
>            Priority: Critical
>         Attachments: test.xml, test.xsl, test_output.xml
>
>
> When a text comparison on an empty node is performed, it never returns true.  For example, if I were to use this variable:
>     <xsl:variable name="testcase1" select="text()=''"/>
> this will always return false.
> Yet, if I do:
>     <xsl:variable name="testcase1" select="string-length(text())=0"/>
> This returns the correct result.
> I will attach a test case to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org