error on line 39 at column 26: Namespace prefix xlink for href on script is not defined

匿名 (未验证) 提交于 2019-12-03 01:33:01

问题:

i am embedding a javascript file inside an svg file like this:

<svg     xmlns:dc="http://purl.org/dc/elements/1.1/"    xmlns:cc="http://creativecommons.org/ns#"    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:svg="http://www.w3.org/2000/svg"    xmlns="http://www.w3.org/2000/svg"    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"    version="1.0"    width="958.69"    height="592.78998"    id="svg2275"    sodipodi:version="0.32"    inkscape:version="0.46"    sodipodi:docname="Map of USA with state names.svg"    sodipodi:docbase="C:\temp\webdesign"    inkscape:output_extension="org.inkscape.output.svg.inkscape">    <metadata       id="metadata2625">      <rdf:RDF>        <cc:Work           rdf:about="">          <dc:format>image/svg+xml</dc:format>          <dc:type             rdf:resource="http://purl.org/dc/dcmitype/StillImage" />        </cc:Work>      </rdf:RDF>    </metadata>    <defs       id="defs2623">      <inkscape:perspective         sodipodi:type="inkscape:persp3d"        inkscape:vp_x="0 : 296.39499 : 1"        inkscape:vp_y="0 : 1000 : 0"        inkscape:vp_z="958.69 : 296.39499 : 1"        inkscape:persp3d-origin="479.345 : 197.59666 : 1"        id="perspective364" />    </defs>    <script type="text/ecmascript" xlink:href="script.js" /> ... ......... ..... ...... 

and i am getting the above error. anyone know what am idoing wrong?

回答1:

You never defined the xlink namespace (just like the error tells you)

You'll need to do something like what was done for the sodipodi namespace:

xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" 

According to the W3C, the appropriate namespace declaration is:

xmlns:xlink="http://www.w3.org/1999/xlink" 

Add that to your root element.



回答2:

You need to associate the xlink prefix with a namespace. Try adding the following to your svg element:

xmlns:xlink="http://www.w3.org/1999/xlink" 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!