Page 1 of 1

Check if an element is allowed without inserting

Posted: Thu Dec 06, 2012 6:13 pm
by Vincent
Hi,


We have some buttons which aim to insert new elements in the XML tree.
We would like to "setEnable" those buttons only when it is allowed by the schema.

In fact we would like to test an xml fragment at the caret position in order to know if we can insert it or not (true/false). But without having to add it in the XML tree (this step will depend on if the user will click or not)



Thank you,
Vincent.

Re: Check if an element is allowed without inserting

Posted: Thu Dec 06, 2012 6:26 pm
by Radu
Hi Vincent,
We have some buttons which aim to insert new elements in the XML tree.
We would like to "setEnable" those buttons only when it is allowed by the schema..
If the buttons are implemented as Author actions, they have XPath activation expressions.
In Oxygen 14.2 these expressions will also be used to disable the actions if the XPath activation expression is not triggered in the current context.
In fact we would like to test an xml fragment at the caret position in order to know if we can insert it or not (true/false).
There is an AuthorSchemaManager:

Code: Select all

AuthorSchemaManager authorSchemaManager = authorAccess.getDocumentController().getAuthorSchemaManager();
which has methods like:

Code: Select all

ro.sync.ecss.extensions.api.AuthorSchemaManager.canInsertDocumentFragment(AuthorDocumentFragment, int, short)
You can create an AuthorDocumentFragment from an XML string like:

Code: Select all

ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentFragmentInContext(String, int)
Regards,
Radu