2013/8/2 Christoffer Holmstedt <christoffer.holmstedt@...400...>:
I'm trying to walk through a complete document and get all nodes of a specific type, in this case <metadata> to populate the new metadata GUI.
My best bet now is to get the current active SPDocument and start to iterate from the root node, depth-first. I've found the sp_repr_lookup_name in "src/xml/repr.h" which do exactly that but stops at the first hit so I would have to wrap it somehow and run it multiple times. If I've understood this correctly it will work on the agnostic XML backbone and not with SPObjects which I should be using but then again RDF implementation doesn't use SPObject in its current state. Am I on the right track or totally lost?
sp_repr_lookup_name will work on the tree of Inkscape::XML::Node.
(within repr-util.cpp it seems like you can iterate through a XML::Node's all children with the help of firstChild() and next(), perhaps better than using the c facade function, but will it work with RDF nodes?)
Yes, it will work with RDF nodes too, they're ordinary XML nodes.
So to my second part, somewhat related, In sp-object.h a comment says "[...] SPObject layer is bound to the SPRepr layer, closely following the SPRepr mutations via callbacks." We have the typed object layer with SPObjects and the agnostic XML layer with SPRepr. The confusion for me now is concerning variable naming, I think, throughout Inkscape codebase both "repr" and "node" are used as variable names for XML::Node objects.
Is SPRepr the old "name" for XML::Node?
Yes, this is a documentation bug. "repr" is short for "representation" and was used in Sodipodi.
If yes, this would mean that everything below Inkscape::XML do work on the the agnostic XML backbone layer and not the SPObjects, have I understood this correctly?
Yes
Regards, Krzysztof