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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:04:44+00:00 2026-06-17T22:04:44+00:00

I am trying to create an XSLT to transform an XML document, but I’m

  • 0

I am trying to create an XSLT to transform an XML document, but I’m having trouble with grouping. I have no problems pulling out information for a single object, but I do not know how to group certain elements using xslt. I have tried xsl:for-each-group and xsl:key for grouping but i was not succesful in transforming.

Input:

<?xml version="1.0" standalone="yes"?>
<root>
    <node1>
        <ID>2</ID>
        <Name>ABCDE</Name>
        <Age>21</Age>
        <Skills>C++ C#</Skills>
        <worklocation>IN</worklocation>
        <designaton>Engineer I</designaton>
    </node1>
    <node2>
        <ID>3</ID>
        <Name>EFGH</Name>
        <Age>12</Age>
        <Skills>java</Skills>
        <worklocation>USA</worklocation>
        <designaton>Engineer II</designaton>
    </node2>
</root>

Desired Output:

<root>
    <node1>
        <ID>2</ID>
        <Name>ABCDE</Name>
        <Age>21</Age>
        <workInfo>
            <Skills>C++ C#</Skills>
            <worklocation>IN</worklocation>
            <designaton>Engineer I</designaton>
        </workInfo>
    </node1>
    <node2>
        <ID>3</ID>
        <Name>EFGH</Name>
        <Age>12</Age>
        <workInfo>
            <Skills>java</Skills>
            <worklocation>USA</worklocation>
            <designaton>Engineer II</designaton>
        </workInfo>
    </node2>
</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-06-17T22:04:45+00:00Added an answer on June 17, 2026 at 10:04 pm

    Use the identity template : see W3C recommandation

    <xsl:template match="@*|node()">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
    </xsl:template>
    

    And then apply a specific template that match the each child node of the root node and will create the workInfo node on the fly.

    <xsl:template match="/root/*">
      <xsl:apply-templates select="ID|Name|Age" />
      <workInfo>
        <xsl:apply-templates select="Skills|worklocation|designaton" />
      </workInfo>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an XSLT to transform an XML document and having
I am trying to transform RSSTV XML using XSLT. The problem I am having
I'm trying to create an XML file with a corresponding XSLT stylesheet. Everything sort
I want to transform this XML to create pages of tags as my XSLT
I've been trying to create an xslt template, but it keeps silently failing like
I've got an XML document, which Im trying to add an xslt to in
I'm trying to do an xml trasformation with XSLT. I have the following xml:
I'm trying to create a positional file out of an XML. I created the
I've been trying to figure out this XSLT/XML problem for the past few days
I'm trying to pass an XML document to an XSLT stylesheet as a parameter.

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.