为什么SVG中的同一文档引用受HTML <base>标记的影响?

6 svg uri fragment-identifier

我有一个带有<base>标签的HTML页面,也包含SVG.然后SVG中的相同文档引用如下所示:

<html>
  <head>
    <base href="http://my/server/basedir">
  </head>
  <body>
    <svg>
      <g>
        <path d="M100,100 L150,150" id="path"/>
        <text>
          <textpath xlink:href="#path"/>
        </text>
      </g>
    </svg>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

xlink:href="#path"参考文献没有解决.没有HTML base元素,这可以正常工作.如果我用一个绝对IRI后跟片段标识符替换元素href上的属性,它也可以工作textpath.

在我看来,SVG应该以不同的方式处理同一文档的IRI并且独立于HTML base.在http://www.w3.org/TR/xmlbase/#same-document中,它说"取消引用同一文档引用是专门处理的.",虽然在上下文中被授予xml:base.顺便说一句,我打了一个推杆xml:base上的svg元素重写HTML的希望base为无法弄清楚如何使这项工作环境.

cui*_*ing 0

情况1:无xml:base

适用于 IE(Edge)、Chrome,但不适用于 Firefox。

<html>
  <head>
    <base href="http://my/server/basedir">
  </head>
  <body>
    <svg width="300" height="300" xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
      <g>
        <path d="M100,100 L150,150" id="path"/>
        <text>
          <textpath xlink:href="#path">Hello</textpath>
        </text>
      </g>
    </svg>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

情况2:与xml:base

适用于 IE(Edge)、Chrome、Firefox。

如果此页面 urlhttp://my/thisfile.htm然后设置xml:base="http://my/thisfile.htm"在 svg 标签或 textpath 标签上。

<html>
  <head>
    <base href="http://my/server/basedir">
  </head>
  <body>
    <svg width="300" height="300" xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xml:base="http://my/thisfile.htm">
      <g>
        <path d="M100,100 L150,150" id="path"/>
        <text>
          <textpath xlink:href="#path">Hello</textpath>
        </text>
      </g>
    </svg>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)