我一直在尝试让 XPointer URI 在 SVG 文件中工作,但到目前为止还没有成功。在尝试了一些更复杂但失败的事情之后,我将其简化为只引用一个 ID。然而,这仍然失败。
规范似乎很清楚这个实现:
http://www.w3.org/TR/SVG/struct.html#URIReference
我在网上找到了一个示例,说明在 svg 文档中应该是有效的 XPointer 引用。这是 Original .这是我复制出来的版本:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="500" height="200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <rect id="simpleRect" width="100px" height="75px"/> </defs> <use xlink:href="#simpleRect" x="50" y="50" style="fill:red"/> <use xlink:href="#xpointer(id('simpleRect'))" x="250" y="50" style="fill:yellow"/> </svg>
这应该显示两个矩形...一个红色和一个黄色。我尝试使用 Firefox 3.6 和 Inkscape 0.47 进行渲染。没有成功。仅显示红色矩形。
我错过了什么?
感谢您提供的任何帮助
最佳答案
目前(截至 2016 年 3 月 10 日,SVG 1.1 第二版)不支持在浏览器中渲染 XPointers。 W3Schools writes about this as follows :
XPointer Browser Support
There is no browser support for XPointer. But XPointer is used in other XML languages.
这有点令人沮丧,因为所有官方文档都懒得区分 SVG 的浏览器支持(Internet 就绪)功能和 SVG 的技术支持的纯 XML 类功能。
关于svg - SVG 中的 XPointer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2485999/