You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Craig Raw <cr...@quirk.co.za> on 2003/02/25 11:26:42 UTC

[JXPath] The name attribute?

Hi,

I am using JXPath in combination with JAXB, and am finding it very
useful. I have a question relating to a XPath query which contains
predicates that specify attributes. 

e.g. customer[@id='1']/value

For the most part this works fine, but when the attribute has a name of
'name', as

e.g. customer[@name='xxx']/value

I always get null as a result. The JXPathContext javadoc contains the
following which does not make things any clearer to me, although I
suspect it may apply:

"JXPath does not support DOM attributes for non-DOM objects. Even though
XPaths like "para[@type='warning']" are legitimate, they will always
produce empty results. The only attribute supported for JavaBeans is
"name". The XPath "foo/bar" is equivalent to "foo[@name='bar']". "

Is there some special handling for 'name'?

I am using JXPath 1.1b1. Attributes in JAXB are stored as normal
variables of the class, with corresponding get/set methods (getName(),
setName()).

Thanks for any clarification,

Craig



RE: [JXPath] The name attribute?

Posted by Craig Raw <cr...@quirk.co.za>.
Thanks, much appreciated.

Craig

> -----Original Message-----
> From: Dmitri Plotnikov [mailto:dplotnik@yahoo.com] 
> Sent: 25 February 2003 06:01 PM
> To: Jakarta Commons Users List; craig@quirk.co.za
> Subject: Re: [JXPath] The name attribute?
> 
> 
> Craig,
> 
> "Name" is a special attribute that represents the name of the 
> property.  It was of course a mistake to introduce this 
> attribute without a namespace, it should have been something 
> like "jxpath:name", but now it is too late to change it for 
> compatibility reasons.  This special use of the "name" 
> attribute only applies to beans and maps and does not apply 
> to XML-based models (DOM, JDOM)
> 
> I recommend the use of the child access instead of attribute 
> to access properties, e.g. customer[name='xxx']
> 
> 
> - Dmitri
> 
> 
> --- Craig Raw <cr...@quirk.co.za> wrote:
> > Hi,
> > 
> > I am using JXPath in combination with JAXB, and am finding it very 
> > useful. I have a question relating to a XPath query which contains 
> > predicates that specify attributes.
> > 
> > e.g. customer[@id='1']/value
> > 
> > For the most part this works fine, but when the attribute 
> has a name 
> > of 'name', as
> > 
> > e.g. customer[@name='xxx']/value
> > 
> > I always get null as a result. The JXPathContext javadoc 
> contains the 
> > following which does not make things any clearer to me, although I 
> > suspect it may apply:
> > 
> > "JXPath does not support DOM attributes for non-DOM objects. Even 
> > though XPaths like "para[@type='warning']" are legitimate, 
> they will 
> > always produce empty results. The only attribute supported for 
> > JavaBeans is "name". The XPath "foo/bar" is equivalent to 
> > "foo[@name='bar']". "
> > 
> > Is there some special handling for 'name'?
> > 
> > I am using JXPath 1.1b1. Attributes in JAXB are stored as normal 
> > variables of the class, with corresponding get/set methods 
> (getName(),
> > setName()).
> > 
> > Thanks for any clarification,
> > 
> > Craig
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> commons-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more 
http://taxes.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



Re: [JXPath] The name attribute?

Posted by Dmitri Plotnikov <dp...@yahoo.com>.
Craig,

"Name" is a special attribute that represents the name of the property.
 It was of course a mistake to introduce this attribute without a
namespace, it should have been something like "jxpath:name", but now it
is too late to change it for compatibility reasons.  This special use
of the "name" attribute only applies to beans and maps and does not
apply to XML-based models (DOM, JDOM)

I recommend the use of the child access instead of attribute to access
properties, e.g. customer[name='xxx']


- Dmitri


--- Craig Raw <cr...@quirk.co.za> wrote:
> Hi,
> 
> I am using JXPath in combination with JAXB, and am finding it very
> useful. I have a question relating to a XPath query which contains
> predicates that specify attributes. 
> 
> e.g. customer[@id='1']/value
> 
> For the most part this works fine, but when the attribute has a name
> of
> 'name', as
> 
> e.g. customer[@name='xxx']/value
> 
> I always get null as a result. The JXPathContext javadoc contains the
> following which does not make things any clearer to me, although I
> suspect it may apply:
> 
> "JXPath does not support DOM attributes for non-DOM objects. Even
> though
> XPaths like "para[@type='warning']" are legitimate, they will always
> produce empty results. The only attribute supported for JavaBeans is
> "name". The XPath "foo/bar" is equivalent to "foo[@name='bar']". "
> 
> Is there some special handling for 'name'?
> 
> I am using JXPath 1.1b1. Attributes in JAXB are stored as normal
> variables of the class, with corresponding get/set methods
> (getName(),
> setName()).
> 
> Thanks for any clarification,
> 
> Craig
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/