Funny, I touch myself with something like that. I am building an editor (not really WYSIWYG, but it is abstracting the DOM) for XMLs Civilization 4 (strategy game) uses to store everything. I thought about this for a long time and built two prototypes (in Python), one of which looks promising, so I will expand it in the future. Please note that Civ 4 XML is just something more than a buzzword compatible database (only data that is best stored in JSON / YAML, etc., Basically key value pairs with multiple sublists of key pairs -value "- no recursive data structures).
My first approach was based on the fact that basically there are key value pairs that are not suitable for documents that use all the power of XML (recursive data structures, etc.). My new design is more complicated - so far I have only built (still buggy) the factory validator in this way, but I look forward to extending it, for example. for widgets editing circuit. The main idea is to go through the XSD DOM, recognize the expected content (list of other nodes, text of a certain format, etc.), build in turn (recursively) validators for them, and then build a higher order validator that applies All previously created validators are in the correct order. It is convenient to use for functional programming to enjoy this idea. For the editing part (btw, I use PyQt), I plan to generate a Label-LineEdit pair for tags that contain text and a Label for tags that contain other elements, possibly indented sub-elements and / or collapse. Again, recursion is the key to creating them.
Qt allows us to attach a validator to a text input widget, so this part will be simple as soon as we can create a validator, for example. tag containing "int". For tags containing other tags, something similar to the above may be possible: Create a validator for each element and bind it. The only part that needs to be changed is how we get the content. Ignoring comments, attributes, processing instructions, etc., It should be relatively simple - for a pair of "tag: content", generate "content" and pass it to your DOM parser; for elements with sub-elements, generates a representation of children and places them between "...". Attributes can also be implemented as key-value pairs, but with an additional flag.
delnan
source share