vault-development / react-native-svg-uri

Render SVG images in React Native from an URL or static file
849 stars 334 forks source link

XMLDOM Error - entity not found #99

Closed Slessi closed 1 week ago

Slessi commented 6 years ago

Getting the below when trying to render an SVG

[xmldom error]  entity not found:&ns_ai;
[xmldom error]  entity not found:&ns_graphs;
[xmldom error]  entity not found:&ns_extend;

All the above are mentioned at the top of the relevant SVG, shown here:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
    <!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">
    <!ENTITY ns_ai "http://ns.adobe.com/AdobeIllustrator/10.0/">
    <!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/">
    <!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/">
    <!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">
    <!ENTITY ns_sfw "http://ns.adobe.com/SaveForWeb/1.0/">
    <!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/">
    <!ENTITY ns_adobe_xpath "http://ns.adobe.com/XPath/1.0/">
]>
<svg version="1.1" id="Layer_1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="230px" height="200px"
     viewBox="0 0 230 200" enable-background="new 0 0 230 200" xml:space="preserve">
<switch>
    <foreignObject requiredExtensions="&ns_ai;" x="0" y="0" width="1" height="1">
        <i:pgfRef  xlink:href="#adobe_illustrator_pgf">
        </i:pgfRef>
    </foreignObject>
    <foreignObject requiredExtensions="&ns_ai;" x="0" y="0" width="1" height="1">
        <i:pgfRef  xlink:href="#adobe_illustrator_pgf">
        </i:pgfRef>
    </foreignObject>
...
amandamussio commented 6 years ago

Same error! :(

damithg-dev commented 5 years ago

it's SVG error when you saveing follow the below instructions(on illustrate),

Save As, SVG, SVG 1.1, and then uncheck "Include Slicing Data".

image

xZGit commented 4 years ago

you can try this

const XMLReader  = require('xmldome/sax').XMLReader
const oldParse = XMLReader.prototype.parse
const myEntityMap = {
    'times': '*'
};
XMLReader.prototype.parse =  function(source,defaultNSMap,entityMap){
   return oldParse.call(this, source, defaultNSMap, Object.assign(entityMap, myEntityMap));
};