problems in group element with attribute when using “colon”

Home Evil Mad Scientist Forums AxiDraw problems in group element with attribute when using “colon”

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #29740
    stephanschulz
    Participant

    This link explains how layers need to be named to achieve different drawing behaviours.
    https://wiki.evilmadscientist.com/AxiDraw_Layer_Control

    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.

    #29744
    Windell Oskay
    Keymaster

    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.

    #29745
    stephanschulz
    Participant

    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.

    #29746
    Windell Oskay
    Keymaster

    The AxiDraw software reads SVG. The syntax that we use is properly namespaced SVG, while versions with equals signs or hyphens are not.

    #29747
    stephanschulz
    Participant

    You 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.
    ???

    #29748
    stephanschulz
    Participant

    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.

    `
    svg->setAttribute(“xmlns:dc”,”http://purl.org/dc/elements/1.1/&#8221;);
    svg->setAttribute(“xmlns:cc”,”http://creativecommons.org/ns#&#8221;);
    svg->setAttribute(“xmlns:rdf”,”http://www.w3.org/1999/02/22-rdf-syntax-ns#&#8221;);
    svg->setAttribute(“xmlns:svg”,”http://www.w3.org/2000/svg&#8221;);
    svg->setAttribute(“xmlns”,”http://www.w3.org/2000/svg&#8221;);
    svg->setAttribute(“xmlns:inkscape”,”http://www.inkscape.org/namespaces/inkscape&#8221;);
    `

    Thank you!

    #29751
    Windell Oskay
    Keymaster

    Great; that looks like an approach that would work!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘problems in group element with attribute when using “colon”’ is closed to new replies.