Html HTML5中“xmlns:v=urn:schemas-microsoft-com”是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27142065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:07:15  来源:igfitidea点击:

What is meaning of "xmlns:v=urn:schemas-microsoft-com" in HTML5

xmlhtml

提问by trytop

I happened to find the sentence "xmlns:v=urn:schemas-microsoft-com" as title described

我碰巧找到了标题描述的句子“xmlns:v=urn:schemas-microsoft-com”

Here is source roughly.

这里是大致的来源。

<!--[if gt IE 8]><!DOCTYPE html><!--<![endif]-->
<!DOCTYPE html><!--<![endif]-->
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><br>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge">
        <meta name="viewport" content="user-scalable=0,target-densitydpi=device-dpi">
        ...
    </head>
    <body>
        ...
    </body>
</html>

As I know xmlns is schema, so to speak metadata. If some element is available in body section, the metadata of this element exist in "schemas.microsft.com"

据我所知 xmlns 是模式,可以说是元数据。如果 body 部分中有某个元素可用,则该元素的元数据存在于“schemas.microsft.com”中

If I develop a html page using "microsoft" schema, all elements used in body section will be referernced by "microsoft" Or, If I use other schema, examply "google" (I don't know whether this really exist) all element goes same too.

如果我使用“microsoft”架构开发html页面,则正文部分中使用的所有元素都将由“microsoft”引用,或者,如果我使用其他架构,例如“google”(我不知道这是否真的存在)所有元素也一样。

Here is my question First, If I use table tag that exist in "microsoft" and "google" schema together Will chrome browser interpret context differently? so comes differnt view?

这是我的问题首先,如果我同时使用“microsoft”和“google”模式中存在的表标记,chrome 浏览器会以不同的方式解释上下文吗?所以有不同的看法?

Second, If xmlns is omitted what kind of schema will be used default?

其次,如果省略 xmlns 将默认使用什么样的模式?

回答by ThW

The xmlns:* attributes are namespace definitions. Elements and attributes with the prefix/alias "v" or "o" are part of the respective namespace and not part of HTML. If parsed as HTML < 5 the namespaces will be ignored. In HTML 5 here some constructs for specific namespaces (SVG, MathML), but namespace definitions (the xmlns:* attributes) are ignored.

xmlns:* 属性是命名空间定义。带有前缀/别名“v”或“o”的元素和属性是各自命名空间的一部分,而不是 HTML 的一部分。如果解析为 HTML < 5,命名空间将被忽略。在 HTML 5 中,这里有一些针对特定命名空间(SVG、MathML)的构造,但忽略了命名空间定义(xmlns:* 属性)。

If parsed as XML the attributes define the namespaces. You have to definitions:

如果解析为 XML,则属性定义命名空间。你必须定义:

  • Alias vfor urn:schemas-microsoft-com:vml- the Vector Markup Language
  • Alias ofor urn:schemas-microsoft-com:office:office- MS Office Open XML common attributes
  • 别名vurn:schemas-microsoft-com:vml-在矢量标记语言
  • 别名ourn:schemas-microsoft-com:office:office- MS的Office Open XML的公共属性

XML namespaces allow to mix different XML formats and avoiding conflicts because of element names.

XML 命名空间允许混合不同的 XML 格式并避免因元素名称而产生的冲突。

You file might be generated by MS Office (2003) or a user copied content from Office into it. If here are no elements/attributes starting with v:or o:in your document they don't do anything.

您的文件可能是由 MS Office (2003) 生成的,也可能是用户将 Office 中的内容复制到其中的。如果这里没有以您的文档开头v:o:在您的文档中的元素/属性,它们将不执行任何操作。

If the client knows a namespace/format it can interpret the elements. Not only a browser but RSS Readers, Calendars, ... If a client does not know a namespace but respects it, it at least knows to ignore the elements/attributes even if they have a name that might be valid in HTML.

如果客户端知道命名空间/格式,它可以解释元素。不仅是浏览器,还有 RSS 阅读器、日历……如果客户端不知道命名空间但尊重它,它至少知道忽略元素/属性,即使它们的名称可能在 HTML 中有效。

回答by Kornel

In HTML5 in text/htmlmode it has no meaning. It's an error that is interpreted as an attribute named xmlns:vwhich doesn't do anything.

在 HTML5text/html模式下,它没有意义。这是一个错误,它被解释为一个xmlns:v不做任何事情的命名属性。

In XHTML5 (HTML5 in application/xhtml+xml) it has same meaning as in XML: it declares that the prefix vis for namespace identified by urn:schemas-microsoft-com, but a mere declaration of a prefix doesn't do anything visible.

在 XHTML5(HTML5 in application/xhtml+xml)中,它与 XML 中的含义相同:它声明前缀v用于由 标识的命名空间urn:schemas-microsoft-com,但仅声明前缀不会做任何可见的事情。