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 8393111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:41:53+00:00 2026-06-09T19:41:53+00:00

I am trying to write something for another individual and im stuck on the

  • 0

I am trying to write something for another individual and im stuck on the final part of the stylesheet.

We have two XML Documents:

TestXML.xml:

<rootNode>
  <header>
    <title agg="sum">1</title>
    <records agg="sum">10</records>
    <number agg="min">5</number>
    </header>
</rootNode>

and TestXMLTwo.xml:

<rootNode>
  <header>
    <title agg="sum">2</title>
    <records agg="sum">20</records>
    <number agg="min">15</number>
    </header>
</rootNode>

Where if the node has its agg attribute equal to ‘sum’ we combine the values of the two documents nodes. I am doing this using:

<xsl:param name="InputFileOne">[EditedOut]\TestXML.xml</xsl:param>
<xsl:param name="InputFileTwo">[EditedOut]\TestXMLTwo.xml</xsl:param>

<xsl:template match="node()|@*">
  <xsl:call-template name="ConcatFiles"/>
</xsl:template>

<xsl:template name="ConcatFiles">
  <xsl:variable name="tempStoreDocOne" select ="document($InputFileOne)/rootNode/header" />
  <xsl:variable name="tempStoreDocTwo" select ="document($InputFileTwo)/rootNode/header" />

<xsl:element name="rootNode">
  <xsl:element name="header">

    <xsl:for-each select="$tempStoreDocOne/node()">
      <xsl:choose>

        <xsl:when test="./@agg = 'sum'">
          <xsl:variable name="tempElementDocTwo" select ="$tempStoreDocTwo/."/>
          <xsl:element name="{name(.)}">
            <xsl:value-of select=". + $tempElementDocTwo"/>
          </xsl:element>
        </xsl:when>

        <xsl:otherwise>
          <xsl:element name="{name(.)}">
            <xsl:value-of select="."/>
          </xsl:element>
        </xsl:otherwise>

      </xsl:choose>
    </xsl:for-each>

  </xsl:element>
</xsl:element>
</xsl:template>

However on the line <xsl:value-of select=". + $tempElementDocTwo"/> I just get a value of ‘22016’ for the <title> and 22025 for the <records>. Can someone enlighten me as to where I’m going wrong?

  • 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-09T19:41:54+00:00Added an answer on June 9, 2026 at 7:41 pm

    Change <xsl:for-each select="$tempStoreDocOne/node()"> to <xsl:for-each select="$tempStoreDocOne/*">, then add a variable storing the position i.e.

    <xsl:variable name="pos" select="position()"/>
    

    inside of the for-each, then change

          <xsl:variable name="tempElementDocTwo" select ="$tempStoreDocTwo/."/>
    

    to

          <xsl:variable name="tempElementDocTwo" select ="$tempStoreDocTwo/*[$pos]"/>
    

    Currently you are accessing the string value of the complete header element in the second document which is the concatenation of its descendant nodes while you want to access the child element with the same position as the one in the first document.

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

Sidebar

Related Questions

While trying to write an answer for another SO question something really peculiar happened.
Im trying to write something to get my images to show correctly. I have
I'm trying to write something very similar to an IM client (for learning purposes
I'm trying to write something similar to this (sorry if the sample is not
I am trying to write something in c++ with an architecture like: App -->
I am trying to write something that will fire an event anytime the hard
I'm trying to write something that calls a function at runtime without using reflection.
Forgive the title of the question; spent 20 minutes trying to write something coherent
I'm trying to write an procedure that does something after 2 objects are returned
I'm trying to write a code that could print something like this -xv -xvv

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.