[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Changing the content of an XML document

Wolfgang wolfgang at exist-db.org
Tue Sep 2 14:18:22 PDT 2008


  Changing the content of an XML document
> I tried the following, which is obviously wrong:
> 
> declare function local:alter() {
> let $myfile := doc('/db/myfile.xml')
> return update value $myfile/subnode/text() with
> 	'some other text'
> };

No, that's basically ok. Just make sure that $myfile/subnode/text() 
returns something. I guess you may need $myfile//subnode/text() instead.

Note: eXist's update syntax is still based on some old proposals (the 
implementation nevertheless works very well). The first XQuery update 
drafts were published later and I had no time to adopt this stuff yet 
(it doesn't have the highest priority for me personally).

> I'm neither sure how to specify the document I want to alter (the doc()
> function is surely wrong since it loads the file into memory) nor how to
> select the textnode using XPath (is /text() required here?).

doc("/db/myfile.xml") doesn't "load" the document into memory (it is a 
persistent document whose nodes reside on disk). It just returns a 
reference to that document.

Wolfgang


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.