Helpful error messages for Actions

Are you missing a feature? Request it's implementation here.
Posts: 154
Joined: Sat Aug 28, 2010 1:23 am

Helpful error messages for Actions

Post by dcramer » Fri Jan 28, 2011 6:49 am

Hi there,
Actions are very flexible and useful and I'm creating bunches of them. I do sometimes find myself wanting to be able to specify a helpful error message sometimes. E.g. Say I write the xpath such that a PI can only be the child of an entry (because this PI controls the rotation of text in table cells). I'd like to be able to specify a message like "These PIs must be the direct children of table cells." Which would be more helpful than "The not available in the current context"


Posts: 6812
Joined: Fri Jul 09, 2004 5:18 pm

Re: Helpful error messages for Actions

Post by Radu » Fri Jan 28, 2011 12:18 pm

Hi David,

The solution for this would be to use a very permissive XPath for your operation (like true()) which will mean that your operation is always called.

Then on the

Code: Select all

* @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
implementation you can check for yourself if the caret position is inside a valid XML element.
The ro.sync.ecss.extensions.api.AuthorDocumentController has methods which can be used to evaluate an XPath at the caret position.
Then you have full control over the error message to report either by throwing an AuthorOperationException or by showing the error message yourself:

Code: Select all

Radu Coravu
<oXygen/> XML Editor

Post Reply