getParent() result on root node

Post here questions and problems related to oXygen frameworks/document types.
Isabelle
Posts: 81
Joined: Fri Jan 20, 2017 1:11 pm

getParent() result on root node

Post by Isabelle » Wed Jun 23, 2021 12:55 pm

Hello,

I work with the version 22 of Oxygen SDK.

We have noticed this in the javadoc :
getParent
AuthorNode getParent()
Returns:
The AuthorNode representing the parent of this element, or null if this is the root element.
But we get the root element like this :

Code: Select all

AuthorNode rootNode = authorAccess.getDocumentController().getNodeAtOffset(authorAccess.getEditorAccess().getCaretOffset());
And then use the method getParent() on the rootNode; It provides an AuthorDocument and not null has expected.

Is it normal ?
Did we miss an information or the javadoc is not up to date ?

I have checked the release notes on your website (https://www.oxygenxml.com/xml_editor/whatisnew22.1.html) and i did not find any changes on that part.

Regards,
Isabelle

Radu
Posts: 7579
Joined: Fri Jul 09, 2004 5:18 pm

Re: getParent() result on root node

Post by Radu » Wed Jun 23, 2021 1:28 pm

Hi Isabelle,

The Javadoc is incorrect, I will rectify it like this:

Code: Select all

  /**
   * @return The {@link AuthorNode} representing the parent of this element, 
   * or <code>null</code> if this is the document node.
   */
  AuthorNode getParent();
The code has always worked this way, the root AuthorElement has a parent node which is an AuthorDocument node. The AuthorDocument node may also contain comments or processing instructions which are present before or after the root element.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply