commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald Finster <>
Subject [JXPATH] getting Containers in iteration
Date Sun, 17 Aug 2008 09:00:10 GMT


this is my first posting to this list, so forgive me, if I am
asking dump questions. (At least I had a look at the archive.)

I would like to ask, if it is possible to get containers
(e.g. Lists) 'as they are' in an iteration.

Consider the following bean:

public class Book {
	String title;
	List<Writer> authors;

Iterating this bean with

JXPathContext context = JXPathContext.newContext(book);
i = context.iteratePointers("/*");

results in the following:

title      = "Book Title"
authors[1] = "First Author"
authors[2] = "Second Author"

i.e. the List is iterated instead of being returned as a List-Object.
Obviously, each list-item is regarded as a direct child of the root
of the Book object.

Is there any way to avoid this behavior?
i.e. is it possible to get something like

title   = "Book Title"
authors = [ "First Author", "Second Author" ... ] i.e. List<Author>

In XML-notation the difference would be like this:

The current behavior of 'iterate':

	<title>Book Title</title>
	<authors>First Author</authors>
	<authors>Second Author</authors>

what I would like to see is an equivalent of:

	<title>Book Title</title>
		<1>First Author</1>
		<2>Second Author</2>

By the way: in contrast to 'iterate' 'getValue("authors") returns

I would be grateful for any thoughts and suggestions.

With kind regards


Dr.-Ing. Harald Finster / Aachen Germany industrial history and architecture       gallery: watercolours and oil paintings

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message