downloaded a trial copy of xmlspy2005 yesterday.
XMLSpy 2005 seems to be inconsistent with XMLSpy 2004... I've a working copy for Saxon 8, but it seems to be incompatible with XMLSpy 2005.
working on it now,..
--
Saxon 8 compatible version:
Changes:Only replaces text nodes.
filter variable changed back, because of difference in interpretation of xslt spec.
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2004/07/xpath-functions" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="filters">
<filters>
<filter text="target" replace="objective"/>
<filter text="anywhere" replace="somewhere"/>
<filter text="hi" replace="hello"/>
<filter text="secret" replace=" "/>
</filters>
</xsl:variable>
<xsl:template name="filter">
<xsl:param name="str"/>
<xsl:variable name="match" select="$filters/filters/filter[contains($str, @text)][1]"/>
<xsl:choose>
<xsl:when test="$match">
<xsl:variable name="word" select="$match/@text"/>
<xsl:variable name="repl" select="$match/@replace"/>
<xsl:call-template name="filter">
<xsl:with-param name="str">
<xsl:value-of select="substring-before($str,$word)"/>
<xsl:value-of select="$repl"/>
<xsl:value-of select="substring-after($str,$word)"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$str"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()">
<xsl:call-template name="filter">
<xsl:with-param name="str" select="self::text()"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
MSXML version:
change the match variable to:
<xsl:variable name="match" select="msxml:node-set($filters)/filters/filter[contains($str, @text)]"/>
add the xmlns namespace to the stylesheet:
xmlns:msxml="urn:schemas-microsoft-com:xslt"
and change the version back to 1.0
I tend to think there's a bug in Altova's XPath 2.0 processor.