|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Question for Xpath usage in setter, not query or transform
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








