I am working on a library that uses data- tags inside SVG files to embed extra data within them or flag specific tags that need their values filled in from data within the application. I then need to hand this data back to a library that is expecting a roxmltree::Document.
My current (non-working) though process is below:
Parse SVG with roxmltree
Convert to owned and mutable datatype
Modify SVG file as necessary
Convert back to roxmltree::Document
Hand off roxmltree::Document to usvg parser which then gets handed off to rendering library
My current problem is implementing From<roxmltree::Document> for mylib::Tree because all of the data within Document are private fields, and only some of them have accessor methods. Not sure if the automatically implemented Into will even work with the private fields.
I am not particularly wedded to any part of this process currently, (especially as it is not working), but I have not found an alternate way to do this.
from the roxmltree documentation it seems like you. should be perfectly able to extract any data you could need you just have to traverse the tree instead of trying to convert the entire struct at once
If you want to modify the XML representation, why are you using roxmltree, i.e. a read-only representation in the first place?
I didn't look at your project in detail, but my approach would be the implementation of an extension trait for either the SVG file object as exposed by usvg or, if this is not possible, provide an extension trait for the XML representation from a library, which allows mutation and appropriate conversion.
The main reason I was using roxmltree in the first place, was because I was using usvg and resvg which had that is dependencies.
I also wasn't originally planning on having to modify the XML, rather modifying the SVG produced after parsing the XML.
Not sure what you mean by extension trait here? At this point, I have a completely custom xml type that I am using as an intermediary, but am having a hard time converting to something usvg can use.