Xml 在XSL中检查节点是否存在及其是否为空

Xml 在XSL中检查节点是否存在及其是否为空,xml,xslt,Xml,Xslt,我有一个XSL文件,我需要在其中检查XML节点bean:usz-approve是否存在,以及它是否为空。 我尝试了许多变体,但没有人适合我 XML: 我试着做一些类似的事情: <xsl:template match="bean:usz-consent"> <xsl:if test="bean:usz-consent/text() = ''"> <summary:show-popup>true</summary:show-popup>

我有一个XSL文件,我需要在其中检查XML节点bean:usz-approve是否存在,以及它是否为空。 我尝试了许多变体,但没有人适合我

XML:


我试着做一些类似的事情:

<xsl:template match="bean:usz-consent">
  <xsl:if test="bean:usz-consent/text() = ''">
    <summary:show-popup>true</summary:show-popup>
  </xsl:if>
</xsl:template>

真的


真的
如果您使用

<xsl:template match="bean:usz-consent[not(node())]">
    <summary:show-popup>true</summary:show-popup>
</xsl:template>

真的

然后模板只匹配根本没有子节点(没有子元素、文本、注释或处理说明)的
bean:usz-approve

请将XML作为代码添加到问题中。也可以发布您的最佳尝试,这样我们就可以修复它,而不是从头开始为您编写代码。还考虑更详细地解释您认为“空”的内容,即没有子元素,没有子节点,只有空白空间内容。“空”意味着没有子节点,没有子节点,只有bean:usz同意,在我的XML和xsl中没有任何内容,而不是
尝试
。也许有更好的方法,但你没有表现出一种积极的态度。但很明显,你的测试是在错误的背景下进行的。
<xsl:template match="bean:usz-consent">
  <xsl:if test="string(//bean:usz-consent) = ''">
    <summary:show-popup>true</summary:show-popup>
  </xsl:if>
</xsl:template>
<xsl:template match="bean:usz-consent[not(node())]">
    <summary:show-popup>true</summary:show-popup>
</xsl:template>