>
Any other suggestions?

Hm, no easy one. You could pass on a function that does the navigation to the relevant nodes:

  let $f := function($node) { $node/update1 }
  return $a update replace value of node $f(.) with "bla"

Christian




On Fri, Aug 8, 2014 at 4:26 PM, Rob Stapper <r.stapper@lijbrandt.nl> wrote:

Hi  Christian,

 

Thanx for the ultra fast response.

 

The problem is that my actual program  I don’t know the path from the root of $a to “default/text1” ( $c), in this case: “./”. Element:  “default/text1” ( $c), could be located anywhere in $a.

I do know the relative path to “default/text1” from $b, in this case: “$b/parent::*/default/text1”.

 

It’s not that simple;-) ( not to me anyway)

 

Rob

 

PS I’ve tried it with soring the XML in the database and using node-id(). But apparently the copy doesn’t use node-id’s. So this didn’t work.

 

 

Van: Christian Grün [mailto:christian.gruen@gmail.com]
Verzonden: vrijdag 8 augustus 2014 16:04
Aan: Rob Stapper
CC: BaseX
Onderwerp: Re: [basex-talk] How to update a XML-file from itself?

 

Hi Rob,

 

I didn’t find variable $c in your example, but the following modification might give you the correct result:

 

  let $update.processor := function($a, $b) {

    ($a update replace value of node ./default/text1 with ())

      update insert node $b/string into .//default/text1

  }

 

…or (depending on what you plan to do):

 

let $update.processor := function($a, $b) {

  ($a update insert node $b/string into default/text1)

}

 

As you already observed, it is only possible to update nodes that have been copied by the 'update' keyword.

 

Hope this helps,

Christian

 

 

 

On Fri, Aug 8, 2014 at 3:49 PM, Rob Stapper <r.stapper@lijbrandt.nl> wrote:

Hi,

 

Can anyone help me with this casus?

 

I want to update XML-source: $a, by inserting the content of XML-element: $b, a sub-element of $a, into XML-element: $c, also a sub-element of $a.

The relative path from $b to $c is known.

 

See attached example: the problem is that the update works on a copy of $a and that the destination-element: $b/parent::*/default/text1, is actually an element of the original $a.

How can I make it point to the corresponding element in the copy?

 

Any suggestions?

 

Thanx in advance,

 

Rob Stapper

 


Afbeelding verwijderd door afzender.

Dit e-mailbericht bevat geen virussen en malware omdat avast! Antivirus actief is.

 

 




Dit e-mailbericht bevat geen virussen en malware omdat avast! Antivirus actief is.