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

  • Home
  • SEARCH
  • 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 3699014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:03:06+00:00 2026-05-19T05:03:06+00:00

i have multiple Xml files, in a List<File> . What i want is to

  • 0

i have multiple Xml files, in a List<File>. What i want is to transform those xml into one Xml with an Xsl :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" indent="yes"/>

<xsl:template match="testsuites">
    <xsl:call-template name="summary"/>
</xsl:template>

 <xsl:template name="summary">
           <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
         <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
         <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
 <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
         <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
          <xsl:attribute name="class">
                <xsl:choose>
                    <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
                    <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
                </xsl:choose>
            </xsl:attribute>
         <Build>
          <NombreTest><xsl:value-of select="$testCount"/></NombreTest>
          <Failures><xsl:value-of select="$failureCount"/></Failures>
          <Erreurs><xsl:value-of select="$errorCount"/></Erreurs>
         <PercentSucces><xsl:call-template name="display-percent">
                    <xsl:with-param name="value" select="$successRate"/>
                </xsl:call-template></PercentSucces>
          <ExecTime><xsl:call-template name="display-time">
                   <xsl:with-param name="value" select="$timeCount"/>
                </xsl:call-template> </ExecTime>
          </Build> 
       </xsl:template>

<xsl:template match="failure">
    <xsl:call-template name="display-failures"/>
</xsl:template>

<xsl:template match="error">
    <xsl:call-template name="display-failures"/>
</xsl:template>

<xsl:template name="display-time">
    <xsl:param name="value"/>
    <xsl:value-of select="format-number($value,'0.000')"/>
</xsl:template>

<xsl:template name="display-percent">
    <xsl:param name="value"/>
    <xsl:value-of select="format-number($value,'0.00%')"/>
</xsl:template>

<xsl:template name="display-failures">
    <xsl:choose>
        <xsl:when test="not(@message)">N/A</xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="@message"/>
        </xsl:otherwise>
    </xsl:choose>
 </xsl:template>

</xsl:stylesheet>

My problem is that when i am looping and apply the transform with a TransformerFactory it always erase the output XML. I want to edit the output instead.

I know that i can do it in java with a temporary XML and after merge it, but i’m almost sure that it is possible in XSL?

Thanks for helping

  • 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-05-19T05:03:06+00:00Added an answer on May 19, 2026 at 5:03 am

    You need to pass all document URLs within a single external parameter and you will typically have a transformation like this:

    <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="pdocNames">
      <name>doc1.xml</name>
      <name>doc2.xml</name>
      <name>doc3.xml</name>
     </xsl:param>
     
        <!-- you can directly use $pdocNames/name
            if the param is provided externally -->
     <xsl:variable name="vDocNames" select=
      "document('')/*/xsl:param[]@name='pdocNames']/name"/>
        
     <xsl:template match="/">
         <combinedDocs>
        <xsl:copy-of select="document($vDocNames)"/>
         </combinedDocs>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on any XML document (not used), it performs the following:

    1. Obtains the name elements that contain the provides in the parameter $pdocNames document URIs. These elements are contained in the variable vDocNames.

    2. Creates the top element for the output document (in this case named combinedDocs).

    3. Copies all XML documents, whose URIs are in the name elements contained in the vDocNames variable. The standard XSLT function document() is used here.

    Do note:

    The URLs of all wanted XML documents must be passed externally via a parameter to the transformation. It is vendor-dependent how to pass a parameter to the transformation. You need to read the documentation provided for your particular XSLT processor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is it possible to have app.config file like this : <?xml version=1.0 encoding=utf-8 ?>
I have an XML file (on the left) and I want to create multiple
I have set up multiple targets in a single xml file. I expect all
I have a maven pom.xml file with multiple instances of a same goal defined
I have an xml file and I am trying to get a list of
I have two files file a.) xmlFile.xml b.) emails.txt xmlFile.xml has the following structure
I have been creating multiple background threads to parse xml files and recreate new
I have an XML file which contains multiple nodes that have children. If the
I have multiple XML descriptor files in my actual project and I'm having troubles
We have a issue where we are trying to merge persistence.xml files from multiple

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.