You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "MUELLER,RAINER (HP-Switzerland,ex1)" <ra...@hp.com> on 2001/07/10 13:32:12 UTC

when will the fixed tlds be available

Hi guys,

any ideas when the fixed tlds (trying xtags and log) be available?


Thanks,
Rainer

Re: xtags:ForEach question (involving parameters)

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "John Townsend" <jo...@listenpoint.com>
> What I would like to do is sort all of the person objects that are
> returned from the forEach select statement by an attribute (name, phone
> number, title, etc.)

Here's an example....

<%-- parse some XML --%>

<xtags:parse>
<people>
    <person name="James">
        ..
    </person>
    <person name="John">
        ..
    </person>
</people>
</xtags:parse>

<%-- now iterate through people in @name order --%>

<xtags:forEach select="/people/person" sort="@name">
    Name: <xtags:valueOf select="@name"/>
</xtags:forEach>


James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: xtags:ForEach question (involving parameters)

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "John Townsend" <jo...@listenpoint.com>
> Thanks for the pointers to XPath wizard and the tutorial. I have looked
> at both of them and they have definitely helped. One thing I can't
> figure out in either of them: Sorting.
>
> In the forEach tag, you can pass in an XPath expression for sorting. I
> have tried a variety of different expressions in the XPath wizard and it
> seems to have no effect on the results.

Just one point about the XPath wizard and sorting - to enable sorting you
must tick the 'sort results' checkbox next to the 'Sort by XPath expression'
text field.

Does that help any in trying out sorting in the XPath wizard?

James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


RE: xtags:ForEach question (involving parameters)

Posted by John Townsend <jo...@listenpoint.com>.
Thanks again for the input.. I appreciate it. I am beginning to think
that maybe building the select statement dynamically in Java code is
probably the way to go.

Thanks for the pointers to XPath wizard and the tutorial. I have looked
at both of them and they have definitely helped. One thing I can't
figure out in either of them: Sorting. 

In the forEach tag, you can pass in an XPath expression for sorting. I
have tried a variety of different expressions in the XPath wizard and it
seems to have no effect on the results. 

What I would like to do is sort all of the person objects that are
returned from the forEach select statement by an attribute (name, phone
number, title, etc.)

Is this something that sorting can handle or do I need to find another
way?

Thanks,
-- John Townsend


-----Original Message-----
From: James Strachan [mailto:james_strachan@yahoo.co.uk] 
Sent: Friday, July 13, 2001 12:03 PM
To: John Townsend
Cc: taglibs-user@jakarta.apache.org
Subject: Re: xtags:ForEach question (involving parameters)

Hi John

Yes Bill is right. If you want to build up an XPath expression
dynamically
you can always do it in Java code before you call the xtags. This can
often
be much easier if you want to dynamically resolve the elements or
attributes
to search for.


>is this legal:
>
> //person[$field[contains(.,$value)]]


Not quite.

> Where $field and $name would come from the query string? This doesn't
> cause an exception, but it doesn't work either. I just seem to get all
> of the person objects back.



XPath allows variables to be used but mostly for testing either node
equality or string values. For example if $field is the name of an
element
you wish to test for then the following is valid XPath:-

//person/*[name()=$field and contains(.,$value)]

The above will select all of the immediate child elements of <person>
which
are called the value of $field and the text of the element contains the
$value.

e.g. that would select ..

<person>
    <name>John Townsend</name>
</person>

The expression would match the <name> element if the query string was
field=name&value=John

If you actually wanted the person tag then append a /..

//person/*[name()=$field and contains(.,$value)]/..

BTW if you ever want to play around with XPath expressions, there is a
little XPath Wizard JSP in the xtags example web app that might help. Or
this site is useful too, its an online XPath tool from Zvon...

http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/extras.html

James



_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com




Re: xtags:ForEach question (involving parameters)

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi John

Yes Bill is right. If you want to build up an XPath expression dynamically
you can always do it in Java code before you call the xtags. This can often
be much easier if you want to dynamically resolve the elements or attributes
to search for.


>is this legal:
>
> //person[$field[contains(.,$value)]]


Not quite.

> Where $field and $name would come from the query string? This doesn't
> cause an exception, but it doesn't work either. I just seem to get all
> of the person objects back.



XPath allows variables to be used but mostly for testing either node
equality or string values. For example if $field is the name of an element
you wish to test for then the following is valid XPath:-

