Home › Evil Mad Scientist Forums › AxiDraw › problems in group element with attribute when using “colon”
Tagged: axidraw openframeworks SVG
- This topic has 6 replies, 2 voices, and was last updated 2 years, 10 months ago by Windell Oskay.
-
AuthorPosts
-
January 29, 2022 at 11:24 pm #29740stephanschulzParticipant
This link explains how layers need to be named to achieve different drawing behaviours.
https://wiki.evilmadscientist.com/AxiDraw_Layer_ControlUnder “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 #29744Windell OskayKeymasterBoth 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 #29745stephanschulzParticipantThanks 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 #29746Windell OskayKeymasterThe 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 #29747stephanschulzParticipantYou are saying that using eraul signs and hyphens in the SVG are not proper?
Here https://wiki.evilmadscientist.com/AxiDraw_Layer_Control
you are showing us to do just that
inkscape:groupmode=”layer”and the example SVGs that come with Axidraw-Examples-1-2.4 also have that in them
inkscape:groupmode=”layer”I am confused.
???January 31, 2022 at 1:37 pm #29748stephanschulzParticipantThank 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.
`
svg->setAttribute(“xmlns:dc”,”http://purl.org/dc/elements/1.1/”);
svg->setAttribute(“xmlns:cc”,”http://creativecommons.org/ns#”);
svg->setAttribute(“xmlns:rdf”,”http://www.w3.org/1999/02/22-rdf-syntax-ns#”);
svg->setAttribute(“xmlns:svg”,”http://www.w3.org/2000/svg”);
svg->setAttribute(“xmlns”,”http://www.w3.org/2000/svg”);
svg->setAttribute(“xmlns:inkscape”,”http://www.inkscape.org/namespaces/inkscape”);
`
Thank you!
January 31, 2022 at 1:39 pm #29751Windell OskayKeymasterGreat; that looks like an approach that would work!
-
AuthorPosts
- The topic ‘problems in group element with attribute when using “colon”’ is closed to new replies.