Subject: Re: Changing the Attibute Value
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 21 Jul 2008 10:47:12 +0100
|
2008/7/21 Buddhi D. Mahindarathne <buddhi@xxxxxxxxxxxxxxxxxxx>:
> This way I tried .. But no luck
> <xsl:template match="VisualObject[@xsi:type='CChamferEx']">
> <xsl:template match="Name[. = 'ChamferedRectangle']">
> <xsl:copy>Fillet</xsl:copy>
> </xsl:template>
> </xsl:template>
I can see what you're thinking, but you can't do that. I know others
are trying not to just give you the code, but as far as I'm concerned
using xsl:apply-templates within xsl:copy is one of the hardest things
to grasp in XSLT - I remember it taking me ages to get it. It's
probably best to start with a working example, and go from there.
The stylesheet below does most of what you asked, you just need to add
an extra template to handle the address element:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="VisualObject[@xsi:type='CChamferEx']">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="xsi:type">CFilletEx</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Name[. = 'ChamferedRectangle1']">
<xsl:copy>Fillet1</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
|