You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Singh, Rupinder" <Ru...@softwareag.com> on 2013/02/15 18:51:07 UTC
[jxpath] Syntax with @name
I have a jxpath expression question.
Map m = new HashMap();
Map[] dd = new HashMap[2];
dd[0] = new HashMap();
dd[0].put("tag", "10");
dd[0].put("score", "100");
dd[1] = new HashMap();
dd[1].put("tag", "11");
dd[1].put("score", "90");
Map ddk = new HashMap();
ddk.put("dataDescription", dd);
m.put("Values", ddk);
JXPathContext xpathContext = IDataJXPathContext.newContext(m);
Object works =
xpathContext.getValue("//dataDescription[tag='10']"); //This returns
the correct data as expected
Object doesntWork =
xpathContext.getValue("//.[@name='dataDescription'][tag='10']"); // This
does not bring up anything
I have to use @name as the actual names have special characters in them.
Can anybody help with what the correct syntax for this should be ?
Thanks
Rupinder
RE: [jxpath] Syntax with @name
Posted by "Singh, Rupinder" <Ru...@softwareag.com>.
That does not bring up anything. The tag is inside dataDescription. The
funny thing is that both
//.[@name='dataDescription'] and //dataDescription bring up the same
results - a list of dataDescription nodes. So I was just hoping that it
would just work from there on by adding the [tag='10'] criteria to pick
the correct one. While the first one does do that the second one does
not.
-----Original Message-----
From: Matt Benson [mailto:gudnabrsam@gmail.com]
Sent: Friday, February 15, 2013 2:06 PM
To: Commons Users List
Subject: Re: [jxpath] Syntax with @name
Have you tried [@name='dataDescription' and @tag='10'] or something
along these lines?
HTH,
Matt
On Fri, Feb 15, 2013 at 11:51 AM, Singh, Rupinder <
Rupinder.Singh@softwareag.com> wrote:
> I have a jxpath expression question.
>
>
>
> Map m = new HashMap();
>
> Map[] dd = new HashMap[2];
>
> dd[0] = new HashMap();
>
> dd[0].put("tag", "10");
>
> dd[0].put("score", "100");
>
> dd[1] = new HashMap();
>
> dd[1].put("tag", "11");
>
> dd[1].put("score", "90");
>
> Map ddk = new HashMap();
>
> ddk.put("dataDescription", dd);
>
> m.put("Values", ddk);
>
>
>
> JXPathContext xpathContext = IDataJXPathContext.newContext(m);
>
> Object works =
> xpathContext.getValue("//dataDescription[tag='10']"); //This returns
> the correct data as expected
>
> Object doesntWork =
> xpathContext.getValue("//.[@name='dataDescription'][tag='10']"); //
> This does not bring up anything
>
>
>
>
>
> I have to use @name as the actual names have special characters in
them.
> Can anybody help with what the correct syntax for this should be ?
>
>
>
> Thanks
>
>
>
> Rupinder
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [jxpath] Syntax with @name
Posted by Matt Benson <gu...@gmail.com>.
Have you tried [@name='dataDescription' and @tag='10'] or something along
these lines?
HTH,
Matt
On Fri, Feb 15, 2013 at 11:51 AM, Singh, Rupinder <
Rupinder.Singh@softwareag.com> wrote:
> I have a jxpath expression question.
>
>
>
> Map m = new HashMap();
>
> Map[] dd = new HashMap[2];
>
> dd[0] = new HashMap();
>
> dd[0].put("tag", "10");
>
> dd[0].put("score", "100");
>
> dd[1] = new HashMap();
>
> dd[1].put("tag", "11");
>
> dd[1].put("score", "90");
>
> Map ddk = new HashMap();
>
> ddk.put("dataDescription", dd);
>
> m.put("Values", ddk);
>
>
>
> JXPathContext xpathContext = IDataJXPathContext.newContext(m);
>
> Object works =
> xpathContext.getValue("//dataDescription[tag='10']"); //This returns
> the correct data as expected
>
> Object doesntWork =
> xpathContext.getValue("//.[@name='dataDescription'][tag='10']"); // This
> does not bring up anything
>
>
>
>
>
> I have to use @name as the actual names have special characters in them.
> Can anybody help with what the correct syntax for this should be ?
>
>
>
> Thanks
>
>
>
> Rupinder
>
>
>
>