Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:53:44+00:00 2026-06-11T05:53:44+00:00

I have two xml files. I want to merge them and make some arithmetic

  • 0

I have two xml files. I want to merge them and make some arithmetic with a few attributes. Please provide some ideas. I am using a standard xslt http://informatik.hu-berlin.de/merge to merge the files.

File 1:

<coverage branch-rate="0.5125" branch-total="50" line-rate="0.00593031875463">  
</coverage> 

File 2:

<coverage branch-rate="0.5" branch-total="40" line-rate="1.0">  
</coverage>

Expected Result File

<coverage branch-rate="(0.5125*50 + 05*40)/(50+40)" branch-total="50" line-rate="0.00593031875463"> 
</coverage> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:53:46+00:00Added an answer on June 11, 2026 at 5:53 am

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:param name="pFile1" select="'file:///c:/temp/delete/file1.xml'"/>
     <xsl:param name="pFile2" select="'file:///c:/temp/delete/file2.xml'"/>
    
     <xsl:variable name="vF2Cover" select="document($pFile2)/coverage"/>
    
     <xsl:template match="/">
       <xsl:apply-templates select="document($pFile1)/coverage"/>
     </xsl:template>
    
     <xsl:template match="coverage">
       <coverage branch-rate=
        "{(@branch-rate*@branch-total + $vF2Cover/@branch-rate*$vF2Cover/@branch-total)
          div (@branch-total+$vF2Cover/@branch-total)
         }"
       branch-total=
        "{@branch-total*(@branch-total>= $vF2Cover/@branch-total)
        +
         $vF2Cover/@branch-total*($vF2Cover/@branch-total >@branch-total)
         }"
       line-rate=
        "{@line-rate*($vF2Cover/@line-rate >= @line-rate)
        +
         $vF2Cover/@line-rate*(@line-rate > $vF2Cover/@line-rate)
         }"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on any XML document (not used), and having the two provided XML documents reside in:

    c:/temp/delete/file1.xml:

    <coverage branch-rate="0.5125" branch-total="50" line-rate="0.00593031875463">
    </coverage>
    

    and c:/temp/delete/file2.xml:

    <coverage branch-rate="0.5" branch-total="40" line-rate="1.0">
    </coverage>
    

    produces the wanted, correct result:

    <coverage branch-rate="0.5069444444444444" branch-total="50" line-rate="0.00593031875463" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two xml files and I want to diff them. The problem is
Please i want to know how i can merge two xml files into one
I have two XML sources to retrieve data from. I want to use them
I have two spring config files and I'm specifying them in my web.xml as
I have two layouts(xml files) and I want to flip from one page to
I have two large XML files(c.100MB) containing a number of items. I want to
I want to merge two files A.xml and map.xml with Node elements according to
I want to parse a large XML file and I have two options: Perl
I have set the two buttons in preference.xml file. I want to go to
I have two XML files that are generated by another application I have no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.