cppfw/svgdom

Missing namespaces in root <svg>

Closed this issue · 2 comments

Is there a way to include namespaces when writing the root <svg>? Here's the code and the generated string to illustrate what I'm talking about:

auto dom = utki::makeUnique<svgdom::SvgElement>();

svgdom::PathElement path;

svgdom::PathElement::Step step;

step.type = svgdom::PathElement::Step::Type_e::MOVE_ABS;
step.x = 0;
step.y = 0;
path.path.push_back(step);

step.type = svgdom::PathElement::Step::Type_e::LINE_ABS
step.x = 0;
step.y = 300;
path.path.push_back(step);

step.type = svgdom::PathElement::Step::Type_e::LINE_ABS;
step.x = 300;
step.y = 300;
path.path.push_back(step);

step.type = svgdom::PathElement::Step::Type_e::LINE_ABS;
step.x = 300;
step.y = 0;
path.path.push_back(step);

dom->children.push_back(utki::makeUnique<svgdom::PathElement>(path));

cout<<dom->toString()<<std::endl;

And here's the string result:

<svg>
	<path d="M0,0L0,300 300,300 300,0"/>
</svg>

Notice that the xmlns namespace is missing, and therefore the result can't be properly rendered.

Unable to reproduce the problem. I added a new test 'toString' which is one to one your code above and it generates those xmlns name spaces.
Here, on the build log line 1042 you can see that the test passes:
https://ci.appveyor.com/project/igagis/svgdom/build/master-282#L1042

Are you sure that you use the latest version of svgdom?

Thanks for adding the test. I just found out that the error was happening on a previous version (before you did all the refactoring). My bad, should have tested with latest version. I'm going to go ahead and close this issue.