This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Search and Replace in XSLT


I'm not sure that you want a search and replace function (though the
translate() function would do this).

From the input:

<img src="x.bmp" alt="[tag]"/>

you want the output:

<img src="x.bmp"><tag/></img>

This could be done in the following way:

<xsl:template match="img">
<img src="{@src}">
	<xsl:element name="{translate(@alt,'[]', '')}" />
</img>
</xsl:template>

(though it would eliminate the need for the translate function if the [ and
the ] were not in the source)

Hope this helps,

Ben


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]