Ok, so I'd better backup them via an XSL, and then delete the originals
nodes.
And then, to re-add the backuped nodes, to do this via an XSL.
Thanks Michael,
Christophe
On 30/12/2010 01:04, Michael Kay wrote:
> On 29/12/2010 14:37, Christophe Marchand wrote:
>> Hi,
>>
>> using linked tree, I need to backup some nodes from a document for a
>> XSLT process, and then to re-add them to the original document.
> In XQuery Update, the rules for what happens to a node after it is
> deleted have been left very fuzzy, and this fuzziness is reflected in
> the Saxon primitives. One reason for this is the rule that when placing
> nodes into document order, nodes from different documents are never
> interleaved. This means that it is impossible for a node to be moved
> from one document to another while retaining its identity (or at any
> rate, its position in document order; and the idea that it can retain
> its identity while changing its position in document order is rather
> disquieting).
>
> I'd recommend copying the nodes before deleting them, and working with
> the copy. (Unfortunately copying a node isn't trivial at the Java level;
> the simplest way to do it is to run an identity transformation).
>
> Michael Kay
> Saxonica
>
>> Here is a sample code, it's more easy to understand :
>>
>> XPathSelector linesToBackupSelector =
>> xpc.compile("//n:LigneBudget[n:Fonction]").load();
>> linesToBackupSelector.setContextItem(budget);
>> ElementImpl backup = new ElementImpl();
>> backup.setNameCode(namePool.allocate("", Constants.MY_NS, "Backup"));
>> for (XdmItem item:linesToBackupSelector) {
>> MutableNodeInfo line = (MutableNodeInfo)item;
>> line.delete();
>> // my problem is here
>> backup.insertChildren(new NodeInfo[] {
>> line.getUnderlyingNode() }, false, true);
>> }
>> ....
>> // then, re-add lines to budget
>>
>> MutableNodeInfo.delete() javadoc explains that the effect of other
>> operations on a deleted node is undefined. So, I'm not sure that's the
>> correct way to do it ; maybe I'd prefer to clone nodes before removing
>> them, and add the cloned one...
>>
>> Any idea ?
>>
>> Christophe
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
>> to consolidate database storage, standardize their database environment, and,
>> should the need arise, upgrade to a full multi-node Oracle RAC database
>> without downtime or disruption
>> http://p.sf.net/sfu/oracle-sfdevnl
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> saxon-help@...
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>
> ------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> to consolidate database storage, standardize their database environment, and,
> should the need arise, upgrade to a full multi-node Oracle RAC database
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
|