get Current node (name) in AuthorOperation

Are you missing a feature? Request its implementation here.
rparree
Posts: 53
Joined: Tue Aug 23, 2005 12:00 pm

get Current node (name) in AuthorOperation

Post by rparree »

Hi,

Is it possible to find out where your are inside the document in terms of XML. I need to find out if an node a or node b. Depending on this location i either need to add a fragment at the caret position or as a sibling under the current node.

tx.,
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: get Current node (name) in AuthorOperation

Post by sorin_ristache »

Hello,

You can find the current XML node based on the current position of the cursor in the Author editor and once you find the current XML node you request the name of the node:

Code: Select all

int offset = authorAccess.getCaretOffset();

AuthorNode node = authorAccess.getDocumentController().getNodeAtOffset(offset);

String name = node.getName();
Regards,
Sorin
rparree
Posts: 53
Joined: Tue Aug 23, 2005 12:00 pm

Re: get Current node (name) in AuthorOperation

Post by rparree »

Sorin,

Thanks for the prompt reply (again!)

The JavaDoc writes that this returns the qualified name, is there a way of obtaining the local-name or the qualified name as a QName?

tx.,
rparree
Posts: 53
Joined: Tue Aug 23, 2005 12:00 pm

Re: get Current node (name) in AuthorOperation

Post by rparree »

Oops found it there is an AuthorElement sub interface that gives you this option..
Post Reply