Subject: Re: [xsl] Replacing many attributes From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Wed, 02 Apr 2003 20:23:37 +0200 |
I have about a hundred attributes to replace in docs and trying to find a...
more efficient way of doing this. I am currently doing this below but there must be a better way.
<xsl:template match="para/@meta[.='cc_gen_desc']"> <xsl:attribute name="meta">description</xsl:attribute> </xsl:template>
If this is an one-shot task I'd investigate a stream editor first. For an XML solution, you can define a file with replacements:
<replacements> <replace from="cc_gen_desc" to="description"/> ... </replacements>
Use it as follows: <xsl:variable name="replacements" select="document('replacements.xml')/replacements"/> <xsl:template match="para/@meta"> <xsl:variable name="replacement" select="$replacements/replace[@from=current()]"/> <xsl:choose> <xsl:when test="$replacement"> <xsl:attribute name="meta"> <xsl:value-of select="$replacement/@to"/> </xsl:attribute name="meta"> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Replacing many attributes, David Pratt | Thread | Re: [xsl] Replacing many attributes, David Pratt |
Re: [xsl] How do you set the action, David Carlisle | Date | [xsl] XSLT, XML & PHP, Anna Wagg |
Month |