[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

John Snelson john.snelson at oracle.com
Tue Sep 2 12:02:18 PDT 2008


  Changing the content of an XML document
Hi Georg,

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

John

Christian Schlaefcke wrote:
> Hi Georg,
> 
> take a look at this thread:
> http://www.stylusstudio.com/xquerytalk/200808/002828.html
> 
> I had a similar problem exept I wanted to delete certain nodes instead of
> replacing them.
> 
> Espacially the "identity transform"
> (http://en.wikipedia.org/wiki/Identity_transform) hint was very helpful
> and it sounds as it could help you with your problem too.
> 
> Best regards,
> 
> Christian
> 
> 
>>> Wolfgang [mailto:http://x-query.com/mailman/listinfo/talk] wrote:
>>>
>>>> This means, in the script I load the XML file into a
>>>> local variable using the doc() function and return the result to the
>>>> client.
>>>  >
>>>  > But now, occationally some of the content of the file has
>>> to be altered.
>>>
>>> I'm not sure I completely understand the question. Is the document
>>> stored in the db or do you load it from the filesystem? And
>>> do you only
>>> need to temporarily change some content of that file (in which case I
>>> would probably call an XSLT) or permanently (use XQuery
>>> update extensions)?
>> Actually I can reduce my question to the following: Assuming I have a
>> variable which stores a node-tree like that
>>
>> let $tree :=
>>   <node>
>>     <subnode>
>>       some text
>>     </subnode>
>>   </node>
>>
>> In reality $tree is the entire XML file which I want to send back to the
>> client. Now, depending on some conditions I want to change the content
>> of <subnode> "some text" to "some other text", before sending it. I
>> don't actually want to alter the file in the database, just the message
>> that I'm sending.
>>
>> If I placed the XML-file inside the script, I would write something like
>>
>> <node>
>>   <subnode>
>>   {
>>     if ($condition)
>>     then "some text"
>>     else "some other text"
>>   }
>>   </subnode>
>> </node>
>>
>> But since I have a couple of not too small XML files I fear that this
>> will get a bit overcrwoded.
>> Do you understand what I mean?
>>
>> Best,
>> Georg
> 
> 
> 
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk


-- 
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:            http://oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net


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-2011 All Rights Reserved.