Tagged: axidraw openframeworks SVG
January 29, 2022 at 11:24 pm #29740
This link explains how layers need to be named to achieve different drawing behaviours.
Under “Adding layers outside of Inkscape” it also says that each <g> group needs to have “inkscape:groupmode=”layer” and “inkscape:label=”1-myName”.
I am making an openframeworks app that generates a custom svg using svgtiny. But due to the colon in “inkscape:groupmode” the app crashes.
“libc++abi.dylib: terminating with uncaught exception of type Poco::XML::SAXParseException: SAXParseException”
The app generates a proper SVG successfully when I replace the colon with a dash like so “inkscape-groupmode”. Not sure yet if the axidraw will like it.
My question is if I can remove the “inkscape:” part and only leave “groupmode” and “label” attribute?
Or is there any other work around you might know to prepare the svg correctly, so that axidraw will parse the layers correctly?
It seems SVGs don’t like colons that much: https://stackoverflow.com/questions/69804075/why-do-colons-in-lineargradient-ids-break-them-when-the-svg-is-used-in-an-img
thanks.January 29, 2022 at 11:38 pm #29744
Both the crash ( SAXParseException ) and the stackoverflow link should be pointing you in the correct direction: You shouldn’t use a “bare” colon if you’re using any frameworks that recognize the SVG tree, since they will conflict with any declared namespaces.
What to do about it depends a lot on what you are actually doing, and at what stage it’s crashing.
If you’re seeing a crash while building the file, then you’re probably using some sort of framework that parses or otherwise understands an SVG (XML) tree. In that case, you need to either register the namespace and build the namespaced object correctly, or (with a very different approach) build the SVG by simple string concatenation, in which case you can use colons directly.
If you’re seeing the crash while loading the SVG into something else (trying to parse it after you made it), it sounds like you didn’t add the right namespaces to the file.January 30, 2022 at 1:30 pm #29745
Thanks for the reply.
So I take it
inkscape:label = “1 +D250name” and inkscape:groupmode=”layer”
both really need the “inkscape:”
and axidraw API will not work with just
label = “1 +D250name” and groupmode=”layer” ?
For now I will follow your suggestion and use the simple string concatenation approach.January 30, 2022 at 1:32 pm #29746
The AxiDraw software reads SVG. The syntax that we use is properly namespaced SVG, while versions with equals signs or hyphens are not.January 31, 2022 at 1:37 pm #29747
You are saying that using eraul signs and hyphens in the SVG are not proper?
you are showing us to do just that
and the example SVGs that come with Axidraw-Examples-1-2.4 also have that in them
I am confused.
???January 31, 2022 at 1:37 pm #29748
Thank you again for taking the time to respond.
I understand now.
Inside the SVG I have to make sure that I am setting up the proper namespace for inkscape usage.
The following block needs to be included otherwise my svg reader throughs an error about the included colon.
Thank you!January 31, 2022 at 1:39 pm #29751
Great; that looks like an approach that would work!
- The topic ‘problems in group element with attribute when using “colon”’ is closed to new replies.