Created
March 21, 2014 15:00
-
-
Save wader/9688134 to your computer and use it in GitHub Desktop.
Ugly REXML::UndefinedNamespaceException workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rexml/document" | |
| # in this case monkey patch to be able to read Inkscape "plain svg" files | |
| # make the namespace stack start out to have inkscape: and sodipodi: | |
| module REXML | |
| module Parsers | |
| class BaseParser | |
| alias_method :old_stream, :stream= | |
| def stream=(source) | |
| old_stream(source) | |
| @nsstack.unshift(Set.new(["inkscape", "sodipodi"])) | |
| end | |
| end | |
| end | |
| end | |
| REXML::Document.new(File.read(ARGV[0])).write |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment