why function is not called in xslt?

血红的双手。 提交于 2019-12-11 04:28:51

问题


I am trying to call function .But it not display out .here is my code https://plnkr.co/edit/TN1BN5Yao5Z63RDcBGlN?p=preview

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:template name="dosomething">
        <xsl:text>A function that does something</xsl:text>
    </xsl:template>

    <xsl:call-template name="dosomething"/>

</xsl:stylesheet>

回答1:


xsl:call-template cannot be at the top level of your stylesheet. It must only be used within a template body, for example:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:template name="dosomething">
        <xsl:text>A function that does something</xsl:text>
    </xsl:template>

   <xsl:template match="/">
        <xsl:call-template name="dosomething"/>
    </xsl:template>


</xsl:stylesheet>


来源:https://stackoverflow.com/questions/41033174/why-function-is-not-called-in-xslt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!