Change the DOCTYPE of an Open XML Document
Use Case
You want to change the DOCTYPE of a document that is open in the Author mode.
Solution
The following API:
ro.sync.ecss.extensions.api.AuthorDocumentController.getDoctype()
allows you to get the DOCTYPE
of the current XML file open in the
Author mode.
There is also an API method available that would allow you to set the
DOCTYPE
back to the XML:
ro.sync.ecss.extensions.api.AuthorDocumentController.setDoctype(AuthorDocumentType)
AuthorDocumentType
dt = new AuthorDocumentType("article", "testSystemID", "testPublicID",
"<!DOCTYPE article PUBLIC \"testPublicID\" \"testSystemID\">");
docController.setDoctype(dt);
Basically, you could take the entire content from the existing DOCTYPE,
ro.sync.ecss.extensions.api.AuthorDocumentType.getContent()
modify it to your needs, and create another AuthorDocumentType
object with
the new content and with the same public, system IDs.
For example, you could use this API is you want to add unparsed entities in the XML
DOCTYPE
.