So I guess only the ro.sync.ecss.extensions.api.AuthorSchemaManager.createAuthorDocumentFragment(CIElement) method generates such a valid AuthorDocumentFragment, right?
Yes, you need to use the schema manager if you want to create a fragment which has all required elements and attributes filled in.
But how do I get the desired CIElement from a String, which just contains the name of the XML element?
Please look at the sample code I posted.
The code I posted has at some point:
You can then use the API to insert this fragment at the caret position.
So it creates an AuthorDocumentFragment object which can either be inserted directly or converted to XML using AuthorDocumentController.serializeFragmentToXML(AuthorDocumentFragment)
or is it somehow possible to get only the required elements of an existing element, so that I can add those elements afterwards? After the node with the schema aware dialog is used?
Yes, you can also do this.
First use the API to create a context:
then you use this API to get a list of allowed elements at the caret position:
object has a method called CIElement.getGuessElements()
which returns the list of required child elements in it.
But it is easier to let Oxygen create the fragment for you as shown in my sample code.