Hello forum,
- I have built a PIM XML feed and are trying to remove all HTML formatting from the Description field, but when saving the XSLT I'm getting an error:
The error is related to the line: <xsl:when test="contains($string, '<')">
If I use a XSLT validation and transformation tool everything works as expected. How to have this working in DW?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="LongDescription">
<xsl:copy>
<xsl:call-template name="remove-markup">
<xsl:with-param name="string" select="."/>
</xsl:call-template>
</xsl:copy>
</xsl:template>
<xsl:template name="remove-markup">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string, '<')">
<xsl:value-of select="substring-before($string, '<')" />
<!-- recursive call -->
<xsl:call-template name="remove-markup">
<xsl:with-param name="string" select="substring-after($string, '>')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Br. Michael Knudsen