Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 检查是否有节点但没有文本_Xslt - Fatal编程技术网

Xslt 检查是否有节点但没有文本

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

我有以下几段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>
这是一个不同的宣誓案件
在这里,我想让控件在只有节点存在时调用节模板(情况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有很多验证,其中就有一个。您能看一下吗