Subject: Re: [xsl] Using a template to transform a node attribute From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 12 Sep 2005 16:32:44 +0100 |
> But the parser tells me that I have a syntax error when trying to > specify the attribute "id" properly. Any ideas? It shouldn't be the parser (It's not a syntax error) You should have (most likely) got a run time error saying that you could not generate an attribute node (it depends on the rest of your template that you didn't show). <xsl:template match="/report/version[@id]"> does not match id attributes it matches version elements that have an id. <xsl:attribute name="id">bar</xsl:attribute> then generates an id attribute but you may only do this if you have not already started to generate child elements or text of the parent element. Probably you want something like <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="version/@id"> <xsl:attribute name="id">bar</xsl:attribute> </xsl:template> David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Using a template to transform, Emerson, Matt | Thread | Re: [xsl] Using a template to trans, Will McCutchen |
[xsl] Using a template to transform, Emerson, Matt | Date | Re: [xsl] Using a template to trans, Will McCutchen |
Month |