|
next
|
 Subject: RE: Using the translate() function Author: (Deleted User) Date: 30 Nov 2005 07:29 PM
|
Dominic,
Are you asking how to structure the .xslt file overall?
It is kind of complicated if you want to preserve all namespace information, processing instructions, comments, etc, but you just asked to be pointed in the right direction, so try this.
This stylesheet copies almost everything except namespaces on attributes.
Is this what you were looking for?
Clyde
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Start the whole thing going -->
<xsl:template match="/">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<!-- Translate each attribute value by creating a new attribute -->
<xsl:template match="@*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="translate(., 'i', 'o')"/>
</xsl:attribute>
</xsl:template>
<!-- Translate each text node -->
<xsl:template match="text()">
<xsl:value-of select="translate(., 'i', 'o')"/>
</xsl:template>
<!-- copy everything else unchanged, and recurse -->
<xsl:template match="*|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
|
|
|
|