[
Lists Home |
Date Index |
Thread Index
]
- To: "Chen, Andrew ." <ChenA@westinghouse.com>
- Subject: Re: [xml-dev] Question for Xpath usage in setter, not query or transformation
- From: Burak Emir <Burak.Emir@epfl.ch>
- Date: Tue, 03 Aug 2004 14:51:17 +0200
- Cc: "'xml-dev@lists.xml.org'" <xml-dev@lists.xml.org>
- In-reply-to: <945A2CFE6C33D611A49D0002A59305DB044B4765@SWEC9901>
- References: <945A2CFE6C33D611A49D0002A59305DB044B4765@SWEC9901>
- User-agent: Mozilla Thunderbird 0.5 (X11/20040208)
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
|