Forum: Ruby on Rails REST API's and querying a graph of objects

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mike P. (Guest)
on 2006-01-20 18:26
(Received via mailing list)
Hey all,

I am wondering if anyone has given thought to using REST / XPath as
querying mechanism. That way you could have a URL that actually maps
to a collection of records (objects, really) that meet a certain
criteria and that are sorted a certain way.

Mike P.
Steve L. (Guest)
on 2006-01-20 23:07
(Received via mailing list)
I've seen that approach in the Java world.  You have to be wary using it
though, it opens you up to the possiblity of XPath Injection attacks.
Similar to SQL Injection attacks in principle, not as potentially

Mike P. (Guest)
on 2006-01-20 23:28
(Received via mailing list)
Any Java projects doing this that spring to mind?
Tom C. (Guest)
on 2006-01-21 00:08
(Received via mailing list)
PMD - - does something like this in that you can query
a source file's Abstract Syntax Tree using XPath.  Like this to get all
fields with the name "foo":


It's a bit esoteric - PMD is a Java static analysis tool - but, it seems
to fit the question...



P.S. Disclaimer: I'm the PMD lead guy.
Thibaut Barrère (Guest)
on 2006-01-21 02:08
(Received via mailing list)
> Any Java projects doing this that spring to mind?

Hi Mike

I've been using JXPath ( ) for
that purpose two years ago.



The org.apache.commons.jxpath package defines a simple interpreter of an
expression language called XPath. JXPath applies *XPath* expressions to
graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM
including mixtures thereof.

Consider this example:

Address address = (Address)JXPathContext.newContext(vendor).

This XPath expression is equvalent to the following Java code:

Address address = null;
Collection locations = vendor.getLocations();
Iterator it = locations.iterator();
while (it.hasNext()){
    Location location = (Location);
    String zipCode = location.getAddress().getZipCode();
    if (zipCode.equals("90210")){
      address = location.getAddress();

This topic is locked and can not be replied to.