Dmitri, Thanks for the reply. This explains a lot of what we've been seeing. I tried your suggestion #2 (use "$map/dataMap/Foo/Count[1]" as the predicate) with my test program and it works.
Unfortunately, the data in our application is customized so that all value objects within the map are wrapped inside a custom class. So using $map/dataMap/Foo/Count[1] for the predicate will still fail to give the desired results, since the Integer object it represents is wrapped in another class. (This custom way of storing our data in maps was an area of concern for us when we started using XPath.) And, unfortunately, your suggestion #1 (put a number in the map instead of the list) is not an option. I'll have to chew on this for awhile. I'm not sure what we can do, other than pre-parse the expression and replace "predicates" with their true integer values before evaluating the expression itself. Thanks again for clearing this up. Steve Pannier Jacada, Inc. (763) 201-0002 Ext. 219 [EMAIL PROTECTED] http://www.jacada.com > Steve, > > The explanation for the seemingly inconsistent behavior of JXPath is > quite simple. > > The value for the key "Count" in your example is not really an integer, > but a list containing an integer. That makes a difference. According > to the XPath specification, the predicate (the expression in brackets) > is used differently for different types. If the value of the > expression is a number, it is used as an index. If it is not a number, > it is converted to a boolean. The nodes for which it evaluates to true > are included in the resulting collection. In our case the value of the > expression is a non-empty list, so it evaluates to true for every > element of the collection. This is why every element is included in the > resulting list. > > There are two solutions to the problem: > > 1. Put a number in the map, instead of a list > 2. Change the xpath like this: > "$map/dataMap/Foo/Bar[$map/dataMap/Foo/Count[1]]". > > I hope this helps. > > - Dmitri > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
