Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Transform XML to XML only with fewer data [Thread Next] Re: Transform XML to XML only with fewer dataTo: NULL Date: 12/29/2008 1:53:00 PM Savvoulidis Iordanis wrote: > As a new one on XSLT, how can I write the XSLT file in order to create > another XML file out of the following one, containing only the 'Status', > 'League', 'Date', 'Time', 'HomeTeam', 'AwayTeam' for every Event? Also can I > change the names to 'Event_Status', 'Event_League',... and so on, in the new > file, while transforming? Here is a sample stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="Event"> <xsl:copy> <xsl:apply-templates select="@* | Status | League | Date | Time | HomeTeam | AwayTeam"/> </xsl:copy> </xsl:template> <xsl:template match="Event/*"> <xsl:element name="Event_{name()}"> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
