netvl/xml-rs

[Question] Is this library suited for XML reformatting?

hoijui opened this issue · 2 comments

Hello! :-)
I would like to make a tiny tool, that reformats XML in a specific format, well suited for diffing/storing it in git and the like.
We currently need this especially for SVG, but I guess doing it for XML in general would not hurt either.
The question is, whether this library is suited for such a task, with the main issue being fine-grained control over the output formatting, I imagine.

A little sample output:

...
  <defs
     id="defs6">
    <linearGradient
       gradientTransform="translate(-944.87702,-1490.4786)"
       id="linearGradient1424"
       osb:paint="solid">
...

The exact details may vary, but more or less, something like the above seems to make sense.

NOTE: Please also give word if you know of such a tool already existing!
There is at least gsvg, but it is Node.js based,
which I consider far from optimal for such a kind of tool.

I am not yet a rust dev, but am looking for a somewhat simple project to start.
So if you have some sample code that does something similar already, I would be happy about that too.

There is also tidy, which is written in C. It seems quite large, powerful and complex, and I was not able to make it behave properly (for example, it produces different output if you run it once on a file, or twice).

gsvg even changes the actual content of the file, so my SVGs look different after applying it.

Yes and no. The XML writer provided by this library does not have enough control for this, and I don't think files that pretty are needed.

However, you can use the XML reader and use its events to print parsed XML data any way you want.