XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
SV: How to merge nodes?

Hi,

After sleeping more on it I came out with an less technical way to solve it by marking nodes and pruning all nodes if themselves or their children has not been marked.




Från: Henning Phan <henningphan@hotmail.com>
Skickat: den 5 juli 2016 17:56
Till: xml-dev@lists.xml.org
Ämne: [xml-dev] How to merge nodes?
 

Hi,
Im using basex, a xml database and I just started doing xquery a month ago and may not use the correct terminology.
I need a sanity check on my idea and also accept alternative solutions.

I have 3 files.
$conf = 5 GB xml file containing the current server configuration
$input= The changes we want to do to $conf, assume each line is a tuple, (unique path to a node and the new value the node should have)
The only way to change the configuration to the server is to upload a configuration file to the server, but because only a fraction of the values might be updated we DO NOT want to want to modify $conf and upload it.
$newConf= The new configuration file containing the updated values from $input and has the same structure as $conf. The file to be uploaded to the server.

So want to create $newConf from $conf and $input.

========= example =============
Generic case scenario, $conf has higher node diversity and depth.
======= $conf
<a>
<b id="1">
<c>1</c>
<c1>1</c1>
<c2>1</c2>
</b>
<b id="2">
<c>1</c>
<c1>1</c1>
<c2>1</c2>
</b>
<b id="3">
<c>1</c>
<c1>1</c1>
<c2>1</c2>
</b>
<x id="2">
<c>1</c>
<c1>1</c1>
<c2>1</c2>
       <y attr="">
              <z>1</>
       </y>
</x>
</a>
=================== $input (: Example input, paths and value can be arbitrary :)
(//b[@id eq 1]/c, 2)
(//b[@id eq 1]/c1, 2)
(//b[@id eq 3]/c1, 2)


================= $newConf
(: This file is a result of the input $conf and $input, note that the hiearchy is retained and attributes but only has the updated values from $input :)
<a>
   <b id="1">
<c>2</c>
<c1>2</c1>
</b>
   <b id="3">
<c1>2</c1>
</b>

</a>
======= Current plan (: Very rough idea :)
for $line in $input
let $node := extract($conf,$line)
merge($newConf, $node)  (: This is some sort of update function :)

============= Last words
1. Please help me out with the merge function
2. Anything I forgot to consider?
3. I did look up on streaming transform but I dont see advantages over the current plan because it feels like it would be hard to feed the $input file. And my lack of skills in that area.

Thank you for reading, 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS