michmech / xonomy

A schema-driven XML editor for the web.
MIT License
91 stars 32 forks source link

A way to let the user add attributes/elements with a custom name? #12

Closed tarockx closed 7 years ago

tarockx commented 7 years ago

From reading the documentation, there seems to be no way to let the user add an attribute/child element with a name chosen by the user himself.

I would like the user to be able to click "add child..." or "add attribute..." on an element and be presented with a text box (similar to the Xonomy.askString asker) that asks him to enter the name of the element/attribute to be added.

Is this possible in any way? What would be the best way to implement it?

michmech commented 7 years ago

Xonomy doesn't have such a feature out of the box, but this should be relatively easy to do by writing your own menu action function, see section 4.4 in the Xonomy documentation. The function would need to ask the user for the name of the element/attribute and then simply call Xonomy.newAttribute() or Xonomy.newElementChild().

If you manage to get that done, it would be cool if you could do it in a fork of Xonomy and then send us a pull request!

Additionally, if you're allowing users to create elements and attributes with arbitrary names, then you will probably want to make sure that your document specification has the unknownElement and unknownAttribute properties. See section 14.1 in the Xonomy documentation for more about this.