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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:33:19+00:00 2026-06-04T02:33:19+00:00

I have two source files which I need to combine on a row by

  • 0

I have two source files which I need to combine on a row by row basis. I am happy reading the files into a variable and I am happy with the logic but the syntax has me stumped. For each row in file 1 I need to loop round each row in file 2 and output the two variables concatenated together:

File 1:

<rows>
    <row>1</row>
    <row>2</row>
    <row>3</row>
    <row>4</row>
</rows>

File 2:

<rows>
    <row>a</row>
    <row>b</row>
</rows>

Required output:

<rows>
    <row>1/a</row>
    <row>1/b</row>
    <row>2/a</row>
    <row>2/b</row>
    <row>3/a</row>
    <row>3/b</row>
    <row>4/a</row>
    <row>4/b</row>
<rows>

My (poor) attempt at getting the XSLT to work:

<rows>
    <xsl:apply-templates select="document('file1.xml')/rows/row" />
</rows>

<xsl:template match="row">
    <xsl:apply-templates select="document('file2.xml')/rows/row" />
</xsl:template>  

<xsl:template match="row">
    <row><xsl:value-of select="???" />/<xsl:value-of select="???" /></row>
</xsl:template>

(These files are simplified versions of what I actually have)

How do I make one template match one ‘row’ value and the other match another (both source files use the same structure). And how do I set those ‘???’ values?

  • 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-04T02:33:21+00:00Added an answer on June 4, 2026 at 2:33 am
    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:variable name="vDoc2">
        <rows>
            <row>a</row>
            <row>b</row>
        </rows>
     </xsl:variable>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="/*">
      <rows>
        <xsl:apply-templates/>
      </rows>
     </xsl:template>
    
     <xsl:template match="row">
       <xsl:apply-templates select="$vDoc2/*/row" mode="doc2">
         <xsl:with-param name="pValue" select="."/>
       </xsl:apply-templates>
     </xsl:template>
    
     <xsl:template match="row" mode="doc2">
       <xsl:param name="pValue" />
    
       <row><xsl:sequence select="concat($pValue, '/', .)"/></row>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided first XML document:

    <rows>
        <row>1</row>
        <row>2</row>
        <row>3</row>
        <row>4</row>
    </rows>
    

    the wanted, correct result is produced:

    <rows>
       <row>1/a</row>
       <row>1/b</row>
       <row>2/a</row>
       <row>2/b</row>
       <row>3/a</row>
       <row>3/b</row>
       <row>4/a</row>
       <row>4/b</row>
    </rows>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A bit context. Let's say I have source files, which need to end up
I have many Java source files which I need to change their package line
I have two tab delimited csv files (with headers) that I need to merge
I have two C++ projects in a solution both of which need to share
Suppose I have two lists that holds the list of source file names and
I have two large source trees. One of them has some out of date
I have two identical SQL Server tables ( SOURCE and DESTINATION ) with lots
I have a class with two constructors that look like this: public MyClass(SomeOtherClass source)
I have a form in Axapta/Dynamics Ax (EmplTable) which has two data sources (EmplTable
I am starting a project in which I need to get two sets of

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.