short notes is a journal on software, systems, engineering practices among other things.
Copyright © 2002-2006 short notes. All rights reserved.    contact address: email to the editor   ISSN 1543-6489

short notes
 
Tuesday, 18. June 2002

Herblock's history


Herblock's history at Library of Congress


 
permalink   
 

JXPath - XPath for Java


From Jakarta page on JXPath:

JXPath applies XPath expressions to graphs of objects of all kinds: JavaBeans, Maps, Servlet contexts, DOM etc, including mixtures thereof.

Consider this example:

Address address = (Address)JXPathContext.newContext(vendor).
         getValue("locations[address/zipCode='90210']/address");

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)it.next();
    String zipCode = location.getAddress().getZipCode();
    if (zipCode.equals("90210")){
      address = location.getAddress();
      break;
    }
}


Some pros and cons:
Pro: Code gets shorter.
Con: Compiler can't do type checking. Expression is just an embedded string.

Pro: Because it's string we can do dynamic queries via file system, telnet, http texts!
Con: Security.

Pro: Same expression/query language for Java and XML.
Con: Why mix oil and water?

Pro: XPath can be the universal query language.
Con: We live in an interesting time.

NB JXPath is a subset of Jex API.
 
permalink   
 

 
Published since 2002-04-23
Updated: 2010-10-16
status
Youre not logged in ... Login
menu
June 2002
SunMonTueWedThuFriSat
1
2345678
9101112131415
16171819202122
23242526272829
30
MayJuly
recent
recent

RSS Feed

RSS integration

Made with Antville
powered by
Helma Object Publisher