we are way off XML as most Inkscapers use it here, but I find your comments interesting Peter.


It sounds like you have gone beyond my exploration. If I understand you correctly, I think you are probably right.


On 03/02/2015 11:52 AM, Peter Brooks wrote:
I've had a look at Kate, and at a test version of a commercial XML editor.

They seem OK at getting a pretty line-up of the elements, not that that's particularly difficult.

The problem I see is that they seem only to have text search and replace - I'd have thought that the whole point was to search and replace at the node level - a semantic search.

How would you do this without knowing the schema to start with? It sounds like you want XML to be the self-identifying self-defining structure it was supposed to be. I think.

But it IS possible to write an XML lint, so there is some ability to say this tree is valid and that isn't.

My experience was that is was possible, even easy, to create XML that wasn't internally coherent, yet was valid. And as a pragmatist I found it easier to just translate it into JSON in a JS SVG project.



So they seem more like a plug-in to vi for appearance than an actual object editor.

I tried the python libraries. They have read-in alternatives of DOM and SAX. After that, they seem a bit basic. They seem to expect you to know the schema, or know which to choose from the various schemas.

I was expecting a bit more. Maybe I'm foolish, but I'd hoped to be able to:

- read into a DOM structure
- print out the schema - a node tree - of something as common as a .svg file
- do a search and replace on tags or objects

Something like: %s/<text>\(.*\)</text>/<a href:\1>&</a>/ 
But with some knowledge of the tags - the above is simply sed syntax.

I'm getting the strong feeling that where I started, with awk, might be the least inelegant place.

Unless, as is quite possible, I'm missing something fundamental.

When I use the python DOM, the underlying assumption seems to be that it's a fairly balanced and uniform tree, with a single root. An SVG file, though, has a preamble, then a whole series of nodes, at the same level as the preamble, so it's a much flatter structure. So looking for sub-nodes of the root and their siblings doesn't really work - well, it might, if there was a way to print out what it thinks the structure is to get an idea of the best way to navigate it.

The examples I've found make sense, but they're all based on much simpler and more regular structures than an svg file.

Inkscape offers some nice looking reflections and transformations of the diagram, but doesn't really seem helpful when it comes to attaching URLs or other actions in the CLI. Again, maybe I'm missing an obvious trick.

If I am missing some obvious tricks here, I'd be most grateful if somebody could point them out to me - or point me in the direction of something that addresses this.

-- 
John Fisher
Znyx Networks