//person/*[name()=$field and contains(.,$value)]

The above will select all of the immediate child elements of <person> which
are called the value of $field and the text of the element contains the
$value.

e.g. that would select ..

<person>
    <name>John Townsend</name>
</person>

The expression would match the <name> element if the query string was
field=name&value=John

If you actually wanted the person tag then append a /..

//person/*[name()=$field and contains(.,$value)]/..

BTW if you ever want to play around with XPath expressions, there is a
little XPath Wizard JSP in the xtags example web app that might help. Or
this site is useful too, its an online XPath tool from Zvon...

http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/extras.html

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


RE: xtags:ForEach question (involving parameters)

Posted by John Townsend <jo...@listenpoint.com>.
Hi James.. thanks for the response. Here's another question. Is this
legal:

//person[$field[contains(.,$value)]]

Where $field and $name would come from the query string? This doesn't
cause an exception, but it doesn't work either. I just seem to get all
of the person objects back.

BTW.. Thanks again for your message. Its greatly appreciated!

-- John Townsend


-----Original Message-----
From: James Strachan [mailto:james_strachan@yahoo.co.uk] 
Sent: Friday, July 13, 2001 10:49 AM
To: taglibs-user@jakarta.apache.org
Cc: john.townsend@listenpoint.com
Subject: Re: xtags:ForEach question (involving parameters)

Hi John

(I'm reposting this as my previous post seemed to vanish)

From: "John Townsend" <jo...@listenpoint.com>
> 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:
>
> <directory>
> <person>
> <name>John Townsend</name>
> ...more data...
> </person>
> </directory>
>
> Here's a piece of my JSP page:
>
> <xtags:forEach select = "//person[child::name[contains(text(),
> '$param')]]">

The $param should not be in quotes. Putting that in quotes means look
for a
name that contains the literal string "$param" such as

<directory>
<person>
<name>Foo $param Townsend</name>
</person>
</directory>

So the XPath expression to evaluate the current param variable that you
need
is

//person[contains(name,$param)]

I took the liberty of simplifying the XPath syntax a bit. More on that
below...


> If my select in the forEach looks like this:
>
> Select = "//person[child::name[contains(text(), 'John')]]"
>
> Then it works.


BTW you can drop the child:: axis as that is the default axis to

//person[name[contains(text(), 'John')]]

Then the contains() function turns both objects into strings so you
could
simplify that again to


//person[name[contains(., 'John')]]

which is the same as

//person[contains(name, 'John')]

Remember only use '' to denote literal strings, never use it for names
of
elements, attributes or variables.


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

No problem.

I can highly recommend the Zvon tutorial for XPath, it takes about 10-20
minutes and teaches at least 90% of XPath thats important using some
simple
examples. (I always find learning by example easier than reading specs,
particularly for languages)

http://www.zvon.org/xxl/XPathTutorial/General/examples.html

James




_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com




Re: xtags:ForEach question (involving parameters)

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi John

(I'm reposting this as my previous post seemed to vanish)

From: "John Townsend" <jo...@listenpoint.com>
> 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:
>
> <directory>
> <person>
> <name>John Townsend</name>
> ...more data...
> </person>
> </directory>
>
> Here's a piece of my JSP page:
>
> <xtags:forEach select = "//person[child::name[contains(text(),
> '$param')]]">

The $param should not be in quotes. Putting that in quotes means look for a
name that contains the literal string "$param" such as

<directory>
<person>
<name>Foo $param Townsend</name>
...more data...
</person>
</directory>

So the XPath expression to evaluate the current param variable that you need
is

//person[contains(name,$param)]

I took the liberty of simplifying the XPath syntax a bit. More on that
below...


> If my select in the forEach looks like this:
>
> Select = "//person[child::name[contains(text(), 'John')]]"
>
> Then it works.


BTW you can drop the child:: axis as that is the default axis to

//person[name[contains(text(), 'John')]]

Then the contains() function turns both objects into strings so you could
simplify that again to


//person[name[contains(., 'John')]]

which is the same as

//person[contains(name, 'John')]

Remember only use '' to denote literal strings, never use it for names of
elements, attributes or variables.


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

No problem.

I can highly recommend the Zvon tutorial for XPath, it takes about 10-20
minutes and teaches at least 90% of XPath thats important using some simple
examples. (I always find learning by example easier than reading specs,
particularly for languages)

