Reputation: 47
I have a problem with call-template, I'm getting error:
Cannot find a template named getIndex
Syntax seems to be correct. I tried with apply-template
and all was fine. I don't have any idea why this error appeared.
Here is example XSLT file:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Studio 2019 (https://www.liquid-technologies.com) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Document">
<xsl:element name="Document">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="Produkt">
<xsl:element name="Produkt">
<xsl:element name="Index">
<xsl:call-template name="getIndex"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="getIndex">
<xsl:value-of select="Index"/>
</xsl:template>
</xsl:stylesheet>
Upvotes: 2
Views: 1174
Reputation: 111611
Change
<xsl:template match="getIndex">
to
<xsl:template name="getIndex">
^^^^
In general:
<xsl:template match="
pattern">
for xsl:apply-templates
.<xsl:template name="
name">
for xsl:call-template
.Upvotes: 6