[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

Piewald, Georg georg.piewald at siemens.com
Tue Sep 2 13:58:24 PDT 2008


  Changing the content of an XML document
 

Wolfgang [mailto:http://x-query.com/mailman/listinfo/talk] wrote:
>
>> The identity transform will work, and is essentially the 
>> same as the 
>> transformation function that Wolfgang suggests. However I think a 
>> transform expression is easier to understand if eXist 
>> supports XQuery 
>> Update:
>> 
>> copy $a := $tree
>> modify replace value of node $a//subnode with
>>   if($condition) then "some text" else "some other text"
>> return $a
> 
> Right now, updates are only supported on documents stored in 
> the db (we 
> directly modify the persistent dom). To use this approach, 
> the document 
> fragment would need to be saved first, which is probably too much 
> overhead for a one-time use.
> 

Ok, XQuery Update looks most convenient to me and I don't mind if I
actually do alter the files stored in the db. But I still can't get it
to work, as I don't really understand the required syntax (as described
at http://exist.sourceforge.net/update_ext.html).

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'
};

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?).

Thanks for all the good answers so far!
Georg



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.