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
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
Update assignee to Tomcat dev list
Resolving. Taglib has been retired.