[xquery-talk] Changing the content of an XML document

Piewald, Georg georg.piewald at siemens.com
Tue Sep 2 10:59:18 PDT 2008


> Wolfgang [mailto:wolfgang at exist-db.org] 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 :=
      some text

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

    if ($condition)
    then "some text"
    else "some other text"

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?


More information about the talk mailing list