EDIT: It's actually an object literal, but whatever ;)
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalEDIT: It's actually an object literal, but whatever ;)
EDIT: It's actually an object literal, but whatever ;)
I'm actually working on something similar, and I've settled with using a JSON file on the server that describes what type of elements/attributes are allowed.
When a user uploads a XML file, it can be compared to the data file on the server through a script, and elements or attributes with improper syntax can be rejected.
As far as a standard way of doing this, I'm not aware of any, though this method has been working quite well for me so far.
Here's what my test JSON object looks like:
XMLTemplate = { xml : '<?xml version="1.0" encoding="UTF-8" ?>', doctype : '<!DOCTYPE xml PUBLIC>', children : [{ name : "ROOT", description : "All xml documents have a root tag", children : [{ name : "GROUP", description : "Groups contain products, as well as some fields", attributes : [{ name : "TYPE", description : "What type of product" },{ name : "DESCRIPTION", description : "Group Description" }], children : [{ name : "TITLE", description : "Title of the group" },{ name : "DESCRIPTION", description : "Group description", attributes : [{ name : "SOMETHINGELSE", description : "some other attribute I don't know" },{ name : "WIDTH", description : "" }] },{ name : "PRODUCT", description : "Products contain some stuffs", attributes : [{ name : "TYPE", description : "type of product" },{ name : "SOMETHINGELSE", description : "some other attribute I don't know" }], }] }] }] }