It is possible to use the Ace editor to edit XML according to a specified XSD?
If not, are there any alternatives?
It is in fact possible to validate XSD with Ace, it is just not supported by the libraries Ace comes with, so you will need to use something else to validate your XML against an XSD file. Then, you simply convert the error output you receive as annotations, and disable the default syntax validator using:
editor.getSession().setUseWorker(false);
For example, I am using AgeGWT which is a wrapper that allows usage of Ace inside Java and GWT. Note that the github version has very outdated libraries (3-4 years..maybe they will be updated in the future, but doesn't look like the page is actively maintained), so I simply downloaded and setup Ace using npm so that I can copy over and use Ace's newest libraries (which have extra features).
Then, I used a Java XML validator that returns all errors, similar to that found here.
This will retrieve a List/Array of SAXParseException. This type allows querying for the error text and line and column numbers - which is the minimum information required to set the annotations (I set them all to have the Error Annotation type).
The annotations themselves are set up on an Ace Callback, that is triggered each time the text in the editor is changed:
editor.addOnChangeHandler(new AceEditorCallback() { @Override public void invokeAceCallback(JavaScriptObject obj) { // validate XSD...
Then I set the annotations in the Ace Editor, using the information gathered previously by the validator.
You do not have to use Java, or the specified libraries to make this work. There should be no issue doing this in JavaScript in a similar fashion, perhaps using sax js...in fact, it will probably be much easier.