0

There are some applications that display XML structure in multiple views. An excellent example is Visual Studio Xaml ("Design") editor, which display an Object Tree, a rendered, "designer" window with mouse-manipulatable objects, a text editor with XAML content, and a properties window.

I am trying to do such a thing in PyQt to edit geographical maps, using KML as file format, but I would like to allow for direct editing and preservation formatting.

For example, I would like to be able to edit the formatting manually like this:

<Element attribute1="value1"
         attribute2="value2"
         attribute3="value3"/>

And be sure that attribute order and alignment would be kept intact upon further manipulation via TreeView or PropertiesWindow.

The fact is, a lot of answers say that, since attribute order is not a XML specification (that is, applications using XML should not count on it), the order is not guaranteed by any official library, and any library implementing it "is not doing XML". Specifically, not any Python library has support for this.

On the other hand, XAML editors in Visual Studio do that all the time.

So the question is: if I really, really want this, using Python GUI toolkits as a "support medium" (PyQt and its widgets, in principle), how hard would be the task? Should I expect to use python's XML libs, or would I have to write my own - that is, an overwhelmingly complex task - ?

heltonbiker
  • 26,657
  • 28
  • 137
  • 252
  • Regarding attribute order, most XML libraries in python uses dictionary to store XML attributes. If you are lucky, this might be as simple as [changing the dictionary to ordered-dictionary](http://stackoverflow.com/questions/1867861/python-dictionary-keep-keys-values-in-same-order-as-declared) – har07 May 15 '16 at 22:56
  • @har07 I thought about this, but actually I think it would be best to have an intermediate data structure between the representing string (the exact character sequence in the file) and the corresponding element node (a [mini]dom node, for example). That would be sort of an "attribute node tree", I guess. – heltonbiker May 16 '16 at 00:05
  • Consider XSLT where you can modify XML to any end-use format you require, even explicitly defining attribute order. – Parfait May 16 '16 at 02:51

0 Answers0