Xslt 检查是否有节点但没有文本
我有以下几段xml 案例1:Xslt 检查是否有节点但没有文本,xslt,Xslt,我有以下几段xml 案例1: <para> <content-style font-style="bold">Affidavit</content-style> </para> 宣誓书 案例2: <para>This is a different <content-style font-style="bold">Affidavit</content-style> case
<para>
<content-style font-style="bold">Affidavit</content-style>
</para>
宣誓书
案例2:
<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>
感谢您的示例,我认为您应该为段落调用一个模板部分,内容样式为,但没有文本。 最好的方法如下所示:
<xsl:template match="para" />
<xsl:template match="para[content-style][not ( text() )]">
<xsl:call-template name="section"/>
</xsl:template>
使用xsl:when应该这样做:
<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>
Hi@hr\u 117谢谢您的快速回复,您能告诉我如何将其添加到when条件中吗,因为模板para有很多验证,其中就有一个。您能看一下吗