Hi Elisa
In XTags all page, request, session and application scope attributes, as
well as parameters are all available as XPath variables.
So you can do the following:
<xtags:parse id="data" uri="xml/mydata.xml"/>
<xtags:forEach select="//item">
<xtags:if test="./title=$Criteria'">
<% totalcount++; %>
</xtags:if>
</xtags:forEach>
Though the above could be done as
<xtags:parse id="data" uri="xml/mydata.xml"/>
The total is
<b>
<xtags:valueOf select="count(//item[title=$Criteria])"/>
</b>
Or a scripting variable could be declared
<xtags:variable id="total" select="count(//item[title=$Criteria])"/>
The total is <%= total %>
James
----- Original Message -----
From: "Elisa Green" <[EMAIL PROTECTED]>
To: "Tablib User Group" <[EMAIL PROTECTED]>
Sent: Friday, June 22, 2001 7:02 PM
Subject: xtags questions
> I am trying to build a search results page using xtags in JSP and
> would like to count the number of items from my parsed data which
> match the input search string (criteriaIn).
>
> My thinking has brought me to the following problem. I would
> like to use criteriaIn to match each item's title, but it does
> not behave as I expected. Is there a way to work around this?
> Or more to the point, is there a feature of taglibs that I have
> completely overlooked?
>
> Relevant code:
> ------------------
> <%!
> String criteriaIn;
> int totalcount;
> %>
> <%
> totalcount = 0;
> criteriaIn = request.getParameter("Criteria");
> %>
>
> <%@ taglib uri="/WEB-INF/taglibs/xtags.tld" prefix="xtags" %>
>
> <xtags:parse id="data" uri="xml/mydata.xml"/>
> <xtags:forEach select="//item">
> <xtags:if test="./title='<%= criteriaIn %>'"><% totalcount++;
> %></xtags:if>
> </xtags:forEach>
> -------------------
> If a fixed string is used, as the following sample demonstrates,
> it works as expected.
>
> ---------------
> <xtags:parse id="data" uri="xml/mydata.xml"/>
> <xtags:forEach select="//item">
> <xtags:if test="./title='Nootka'"><% totalcount++;
> %></xtags:if>
> </xtags:forEach>
> ----------------
>
> Any help will be appreciated. Is there any good references for
> JSP & Taglibs combined, online?
>
> Thanks in advance.
>
> Elisa
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com