xsl 检查变量似乎不起作用

发布于 2024-08-14 18:37:06 字数 443 浏览 3 评论 0原文

例如,当我直接输出节点的值时:

 <fo:inline><xsl:value-of select="isEnabled" /></fo:inline>

我得到了在 pdf“true”中输出的正确字符串..

但是如果我将 isEnabled 的值直接设置为变量,然后尝试对其进行比较..它不会似乎无法正常工作,就好像该节点不存在一样。

<xsl:variable name="isEnabled" select="isEnabled" />

<xsl:choose>
<xsl:when test="$isEnabled = 'true'">
   dostuff...

似乎这里从未正确接收到该值,并且测试总是失败

有什么想法吗?

when I output the value of the node directly for example:

 <fo:inline><xsl:value-of select="isEnabled" /></fo:inline>

I get the correct string outputted in pdf "true"..

but if I set the value of isEnabled directly to a variable and then try to do the comparison on it.. it doesn't seem to work as if the node doesn't exist.

<xsl:variable name="isEnabled" select="isEnabled" />

<xsl:choose>
<xsl:when test="$isEnabled = 'true'">
   dostuff...

It seems that the value is never received correctly here and the test always fails

Any ideas?

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

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

发布评论

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

评论(3

七婞 2024-08-21 18:37:06

isEnabled 是否包含空格?

<isEnabled>true</isEnabled>

vs.

<isEnabled>true </isEnabled>

<isEnabled>
true
</isEnabled>

将为您的测试提供不同的结果。第一个应该通过,接下来的两个可能不会。然而,当使用 value-of 时,它们可能都呈现为文本“true”。

Does isEnabled contain whitespace?

<isEnabled>true</isEnabled>

vs.

<isEnabled>true </isEnabled>

or

<isEnabled>
true
</isEnabled>

will give different results for your test. The first one should pass, the next two likely will not. Yet, they may all appear to render as the text "true" when using value-of.

十雾 2024-08-21 18:37:06

怎么样?

<xsl:variable name="isEnabled">
    <xsl:value-of select="isEnabled" />
</xsl:variable>

<xsl:when test="normalize-space($isEnabled)='true'">

How about?

<xsl:variable name="isEnabled">
    <xsl:value-of select="isEnabled" />
</xsl:variable>

<xsl:when test="normalize-space($isEnabled)='true'">
源来凯始玺欢你 2024-08-21 18:37:06

好吧,事实证明这不是一个 xsl 问题,但问题出现得更早。在为转换生成 xml 的速度模板中。我怎样才能结束这个问题?

ok turned out it wasn't an xsl issue but the problem is much earlier.. at the velocity template that generates the xml for the transformation. How can I close this question?

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