XSLT - 如何匹配任何非文本节点子节点?

发布于 2024-07-21 08:07:55 字数 258 浏览 2 评论 0原文

我是 XSLT 新手,我不知道如何获取 xsl:if 在没有子标签时匹配。

我希望这个匹配:

<context>
    howdy
</context>

而这个不匹配:

<context>
    <child>
        howdy
    </child>
</context>

I'm new to XSLT and I can't figure out how to get an xsl:if that matches when there are no child tags.

I want this to match:

<context>
    howdy
</context>

And this not:

<context>
    <child>
        howdy
    </child>
</context>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半岛未凉 2024-07-28 08:07:55

相关的 xpath 表达式应如下所示:

//context[not(./*)]

the relevant xpath expression should look like:

//context[not(./*)]
岁月如刀 2024-07-28 08:07:55

您还可以指定 count(child::*) = 0 。

You could also specify count(child::*) = 0 .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文