Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Merge DCRs in 2 branches
tsatt
Hi,
I am working on a perl script to merge 2 DCRs in 2 different branches.
I am using DCRnode module and am having issues setting specific nodes in the XML.
Using some logic I have an array of nodes that contains final nodes that need to be in the tree. I want to for example in section ID A replace Links A1 and Links A2 with the new list that contains 3 links and same for section ID B. I wish there was a replaceNode function or something in DCRnode.
ok the structure fo the DCR is like this
<record>
<sections>
<Id>A</Id>
<Links>
<Id>A1</Id>
</Links>
<Links>
<Id>A2</Id>
</Links>
</sections>
<sections>
<Id>B</Id>
<Links>
<Id>B1</Id>
</Links>
<Links>
<Id>B2</Id>
</Links>
</sections>
</record>
Thanks
Solaris 8
TeamSite 6.5
Find more posts tagged with
Comments
nipper
Is that example the final output or one of the source DCRs ? Post both the source and output and what you are currently using andy someone may be able to help.
FWIW, when I have this type of issue, I never update with DCRNode. Rather I read one or both files in and parse them with one of the stock parsers. Then I build XML by hand instead of using a PM to build it.
For easy merges one can also use regex.
For my money those are easier and faster.
HTH
Andy
tsatt
Thanks for replying.
The example in the original post was of the source DCR.
The target DCR will basically have more Link nodes in each sections.
Example snippet below: LInks within Section with ID A will have 4 links instead of 2.
<Links>
<Id>A1</Id>
</Links>
<Links>
<Id>A2</Id>
</Links>
<Links>
<Id>A3</Id>
</Links>
<Links>
<Id>A4</Id>
</Links>
Tying to do something like, get all the nodes of Links and replace with my new node list of links in each section
Thanks
tsatt
I found the solution.
I was initially trying to use set_node_list but was having issue as it would replace everything with the new nodes which I did not want as I only wanted to replace nodes of specific kind. So I used set_inner_xml method along with regex search and replace. One thing I was doing wrong was of using get_xml instead of get_inner_xml method to get the xml of the parent node and therefore was getting Links within Links nodes.
It is working now.
Thanks
GridCells.rptdesign