XHTML 1.1 和 xml:script 标签的 space 属性

发布于 2024-08-16 10:32:57 字数 312 浏览 1 评论 0原文

在 XHTML 1.0 中,在标记中使用 xml:space 属性是有效的,但在 XHTML 1.1 中它是无效的(使用相同的标记)。

我在文档中找不到它......有人可以确认吗?为什么它被删除了?是不是被别的东西代替了?

验证样本:

<script type="text/javascript" xml:space="preserve">
    // <![CDATA[
    alert('foo');
    alert('bar');
    // ]]>
</script>

In XHTML 1.0, using the xml:space attribute in a tag is valid, but in XHTML 1.1 it is not valid (using the same markup).

I can't find it in the docs...can anyone confirm it? Why has it been removed? Has it been replaced by something else?

Sample to validate:

<script type="text/javascript" xml:space="preserve">
    // <![CDATA[
    alert('foo');
    alert('bar');
    // ]]>
</script>

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

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

发布评论

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

评论(1

好听的两个字的网名 2024-08-23 10:32:57

在 XHTML 1.1 中,xml:space 在所有元素上都有一个固定值 preserve,包括

<!ATTLIST %script.qname;
    xml:space    ( preserve )             #FIXED 'preserve'

因此,我不认为在

然而,出于同样的原因,包含该属性也不会获得任何好处。我不确定您希望通过它实现什么...所有 Web 浏览器和通用 XML 工具的“默认空白处理模式”将在

In XHTML 1.1 xml:space has a fixed value of preserve on all elements, including <script>, according to http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-script-1.mod:

<!ATTLIST %script.qname;
    xml:space    ( preserve )             #FIXED 'preserve'

as such I don't believe it should be an error to declare xml:space="preserve" on the <script> element, and I don't know why the validator is tripping on it.

However, by the same token, there is nothing whatsoever to be gained by including the attribute. I'm not sure what you're hoping to achieve by it... the ‘default white-space processing mode’ of all web browsers and general XML tools will preserve whitespace in <script> in any case.

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