Xslt XSL:剥离HTML并截断
我想运行这个Xslt XSL:剥离HTML并截断,xslt,Xslt,我想运行这个 <!-- This will remove the tag --> <xsl:template name="remove-html"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text, '<')"> <xsl:value-of select="normaliz
<!-- This will remove the tag -->
<xsl:template name="remove-html">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text, '<')">
<xsl:value-of select="normalize-space(substring-before($text, '<'))"/>
<xsl:text> </xsl:text>
<xsl:call-template name="remove-html">
<xsl:with-param name="text" select="normalize-space(substring-after($text, '>'))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space($text)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
还有这个
<xsl:choose>
<xsl:when test="string-length(header) > 22">
<xsl:value-of select="substring(header, 0, 22)" />
<xsl:text>…</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="header" />
</xsl:otherwise>
</xsl:choose>
…
一起。。我该怎么做呢?将第二个选项包装在命名模板中,然后用调用模板替换第一个选项中的值。
<xsl:variable name="stripped">
<xsl:call-template name="remove-html">
<xsl:with-param name="text" select="???"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($stripped) > 22">
<xsl:value-of select="substring($stripped, 0, 22)" />
<xsl:text>…</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stripped" />
</xsl:otherwise>
</xsl:choose>
…
将
???
替换为相应的节点您的意思是要将代码的顶部位与主体
元素匹配,将底部位与头部
元素匹配吗?否,我想运行一个文本处理程序,让它删除HTML并截断结果。我不评论您的方法是否正确,但通过捕获变量中第一个操作的输出并将第二个操作应用于此变量,可以自然地实现两个操作的合成。