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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:06:22+00:00 2026-05-24T08:06:22+00:00

I need to transform my XML into another datastructure. I recieve the XML like

  • 0

I need to transform my XML into another datastructure.
I recieve the XML like below:

<results>
  <resultset>
    <result>
      <name>BMW Cars</name>
      <code>BMW Pkw</code>
      <model.model>730d Saloon</model.model>
      <model.name>KM21</model.name>
    </result>
    <result>
      <name>BMW Cars</name>
      <code>BMW Pkw</code>
      <model.model>120i 3 doors</model.model>
      <model.name>UA51</model.name>
    </result>
    <result>
      <name>BMW Cars</name>
      <code>BMW Pkw</code>
      <model.model>Z4 sDrive23i</model.model>
      <model.name>LM31</model.name>
    </result>
    <result>
      <name>Audi</name>
      <code>AUDI</code>
      <model.model>A4 SAL.3.0 Q SPT TIP 5SPD</model.model>
      <model.name>8E2SFZ04</model.name>
    </result>
    <result>
      <name>Audi</name>
      <code>AUDI</code>
      <model.model>A6 SAL. 2.5TDI SPORT MAN.6SP.</model.model>
      <model.name>4B2BBC04</model.name>
    </result>
    <result>
      <name>AUdi</name>
      <code>AUDI</code>
      <model.model>A8 4.2 QUATTRO 6-SPD TIP</model.model>
      <model.name>4E201L04</model.name>
    </result>
  </resultset>
</results>

And I need it to be like this:

<results>
  <resultset>
    <result>
      <name>BMW Cars</name>
      <code>BMW Pkw</code>
      <model.model>730d Saloon</model.model>
      <model.name>KM21</model.name>
      <model.model>120i 3 doors</model.model>
      <model.name>UA51</model.name>
      <model.model>Z4 sDrive23i</model.model>
      <model.name>LM31</model.name>
    </result>
    <result>
      <name>Audi</name>
      <code>AUDI</code>
      <model.model>A4 SAL.3.0 Q SPT TIP 5SPD</model.model>
      <model.name>8E2SFZ04</model.name>
      <model.model>A6 SAL. 2.5TDI SPORT MAN.6SP.</model.model>
      <model.name>4B2BBC04</model.name>
      <model.model>A8 4.2 QUATTRO 6-SPD TIP</model.model>
      <model.name>4E201L04</model.name>
    </result>
  </resultset>
</results>

I’ve spent a lot of time to solve this, but no luck so far.
Does anyone know how to solve this problem?

  • 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-24T08:06:25+00:00Added an answer on May 24, 2026 at 8:06 am
    <?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" version="1.0"  encoding="utf-8" indent="yes" />
    
    <xsl:key name="groupName" match="//results/resultset/result" use="concat(name, code)" />
    
    <xsl:template match="/">
    
      <results>
      <resultset>
      <xsl:for-each select="//results/resultset/result[generate-id() = generate-id( key('groupName', concat(name, code))   [1] ) ]" >
    
    
          <xsl:call-template name="group">
            <xsl:with-param name="k1" select="name" />
            <xsl:with-param name="k2" select="code" />
          </xsl:call-template>
    
      </xsl:for-each>
    
      </resultset>
      </results>
    </xsl:template> 
    
    <xsl:template name="group">
    <xsl:param name="k1" /> 
    <xsl:param name="k2" /> 
    
        <result>
          <xsl:copy-of select="name" />       
          <xsl:copy-of select="code" />       
    
          <xsl:for-each select="//results/resultset/result[name = $k1][code = $k2]">
    
            <xsl:copy-of select="model.model" />       
            <xsl:copy-of select="model.name" />       
    
          </xsl:for-each>
        </result>
    
    </xsl:template> 
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use the result of a javax.xml.transform.Transformer as an input to another
I need to transform one XML document into another using XSLT (for now from
I'm using XSLT to transform from one format of XML into another but I
I need to transform an xml-structure into a text string using xslt. I have
I need to transform an Oracle SQL statement into a Stored Procedure therefore users
I'm using javax.xml.transform.Transformer.transform() to convert one xml to another through an xsl stylesheet. I
Im working with PHP5, and I need to transform XML in the following form:
I'm using iTextSharp library, specifically to view .xml documents and transform them into .pdf
I need to transform inbound payload into map (java.util.Map). There are any way to
I need to serialize/de-serialize some objects into/from string and transfer them as just opaque

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.