[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-users
Subject:    Re: [jibx-users] xpath as a data binding tool?
From:       Eitan Suez <eitan-keyword-deux.352d02 () u2d ! com>
Date:       2006-01-17 15:44:42
Message-ID: 1137512682.8588.24.camel () localhost ! localdomain
[Download RAW message or body]

hi tilman,

  i apologize for such a late reply.  you describe
  very specifically what you are trying to achieve:

    querying java object trees using xpath, and somehow
    leveraging jibx to do this.

  this reminds me a little be of ognl:
    http://www.ognl.org/

  it's supposed to be a mechanism similar to xpath, but
  for querying objects.  i'm not sure how it stacks up
  in terms of performance, or whether the fact that it
  is not related to xml makes it applicable for what 
  you're trying to do.

  my suggestion was somewhat vague in my post, that
  we discuss how xpath could be leveraged in jibx.
  
  so your message actually does describe one relevant
  way of integrating xpath: to query object trees.

  my idea was to use xpath to facilitate how mappings
  are specified in a jibx binding file, by extending 
  the name="" attribute with a more generic 
  xpath="[xpath expression goes here]"
  as i believe it would to be a more flexible way of
  relating a java property to a specific location in
  an xml document (relative to a parent).

/ eitan

On Mon, 2006-01-02 at 11:56 +0100, TIlman Linden wrote:
> Hi Eitan and all,
> 
> I was also thinking about integration of JiBX and XPath recently. I was 
> looking for a possibility to run XPath queries over Java  object trees 
> (JOTs), which are "somehow" connected to XML data ("somehow" means, that 
> this could for example be described by a JiBX binding.) While jaxen and 
> JXPath claim to support this, in both cases I wasn't satisfied with the 
> exisiting techniques. The JXPath support for JOT works, but the XPath 
> expression for querying an object tree is not necessarily equal to the 
> expression for querying the according XML document if you want to obtain 
> equal results. Jaxen's support for JOT seems not to be implemented 
> completely, and there were some remarks on the jaxen developer list 
> about some problems which need to be solved beforehand. One of these 
> mentioned problems was that in JOTs a set of the XPath axes is not 
> clearly defined. This especially counts for the "parent" axis, and all 
> axes which are based on the document order, like "descendant" and 
> "ascendant" axes.
> 
> This is where a binding framework like JiBX comes into play, because a 
> binding as in JiBX exactly defines the axes missing in Java. With a 
> binding definition you always know the "document place" of a member in a 
> JOT. To run XPath on the JOT using the same expressions as if you would 
> query the XML document, you would not even need an attribute 
> "xpath='...'" like Eitan proposed (Or did I miss something in that idea?)
> 
> I am wondering about possible use cases of the discussed techniques. In 
> our current project we are using XUpdate (including XPath) for a 
> protocol to synchronize distributed instances of XML documents which are 
> represented in JOTs. Here we really need an integration of 
> (un)marshalling and XPath/XUpdate functionality for JOTs. We do not use 
> JiBX currently (because I wasn't the one to decide which data binding 
> framework to use :) but a combination of JDOM and handmade code for 
> (un)marshalling and a prototypical extension for jaxen to run 
> XPath/XUpdate over bound JOTs. While this works quite OK, the code is 
> rather blown up and the performance is of course weak (our prototypical 
> binding framework for XPath queries uses Java reflection API).
> 
> Which use cases could other people on this list imagine? One could 
> argue, that when using XML techniques like XPath and XUpdate to access 
> your data, (un)marshalling to a customized JOT becomes obsolete. One 
> could also just use a common DOM implementation to represent your data. 
> (I think the article mentioned by Eitan points in this direction.) Is 
> there the common need for "native" Java access to data 
> (Object.getMemeber()) combined with XPath access (/node/@attribute) to 
> the same data?
> 
> Regards,
> 
> Tilman
> 
> 
> Eitan Suez wrote:
> 
> >hi all,
> >
> >  while on developerworks reading dennis' articles, i also
> >  came across this one:
> >    http://www-128.ibm.com/developerworks/java/library/x-pracdb8.html
> >   entitled: 'xpath as a data binding tool, part 1'
> >
> >  i have to admit i just skimmed the article but it grabbed 
> >  my attention.  i've been thinking for a while that adding
> >  xpath to jibx would be a good move.
> >
> >  more specifically what i mean is that the jibx binding
> >  vocabulary could be extended nicely with xpath support.
> >
> >  here's an example binding file:
> ><binding name="binding1">
> >  <mapping name="customer" class="simple.Customer">
> >    <structure field="name">
> >      <value name="first-name" field="firstName"/>
> >      <value name="last-name" field="lastName"/>
> >    </structure>
> >    <value name="street" field="street1"/>
> >    <value name="city" field="city"/>
> >    <value name="state" field="state"/>
> >    <value name="zip" field="zip"/>
> >    <value name="phone" field="phone"/>
> >  </mapping>
> ></binding>
> >
> >  in jibx we use the attribute 'name' to bind a specific
> >  element or attribute name to a java field.  i think that could
> >  be a perfect spot in the jibx binding file for introducing
> >  an alternative to name="" : xpath=""
> >
> >  as in:
> >   <value xpath="name/first-name" field="firstName" />
> >
> >  i know this is not a complete description of how such an
> >  enhancement would work or fit in to jibx.  but it's a starting
> >  point for consideration, and definitely for discussion.
> >
> >/ eitan
> >
> >


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic