You haven't provided the full XML, so I had to wrap each file into <root>...</root> in order to be able to play with them. I named the first file 1.xml and the second one 2.xml . I then implemented the logic in XML::XSH2:
my $file2 := open 2.xml ; open 1.xml ; my $t := hash langSet[@xml:lang='EN']/tig/term /root/termEntry ; for my $entry in $file2/root/termEntry { my $entry1 = xsh:lookup('t', $entry/langSet[@xml:lang='EN']/tig/te +rm) ; if ($entry1) { for my $lang in $entry/langSet/@xml:lang { if (0 = count($entry1/langSet[@xml:lang=$lang])) cp $lang/.. into $entry1 ; } } else { cp $entry into /root ; } } save :b ;
BTW, I had to remove the </termEntry> before <langSet xml:lang="FR"> in the expected output, I hope that's what you meant.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
In reply to Re: Updating XML files
by choroba
in thread Updating XML files
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |