SVG Xlink赢得';t使用xlink:href在<;中链接到外部文件;使用>;标签

SVG Xlink赢得';t使用xlink:href在<;中链接到外部文件;使用>;标签,svg,href,xlink,Svg,Href,Xlink,我有两个SVG文件。我正在尝试将rect.svg的内容xlink到tst_use.svg中。tst_use.svg的内容包括: <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.1" id=

我有两个SVG文件。我正在尝试将rect.svg的内容xlink到tst_use.svg中。tst_use.svg的内容包括:

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.1" id="svg_hom_img" width="508" height="438">
<use x="0" y="0" id="us_g1_0" width="508" height="438" xlink:href="rect.svg"/>
</svg>

而rect.svg的内容是

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.1" id="svg_hom_img" width="508" height="438">
<rect x="0" y="1" width="250" height="250" id="BackDrop" pointer-events="all" style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:2;     stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0"/>
</svg>


当然,这两个文件在同一个目录中。我试过几种组合。代码可以内联工作。rect.svg将显示在浏览器中。我还可以用javascript将文件拼凑在一起。其他人使用这种语法。为什么tst_不能将.svg xlink改为rect.svg?

根据Robert Longson的评论,我将test_use.svg改为

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0" id="svg_hom_img" width="508" height="438">
  <use x="0" y="0" id="us_g1_0" width="508" height="438" xlink:href="rect.svg#BackDrop"/>
</svg>

使用与问题中相同的rect.svg。在Firefox中显示矩形,但在Chrome中不显示。javascript似乎是最好的解决方案。

在SVG 1.1中无法指向完整的文件,它必须指向该文件中的某些内容。如果需要完整的文件,请使用标记。