http://www.zvon.org/xxl/XPathTutorial/General/examples.html

James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: xtags:ForEach question (involving parameters)

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi John

From: "John Townsend" <jo...@listenpoint.com>
> 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:
>
> <directory>
> <person>
> <name>John Townsend</name>
> ...more data...
> </person>
> </directory>
>
> Here's a piece of my JSP page:
>
> <xtags:forEach select = "//person[child::name[contains(text(),
> '$param')]]">

The $param should not be in quotes. Putting that in quotes means look for a
name that contains the literal string "$param" such as

<directory>
<person>
<name>Foo $param Townsend</name>
...more data...
</person>
</directory>

So the XPath expression to evaluate the current param variable that you need
is

//person[contains(name,$param)]

I took the liberty of simplifying the XPath syntax a bit. More on that
below...


> If my select in the forEach looks like this:
>
> Select = "//person[child::name[contains(text(), 'John')]]"
>
> Then it works.


BTW you can drop the child:: axis as that is the default axis to

//person[name[contains(text(), 'John')]]

Then the contains() function turns both objects into strings so you could
simplify that again to


//person[name[contains(., 'John')]]

which is the same as

//person[contains(name, 'John')]

Remember only use '' to denote literal strings, never use it for names of
elements, attributes or variables.


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

No problem.

I can highly recommend the Zvon tutorial for XPath, it takes about 10-20
minutes and teaches at least 90% of XPath thats important using some simple
examples. (I always find learning by example easier than reading specs,
particularly for languages)

http://www.zvon.org/xxl/XPathTutorial/General/examples.html

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


RE: xtags:ForEach question (involving parameters)

Posted by "William C. Robertson" <in...@bytetherapy.com>.
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.

ie:

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

then

<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.

-Bill

-----Original Message-----
From: John Townsend [mailto:john.townsend@listenpoint.com]
Sent: Thursday, July 12, 2001 3:53 PM
To: taglibs-user@jakarta.apache.org
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:

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

Here's a piece of my JSP page:

	<xtags:forEach select = "//person[child::name[contains(text(),
'$param')]]">
      <TR>
        <TD align=right><xtags:valueOf
select="employee-number"/>&nbsp;&nbsp;</TD>
          <TD><xtags:valueOf select="name"/></TD>
          <TD><xtags:valueOf select="title"/></TD>
          <TD><A
              href="mailto:<xtags:valueOf
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>
     </xtags:forEach>

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:

http://localhost:8080/myapp/mypage.jsp?param=John

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



xtags:ForEach question (involving parameters)

Posted by John Townsend <jo...@listenpoint.com>.
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:

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

Here's a piece of my JSP page: 

	<xtags:forEach select = "//person[child::name[contains(text(),
'$param')]]">
      <TR>
        <TD align=right><xtags:valueOf
select="employee-number"/>&nbsp;&nbsp;</TD>
          <TD><xtags:valueOf select="name"/></TD>
          <TD><xtags:valueOf select="title"/></TD>
          <TD><A 
              href="mailto:<xtags:valueOf
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>
     </xtags:forEach>

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:

http://localhost:8080/myapp/mypage.jsp?param=John

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



Re: when will the fixed tlds be available

Posted by James Strachan <ja...@yahoo.co.uk>.
Hi Rainer

From: "MUELLER,RAINER (HP-Switzerland,ex1)" <ra...@hp.com>
> any ideas when the fixed tlds (trying xtags and log) be available?

We've been having some problems with the overnight builds - sorry about
that. The xtags build is now fixed.

http://jakarta.apache.org/builds/jakarta-taglibs/nightly/projects/xtags/

http://jakarta.apache.org/builds/jakarta-taglibs/nightly/projects/xtags/jaka
rta-taglibs-xtags-20010710.zip


The problem still exists for log and io - we'll hopefully have that fixed
soon too.

(Then we'll hopefully get stable releases done soon too!)

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: when will the fixed tlds be available

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
They are available now in the nightly build for 20010710.

Glenn

"MUELLER,RAINER (HP-Switzerland,ex1)" wrote:
> 
> Hi guys,
> 
> any ideas when the fixed tlds (trying xtags and log) be available?
> 
> Thanks,
> Rainer

-- 
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------