Check if an element is allowed without inserting

Oxygen general issues.
Vincent
Posts: 52
Joined: Thu Dec 15, 2011 7:56 pm

Check if an element is allowed without inserting

Post 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.
Radu
Posts: 9445
Joined: Fri Jul 09, 2004 5:18 pm

Re: Check if an element is allowed without inserting

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply