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

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:tempwebdesign"
   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?


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.


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"
链接地址: http://www.djcxy.com/p/77322.html

上一篇: 如何将PNG图像转换为SVG?

下一篇: 第26列第39行的错误:未定义脚本的名称空间前缀xlink for href