I have the following code. I am trying to use a simple IF within a FOR-EACH. I simplified it for this example here. When I add the follwowing IF (which in this example should always be true), my code bombs out. If I remove the IF test altogether, code runs fine.
<xsl:if test="contains('apple','ap')">
Here is the full code:
<xsl:for-each select="$external-doc/document(.)/items/item">
<xsl:if test="contains('apple','ap')">
<xsl:sort select="concat(substring(pubDate,7,4), substring(pubDate,1,2),substring(pubDate,4,2))" order="descending"/>
<item>
<xsl:attribute name="href" select="concat($base-url,@href)"/>
<xsl:apply-templates select="attribute()[not(name() = 'href')]|node()[not(name() = 'hero-image') and not(name() = 'image')]" />
<xsl:if test="image">
<image>
<xsl:choose>
<xsl:when test="not(contains(image/img/@src,'://'))">
<img>
<xsl:attribute name="src" select="concat($base-url,image/img/@src)"/>
<xsl:apply-templates select="image/img/attribute()[not(name() = 'src')]" />
</img>
</xsl:when>
<xsl:otherwise><xsl:apply-templates select="image/img" /></xsl:otherwise>
</xsl:choose>
</image>
</xsl:if>
<searchtags>{string-join(tags/tag, ',')}</searchtags>
</item>
</xsl:if>
</xsl:for-each>
What am I doing wrong with the test?
I presume your error message says something like:
which is self-explanatory.