Followup:
Broadly, this is a usage error. See
http://commons.apache.org/jxpath/users-guide.html#Map_Element_Access
, which says:
<quote>
Often you will need to use the alternative syntax for
accessing Map elements:
String homeZipCode = (String)context.
getValue("[EMAIL PROTECTED]'home']/zipCode");
Unlike a child name in XPath, the value of the "name"
attribute does not have to be a properly formed
identifier. Also, in this case the key can be an
expression, e.g. a variable.
</quote>
I will leave the bug report open, however, because the
fact that selectSingleNode() behaved the way you
wanted it to is the actual bug (as I suspected might
be the case). :)
-Matt
--- Matt Benson <[EMAIL PROTECTED]> wrote:
>
> --- "Singh, Rupinder"
> <[EMAIL PROTECTED]>
> wrote:
>
> > Can somebody explain the unusual behaviour in the
> > following code. The
> > selectNodes method does not match anything but
> > selectSingleNode does
> > return the correct node for the same jxpath query.
> > Are these two method
> > supposed to behave differently ?
>
> Please do not cross-post to both the user and dev
> lists. It seems you have uncovered some buggy
> behavior related to the fact that you are looking up
> keys in a map which have embedded colons, which
> normally indicate namespaced content in an XML
> context. I'll have to think about what the proper
> behavior would be here. I have created the
> following
> JIRA issue to track this:
>
> https://issues.apache.org/jira/browse/JXPATH-104
>
> Thanks,
> Matt
>
> >
> >
> >
> > Map child = new HashMap();
> >
> > child.put("fname", "testfname");
> >
> > child.put("id", "1");
> >
> > child.put("lname", "testlname");
> >
> > Map name = new HashMap();
> >
> > name.put("tns:name", child);
> >
> > Map data = new HashMap();
> >
> > data.put("person", name);
> >
> > JXPathContext context =
> > JXPathContext.newContext(data);
> >
> > List l =
> > context.selectNodes("person/tns:name/id"); //This
> > returns
> > nothing
> >
> >
> context.selectSingleNode("person/tns:name/id"));
> > //This returns
> > the value 1
> >
> >
> >
> > Thanks
> >
> >
> >
> > Rupinder
> >
> >
>
>
>
>
>
____________________________________________________________________________________
> Looking for a deal? Find great prices on flights and
> hotels with Yahoo! FareChase.
> http://farechase.yahoo.com/
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]