954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

XML to XML transform using XSLT

Hi,
I am new to XSLT, Please helo me in transforming the XML to XML transform
I have XML like this

Through XSLT I need to convert it like this

Please help me out. This is very urgent requirement.

Regards,
Hanuman

hanuinfy
Newbie Poster
2 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

This is really, really simple. You should be able to do this very easily if you're in a class or something. If not you need to visit http://www.w3schools.com/xsl/ and start doing the tutorial. This should take you maybe a couple hours tops if you have any development experience.

Once you actually ATTEMPT a solution, I'll be willing to help you fix it. Post your attempt (please use codeboxes, for your xml documents) and I'll happy to help.

iceandrews
Junior Poster
185 posts since May 2010
Reputation Points: 10
Solved Threads: 30
 

Hi andrwes,
Thanks a lot for replying.
Sure that iwill learn. But their is a urgent requirement to fit this code in to a project. Can u please help me in this.

Regards,
Hanuman

hanuinfy
Newbie Poster
2 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 
Parthmishr
Newbie Poster
7 posts since Sep 2010
Reputation Points: 10
Solved Threads: 1
 

This works for XSLT1

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

   <xsl:template match="product">
   <product>
       <xsl:attribute name="display">
           <xsl:value-of select="display/@value"/>
       </xsl:attribute>
       <xsl:attribute name="count">
          <xsl:value-of select="count/@value"/>
       </xsl:attribute>
   </product>
   </xsl:template>

</xsl:stylesheet>
fpmurphy
Junior Poster
147 posts since Oct 2008
Reputation Points: 22
Solved Threads: 11
 

Note the use of a select attribute with the instruction. This attribute is only available in XSLT2

fpmurphy
Junior Poster
147 posts since Oct 2008
Reputation Points: 22
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: