say this is my xml
<?xml version="1.0" encoding="UTF-8"?>
<node>
<file name="abc.txt.bak">
<fileid value="112358"/>
</file>
<location value="Baker Street"/>
</node>
I want to use xsl to transform this xml, by removing the .bak of file name. The expected result is like this:
<?xml version="1.0" encoding="UTF-8"?>
<node>
<file name="abc.txt">
<fileid value="112358"/>
</file>
<location value="Baker Street"/>
</node>
my xsl file is like this, which does not work. It just copies everything without changing the value.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node/file/@name" >
<xsl:copy>
<xsl:attribute name="name">
<xsl:value-of select="substring-before(., '.bak')" />
</xsl:attribute>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>