1. Overview Previous topic Parent topic Child topic Next topic

Let's assume your web application comprises a frontend running in the user's browser and a backend running on a server computer. Let's call your frontend, MyFrontend and your backend, MyBackend. MyFrontEnd and MyBackend communicate with each other through HTTP/HTTPS. MyFrontEnd is implemented in HTML/CSS/JavaScript, this code possibly being totally or partially automatically generated by MyBackend. MyBackend possibly makes use of a database of some sort also running on a server computer.
In order to integrate XMLmind XML Editor Web Web Edition (XXEW) into your web application:

Opening an XML document

  1. MyFrontEnd JavaScript code queries MyBackend to obtain the XML source of the document to be opened in XMLEditor.
  2. MyFrontEnd obtains a “handle” to the instance of XMLEditor Opens in new window contained in its HTML page, possibly using document.getElementById(id) or document.getElementsByTagName("xxe-client"). Let's call this handle xmlEditor.
  3. MyFrontEnd invokes xmlEditor.openDocument(xmlSource, documentURI) Opens in new window.
    Note
    Note
    Method openDocument() must be passed a document URI identifying the document being edited.
    XMLEditor makes very few assumptions about how documents are stored by your web application, so your are free to use a URI of any kind, suffice for this URI to be meaningful to your web application.
    Using custom URI schemes and/or custom URI authorities is fine as long as the document URI is hierarchical. The syntax of a document URI is thus: scheme://authority/path, with authority being optional. For example, the following URIs are supported: https://cms.acme.com/docs/manual.xml, docs:///0943_3561, and the following URIs are not: mailto:john@acme.com, urn:isbn:9780582035874.
Creating a new XML document rather opening an existing one is done by invoking xmlEditor.newDocumentFromTemplate(templateXMLSource, documentURI) Opens in new window. The main difference with openDocument is that after invoking newDocumentFromTemplate, the saveAsNeeded Opens in new window property of XMLEditor is set to true.

Saving changes

MyFrontEnd may invoke xmlEditor.saveDocument() Opens in new window to save the changes made to the document. Because how documents are stored is entirely the responsibility of MyFrontEnd/MyBackend, this method does nothing at all except setting the saveNeeded Opens in new window property of XMLEditor is set to false.
In order to let MyBackend actually save the document being edited, MyFrontEnd may invoke xmlEditor.getDocument() Opens in new window to first obtain the XML source of the modified document and then send this source to MyBackend.
Similarly, xmlEditor.saveDocumentAs(newDocumentURI) Opens in new window, which may be used to implement the "Save As" command, simply
MyFrontEnd almost certainly needs to be informed when changes are made to the document, therefore when these changes need to be saved to the document storage. This is done by registering a "saveStateChanged" listener with XMLEditor as follows: xmlEditor.addEventListener("saveStateChanged", listener) Opens in new window. This listener will receive SaveStateChangedEvent Opens in new windows.

Closing the XML document being edited

MyFrontEnd may invoke xmlEditor.closeDocument() Opens in new window to close the document being edited, if any.
Several properties of XMLEditor, documentIsOpened Opens in new window, documentUID Opens in new window, documentURI Opens in new window, etc, may be used to test whether a document is currently being edited.