gpt4 book ai didi

html - 使用 xsl :if doesn't include closing tag

转载 作者:行者123 更新时间:2023-11-28 05:07:46 26 4
gpt4 key购买 nike

尝试使用以下代码在博客滚动中插入谷歌广告

<xsl:if test="position() = 3">
<object data="/frontpage_blogroll_center_top_728x90"
width="735"
height="95" ></object>
</xsl:if>

出于某种原因,结束标记 </object>不会在 HTML 中呈现并导致错误。有办法解决这个问题吗?

最佳答案

在 XML 之间没有区别(词汇除外):

<object></object>

<object/>

它们表示完全相同的 XML 元素,不同的 XSLT 处理器可以自由选择上述两种表示形式中的任何一种。

如果在 HTML 中确实需要元素的长形式,这可以通过以下任一方式实现:

  • 使用 <xsl:output method="xhtml"/> . xhtml方法仅在 XSLT 2.0 中可用。

  • 使用 <xsl:output method="html"/> . XSLT 转换的结果将是一个 HTML 文档(而不是 XML)。

  • 使用技巧,例如:

    <object data="/frontpage_blogroll_center_top_728x90" width="735" height="95"  >
    <xsl:value-of select="$vsomeVar"/>
    </object>

哪里$vsomeVar没有值,也不会导致输出任何内容,但会诱使 XSLT 处理器认为某些内容输出,从而输出元素的长格式。

关于html - 使用 xsl :if doesn't include closing tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4964016/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com