[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to merge nodes?

  • From: Henning Phan <henningphan@hotmail.com>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Tue, 5 Jul 2016 15:56:17 +0000

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]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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