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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:57:55+00:00 2026-05-27T04:57:55+00:00

I have a strangely formatted XML document which features a few tags that repeat;

  • 0

I have a strangely formatted XML document which features a few tags that repeat; but I need to process this data using a tool that doesn’t support repeated tags.

Thus I need a way to concatenate the data within the repeated tags.

My initial document appears as follows:

<root>
    <irrelevantTag1>irrelevantData1</irrelevantTag1>
    <irrelevantTag2>irrelevantData2</irrelevantTag2>
    <irrelevantTag3>
        <irrelevantTag4>irrelevantData4</irrelevantTag4>
        <keyword>one</keyword>
        <keyword>two</keyword>
    </irrelevantTag3>
    <irrelevantTag5>irrelevantData5</irrelevantTag5>
</root>

I need a stylesheet to concatenate the values with the two “keyword” tags and produce a single keyword tag as in the following output:

<root>
    <irrelevantTag1>irrelevantData1</irrelevantTag1>
    <irrelevantTag2>irrelevantData2</irrelevantTag2>
    <irrelevantTag3>
        <irrelevantTag4>irrelevantData4</irrelevantTag4>
        <keyword>one,two</keyword>
    </irrelevantTag3>
    <irrelevantTag5>irrelevantData5</irrelevantTag5>
</root>
  • 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-27T04:57:55+00:00Added an answer on May 27, 2026 at 4:57 am

    These two templates should do the trick:

    <xsl:template match="keyword[1]">
       <keyword>
          <xsl:for-each select="../keyword">
             <xsl:if test=". != ../keyword[1]">,</xsl:if>
             <xsl:value-of select="."/>
          </xsl:for-each>
       </keyword>
    </xsl:template>
    <xsl:template match="keyword"/>
    

    Use an apply-templates on a match for the parent element, or simply plug them into an identity transform.

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

Sidebar

Related Questions

I have this code, but strangely it always echos out yes!, even if there
I have an XML file formatted like this: <?xml version=1.0 encoding=utf-8?> <Snippets> <Snippet name=abc>
I have an swf file which behaves strangely on IE. The thing is that
I have used a scrollTop function in jQuery for navigating to top, but strangely
We have an ASP.Net app, that behaves strangely under IIS6. The app itself is
I have a databound ListBox that is behaving strangely. The ListBox's SelectionMode property is
I have a strange issue that I'm baffled with but I'm sure someone in
I have observed my php application behaving rather strangely on the server that it
I have a classic ASP page that submits back to itself. Strangely, the values
I have a Java application that launches an external process (Internet Explorer) using ProcessBuilder.

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.