Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:\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?

like image 454
Alex Gordon Avatar asked Aug 24 '10 21:08

Alex Gordon


People also ask

What is Xlink href?

The xlink:href attribute defines a reference to a resource as a reference IRI. The exact meaning of that link depends on the context of each element using it. Note: SVG 2 removed the need for the xlink namespace, so instead of xlink:href you should use href .

What is xmlns xlink?

XLink is used to create hyperlinks in XML documents.


2 Answers

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.

like image 128
speshak Avatar answered Oct 13 '22 14:10

speshak


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"
like image 24
mwittrock Avatar answered Oct 13 '22 14:10

mwittrock