Altova Mailing List Archives>Archive Index >xml-dev Archive Home >Recent entries >Thread Prev - Question for Xpath usage in setter, not query or transformation [Thread Next] Re: [xml-dev] Question for Xpath usage in setter, not query or transformationTo: "Chen, Andrew ." <ChenA@------------.---> Date: 8/3/2004 12:51:00 PM Chen, Andrew . wrote: > Is it possible to set data in a DOM tree through a simple Xpath like > syntax? > (Although it is Java based, you might take some inspiration from this one) At IBM research, people are working on a Java + XML, called XJ. Here is a short summary of the WWW2004 conference poster. Vivek Sarkar presented it also at ECOOP2004 in Oslo. http://www2004.org/proceedings/docs/2p340.pdf Here's the extract of the code. They use backquotes `...` to embed XPath expressions in Java syntax. 1 import "po.xsd"; 2 public class Discounter { 3 public void giveDiscount(){ 4 purchaseOrder po = (purchaseOrder)XMLItem.load("po.xml", null); 5 6 XML<item> bulkPurchases = po/item[quantity/text() > 50] ; 7 for (int i = 0; i < bulkPurchases.size(); i++) { 8 item current = bulkPurchases.get(i); 9 `current/USPrice/text()` *= 0.80; // Deduct 20% 10 } 11 XMLItem.serialize(po, "po.xml"); 12 } 13 } Again, some fancy XML database API might also provide what you need but I do not know of any. Berkeley DB XML by sleepycat and Apache do not seem offer such an update mechanism, but only "insert-before" and "insert-after". Looks like something worth implementing, but if the programs are to be readable, it requires a clean and at the same time flexible XML API, something which does not seem to exist in the mainstream programming language world, or a language extension, which most users are not inclined to use. cheers, Burak | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
