Subject: Re: Re-arranging an XML file
From: Mike Stroud <stroudmw@xxxxxxxxx>
Date: Wed, 21 Jan 2009 09:05:18 +0200
|
Hi George,
Thanks very much for your help!
Regards,
Mike in SA
> Date: Tue, 20 Jan 2009 10:41:51 +0200
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> From: George Cristian Bina <george@xxxxxxxxxxxxx>
> Subject: Re: Re: Re-arranging an XML file
> Message-ID: <49758E4F.8040904@xxxxxxxxxxxxx>
>
> Hi Mike,
>
> I do not understand what is the part you have difficulties with. You can
> define a key to get the Author elements from their id and then just use
> that, see below:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output indent="yes" />
> <xsl:key name="artistById" match="Artist" use="Number"/>
> <xsl:template match="/">
> <xsl:apply-templates select="*/AddedAlbums"/>
> </xsl:template>
> <xsl:template match="AddedAlbums">
> <AddedAlbums><xsl:apply-templates/></AddedAlbums>
> </xsl:template>
> <xsl:template match="Album">
> <Album><xsl:apply-templates/></Album>
> </xsl:template>
> <xsl:template match="AlbumName">
> <AlbumName><xsl:value-of select="."/></AlbumName>
> </xsl:template>
> <xsl:template match="ArtistNumber">
> <Name><xsl:value-of select="key('artistById', .)/Name"/></Name>
> </xsl:template>
> <xsl:template match="*|text()"/>
> </xsl:stylesheet>
>
> Best Regards,
> George
> --
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
|