I've seen source code for embedded SVGs that look like:
我见过嵌入式SVG的源代码,如下所示:
<svg>...</svg>
and others that look like:
和其他看起来像:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">...</svg>
What exactly does specifying the xmlns / xmlns:xlink attributes do?
具体指定xmlns / xmlns:xlink属性是做什么的?
2 个解决方案
#1
9
In XML documents attributes and elements belong to namespaces. This is to prevent the elements from different technologies from *ing e.g. the SVG <a>
element and the HTML <a>
element can be distinguished if one is called svg:a and the other html:a
在XML文档中,属性和元素属于名称空间。这是为了防止来自不同技术的元素发生冲突,例如如果一个名为svg:a和另一个html,则可以区分SVG 元素和HTML 元素:a
xmlns:xlink says that elements prefixed by xlink should be interpreted using the xlink specification by UAs that understand that specification.
xmlns:xlink表示前缀为xlink的元素应该由理解该规范的UA使用xlink规范来解释。
xmlns defines the default namespace so no prefixes are necessary for that and you can just write <a>
rather than namespace:a and the UA knows it's an SVG <a>
element and not a HTML <a>
element or some <a>
element you made up yourself for your application.
xmlns定义了默认命名空间,因此不需要前缀,你可以只写而不是命名空间:a和UA知道它是SVG 元素而不是HTML 元素或某些元素你为自己的申请做了自己的贡献。
#2
1
The xmlns:XLink is used to create hyperlinks within XML documents
xmlns:XLink用于在XML文档中创建超链接
From wiki
来自维基
XML Linking Language, or XLink, is an XML markup language and W3C specification that provides methods for creating internal and external links within XML documents, and associating metadata with those links
XML链接语言(XLink)是一种XML标记语言和W3C规范,它提供了在XML文档中创建内部和外部链接以及将元数据与这些链接相关联的方法
#1
9
In XML documents attributes and elements belong to namespaces. This is to prevent the elements from different technologies from *ing e.g. the SVG <a>
element and the HTML <a>
element can be distinguished if one is called svg:a and the other html:a
在XML文档中,属性和元素属于名称空间。这是为了防止来自不同技术的元素发生冲突,例如如果一个名为svg:a和另一个html,则可以区分SVG 元素和HTML 元素:a
xmlns:xlink says that elements prefixed by xlink should be interpreted using the xlink specification by UAs that understand that specification.
xmlns:xlink表示前缀为xlink的元素应该由理解该规范的UA使用xlink规范来解释。
xmlns defines the default namespace so no prefixes are necessary for that and you can just write <a>
rather than namespace:a and the UA knows it's an SVG <a>
element and not a HTML <a>
element or some <a>
element you made up yourself for your application.
xmlns定义了默认命名空间,因此不需要前缀,你可以只写而不是命名空间:a和UA知道它是SVG 元素而不是HTML 元素或某些元素你为自己的申请做了自己的贡献。
#2
1
The xmlns:XLink is used to create hyperlinks within XML documents
xmlns:XLink用于在XML文档中创建超链接
From wiki
来自维基
XML Linking Language, or XLink, is an XML markup language and W3C specification that provides methods for creating internal and external links within XML documents, and associating metadata with those links
XML链接语言(XLink)是一种XML标记语言和W3C规范,它提供了在XML文档中创建内部和外部链接以及将元数据与这些链接相关联的方法