[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Re-arranging an XML file


Subject: Re: [xsl] Re-arranging an XML file
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 13 Jan 2009 14:45:21 +0100

Mike Stroud wrote:

Is there an easy way for an XSL rookie to transform it to look more like this?

Here is an XSLT 1.0 stylesheet:


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

<xsl:output method="xml" indent="yes"/>

  <xsl:template match="Catalog">
    <xsl:copy>
      <xsl:apply-templates select="cds/cd"/>
    </xsl:copy>
  </xsl:template>

<xsl:template match="cd">
<xsl:copy>
<xsl:copy-of select="title"/>
<artist>
<xsl:value-of select="../../artists/artist[number = current()/number]/name"/>
</artist>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>


--


	Martin Honnen
	http://JavaScript.FAQTs.com/


Current Thread
Keywords