Page 1 of 1

get Current node (name) in AuthorOperation

Posted: Tue Jun 03, 2008 3:40 pm
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.,

Re: get Current node (name) in AuthorOperation

Posted: Tue Jun 03, 2008 4:23 pm
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

Re: get Current node (name) in AuthorOperation

Posted: Tue Jun 03, 2008 6:14 pm
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.,

Re: get Current node (name) in AuthorOperation

Posted: Wed Jun 04, 2008 8:30 am
by rparree
Oops found it there is an AuthorElement sub interface that gives you this option..