我有以下 xml 片段。
Case1:
<para>
<content-style font-style="bold">Affidavit</content-style>
</para>
Case2:
<para>This is a different <content-style font-style="bold">Affidavit</content-style> case
</para>
我希望控件在仅存在节点(情况 1)时调用部分模板,但如果其中也有文本(情况 2)则不调用部分模板。我尝试了下面的 xslt 但它不起作用。请让我知道该怎么做。
<xsl:template match="para">
<xsl:choose>
<xsl:when test="child::content-style/node[1]">
<xsl:call-template name="section"/>
</when></xsl:choose>
</xsl:template>
Thanks
从你的例子来看,我认为你应该调用一个带有内容样式但没有文本的 para 模板部分。
最好的方法是像下面这样:
<xsl:template match="para" />
<xsl:template match="para[content-style][not ( text() )]">
<xsl:call-template name="section"/>
</xsl:template>
使用 xsl: 时应该这样做:
<xsl:template match="para" >
<xsl:choose>
<xsl:when test="content-style and not(text())">
<xsl:call-template name="section"/>
</xsl:when>
</xsl:choose>
</xsl:template>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)