Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transforming xml file into another xml with xsl file

Status
Not open for further replies.

pit977

Technical User
Feb 28, 2011
6
hi,

I would like to create xsl file to transform xml file #1 to another xml file #2 with different structure:

xml file #1:

<?xml version="1.0" encoding="utf-8" ?>
<orders>
<doctorname>Andrew Dixon</doctorname>
<orderid>10/10/03</orderid>
<compound>
<name>Riboflavorific</name>
<amount>27</amount>
</compound>
<compound>
<name>Reduxicon</name>
<amount>90</amount>
</compound>
<compound>
<name>Photicuderm</name>
<amount>70</amount>
</compound>
</orders>



xml file #2:

<?xml version="1.0" encoding="utf-8" ?>
<orders>
<compound>
<doctorname>Andrew Dixon</doctorname>
<orderid>10/10/03</orderid>
<name>Riboflavorific</name>
<amount>27</amount>
</compound>
<compound>
<doctorname>Andrew Dixon</doctorname>
<orderid>10/10/03</orderid>
<name>Reduxicon</name>
<amount>90</amount>
</compound>
<compound>
<doctorname>Andrew Dixon</doctorname>
<orderid>10/10/03</orderid>
<name>Photicuderm</name>
<amount>70</amount>
</compound>
</orders>

could You help me, please
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:eek:utput indent="yes" method="xml"/>
<xsl:template match="/">
<xsl:apply-templates select="orders"/>
</xsl:template>
<xsl:template match="orders">
<orders>
<xsl:apply-templates select="compound"/>
</orders>
</xsl:template>
<xsl:template match="compound">
<compound>
<xsl:copy-of select="../doctorname"/>
<xsl:copy-of select="../orderid"/>
<xsl:copy-of select="name"/>
<xsl:copy-of select="amount"/>
</compound>
</xsl:template>
</xsl:stylesheet>
 
thank You for solution!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top