tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William C. Robertson" <>
Subject RE: xtags:ForEach question (involving parameters)
Date Fri, 13 Jul 2001 06:11:15 GMT
Hi John,

	I think it will work if you assemble the entire string outside of the xpath
tag then use a string variable in the tag.


String var="//person[child::name[contains(text(), '" +
request.parameters("name") + "')]]"


<xtags:forEach select = "<%=var%>">  ...

Make sure the request part is done right (can't remember the exact syntax of
the top of my head.  Anyway, I'm new to xtags too, but try this.  Just stay
away from trying to construct the string within the forEach tag.


-----Original Message-----
From: John Townsend []
Sent: Thursday, July 12, 2001 3:53 PM
Subject: xtags:ForEach question (involving parameters)

I am having a problem with forEach in the xtags library. I am trying to
use XPath and xtags to select all of the person entries from my
directory that contain a substring (For example, all of the people who
have 'John' in their name).

I have an XML file that looks basically like this:

		<name>John Townsend</name>
		...more data...

Here's a piece of my JSP page:

	<xtags:forEach select = "//person[child::name[contains(text(),
        <TD align=right><xtags:valueOf
          <TD><xtags:valueOf select="name"/></TD>
          <TD><xtags:valueOf select="title"/></TD>
select="email"/>"><xtags:valueOf select="email"/></A></TD>
          <TD><NOBR><xtags:valueOf select="phone"/></NOBR></TD>
          <TD><NOBR><xtags:valueOf select="cell"/></NOBR></TD>
          <TD><NOBR><xtags:valueOf select="home"/></NOBR></TD>
          <TD><xtags:valueOf select="messenger"/></TD></TR>

If my select in the forEach looks like this:

Select = "//person[child::name[contains(text(), 'John')]]"

Then it works. But, I would like to pass in the 'John' parameter from
the URL. The URL would look something like this:


Can I do this? I thought if I put $param in my select statement it would
work, but it didn't seem to work.

Any ideas? Forgive my ignorance of XPath, I am just starting to use the
xtags library and XPath.

-- towns

View raw message