Page 1 of 1

XPath In-scope schema definitions

Posted: Fri Jun 06, 2008 4:29 pm
by rparree
Is there a way of importing schemas into the static context of the XPath console? I know XPath itself has no syntax for importing schema's into the static context, but probbaly the API of your XPath processor implementation has (?). It would simplify my XPath expressions to specify if an Author operation should be available for the current node.

tx.,

Re: XPath In-scope schema definitions

Posted: Fri Jun 06, 2008 4:58 pm
by sorin_ristache
Hello,

In the Author operation that you write you can find out the current node, that is the node with the cursor in the Author editor. The AuthorAccess parameter of the Author operation has a method getCaretOffset and a method getDocumentController. You can find the current node with the code:

Code: Select all

authorAccess.getDocumentController().getNodeAtOffset(authorAccess.getCaretOffset())
You also know the schema of the edited document because you set up your Author operation in a document type created from menu Options -> Preferences -> Document Type Association where you can set what schema you want for your document type.


Regards,
Sorin

Re: XPath In-scope schema definitions

Posted: Fri Jun 06, 2008 5:49 pm
by rparree
Sorin,

Thanks i was aware of this (and this is how i have been developing a couple of operations). What i was referring to was the XPath expression you can define when defining the action in the document type settings. Some plugins can work on various elements, as long as they of a certain type.
This is probably the kind of XPath expression you would like to have here anyway as these operations operate on a type of element, not so much the name of the element.
For example like:

Code: Select all

self::element(*,foo:myType)
If within the author operation code you could check the type (as in schema type) of the current node that would also do the trick.

The alternative is to have a long Xpath expression or a long if statement checking all possible element names of that type. This also gives a maintainance headache when new elements of the same type are introduced.


tx.,

Re: XPath In-scope schema definitions

Posted: Fri Jun 06, 2008 5:54 pm
by sorin_ristache
Now I understand. No, the XPath expression that defines when the Author action can be called is not schema aware. We will consider that for a future version of Author.


Regards,
Sorin