Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse when entity is used for namespace declaration #225

Closed
chulkilee opened this issue Jul 9, 2014 · 2 comments
Closed

Cannot parse when entity is used for namespace declaration #225

chulkilee opened this issue Jul 9, 2014 · 2 comments

Comments

@chulkilee
Copy link

Problem

SVG file generated by Adobe Illustrator uses references to XML entities when declaring name spaces. See the following excerpt:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.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/">
]>
<svg 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" version="1.1" x="0px" y="0px" width="583.029px" height="45px" viewBox="0 0 583.029 45" enable-background="new 0 0 583.029 45" xml:space="preserve">

This is due to the limitation of https://github.com/isaacs/sax-js (not a bug).

Solutions

  • Turn off strict mode in svgo: it works for above cases, but it may allow other cases passed without any error
  • Make sax-js to support DTD
  • Use other parser library

Resource

See related inkscape bugs: 1093433 and 166371

@SebCorbin
Copy link

Just encountered this, how would you turn off strict mode?

@chulkilee
Copy link
Author

Change this line https://github.com/svg/svgo/blob/v0.4.4/lib/svgo/svg2js.js#L7

var config = {
    strict: true,
    trim: true,
    normalize: true,
    lowercase: true,
    xmlns: true,
    position: false
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants