You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by bu...@apache.org on 2009/08/11 22:24:22 UTC

DO NOT REPLY [Bug 47681] New: count function returning incorrect results

https://issues.apache.org/bugzilla/show_bug.cgi?id=47681

           Summary: count function returning incorrect results
           Product: Taglibs
           Version: 1.1.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XTags Taglib
        AssignedTo: taglibs-dev@jakarta.apache.org
        ReportedBy: jsartoris@hotmail.com


--- Comment #0 from Jason <js...@hotmail.com> 2009-08-11 13:24:21 PDT ---
Hello,

I am having an issue with using the count function to count the number of
entries in an XML document.  

For example, given the JSP text:
-------------------
<%@ taglib uri ="http://java.sun.com/jsp/jstl/core" prefix ="c"%>
<%@ taglib uri ="http://java.sun.com/jsp/jstl/xml" prefix ="x"%>

<x:parse var="doc" xml="<?xml version=\"1.0\" encoding=\"ISO-8859-1\"
?><world><country><id>1</id><name>Canada</name></country><country><id>2</id><name>USA</name></country></world>"
/> 

<x:out select="count($doc/world/country)"/>  
<br>
<x:out select="count($doc/country)"/>

-------------------

will result in the count($doc/world/country) always returns 0 (zero)
but the count($doc/country) will return 2.

Is this a bug?  I have tried debugging the taglib code but I cannot figure out
what is going wrong.

Regards,
Jason

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47681] count function returning incorrect results

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47681


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|taglibs-dev@jakarta.apache. |dev@tomcat.apache.org
                   |org                         |


--- Comment #2 from Mark Thomas <ma...@apache.org> 2009-08-17 09:55:54 BST ---
Update assignee to Tomcat dev list

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47681] count function returning incorrect results

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47681



--- Comment #1 from Jason <js...@hotmail.com> 2009-08-12 06:31:27 PDT ---
Just an addition to my original post.  
The "count($doc/world/country)" call will return zero (I think it should return
2.  But when you put the $doc/world/country in a x:forEach tag it will behave
correctly and result in two iterations...like this:

<x:forEach select="$doc/world/country" var="test">
   found a country<br>
</x:forEach>

This will result in "found a country<br>" being printed out twice..which is
expected. 

It seems that once the expression is wrapped in the count function it is not
handled properly.  

I noticed in the XPathUtil.adaptParamsForXalan method is only checking if the
xpath variable starts with a '$' in order to create the appropriate Node and
resolve the variable.  In the case of the count($doc/world/country) expression
this does not start with a '$' and will result in the method creating a
DummyDocument instead of resolving the variable appropriately.  

Regards,
Jason

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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