xsl-list
[Top] [All Lists]

Re: [xsl] Replace an attribute

2008-01-04 10:14:33
Thanks Andrew,
your templates worked exactly as I wanted them to.
Now I need to spend time understanding how they work.

Are the expressions in the match="" statements XPath expressions?

Thanks again.

-- 
Sean Tiley
sean(_dot_)tiley(_at_)gmail(_dot_)com




When you basically want to make a copy of the input XML but with
certain changes then you want to use the "indentity" transform, with
specific templates to make the change.

You're right to use the replace() function, but remember to get the
regex right.

<xsl:stylesheet
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0"
    exclude-result-prefixes="xs">

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="@name">
<xsl:attribute name="name">
<xsl:value-of select="replace(., 'C:\\blah\\blah', 'files')"/>
</xsl:attribute>
</xsl:template>

</xsl:stylesheet>


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>