Find the Ancestor Parent
Having trouble installing Oxygen? Got a bug to report? Post it all here.
Find the Ancestor Parent
Hi Team,
I need the ancestor parent of the child node. Please find the below example.
In the below example if my cursor is at any postion i should get parent as disclaimer.
say my cursor is at para of first footnote or second footnote i should get parent as disclaimer.
I am using below methods to get parent but i am getting immediate parent not the ancestor one.
getCommonAncestor();
getStrictCommonAncestor
Please help me on this.
<disclaimer>
<para>
<text.line/>
</para>
<footnote ID=""
xmlns="">
<footnote.body>
<para>
<label.designator/>
</para>
</footnote.body>
</footnote>
<footnote ID=""
xmlns="">
<footnote.body>
<para>
<label.designator/>
</para>
</footnote.body>
</footnote>
</disclaimer>
I need the ancestor parent of the child node. Please find the below example.
In the below example if my cursor is at any postion i should get parent as disclaimer.
say my cursor is at para of first footnote or second footnote i should get parent as disclaimer.
I am using below methods to get parent but i am getting immediate parent not the ancestor one.
getCommonAncestor();
getStrictCommonAncestor
Please help me on this.
<disclaimer>
<para>
<text.line/>
</para>
<footnote ID=""
xmlns="">
<footnote.body>
<para>
<label.designator/>
</para>
</footnote.body>
</footnote>
<footnote ID=""
xmlns="">
<footnote.body>
<para>
<label.designator/>
</para>
</footnote.body>
</footnote>
</disclaimer>
Re: Find the Ancestor Parent
Hello,
If I understand correctly, you want to obtain the element named "disclaimer", whatever the current position of the caret.
If this is the case I think you should:
- first, get the current element using the AuthorDocumentController.getNodeAtOffset(int), where the offset is the caret offset: authorAccess.getEditorAccess().getCaretOffset()
- if this is not the disclamer element search in parents until you find it.
Also, you can use XPath to search for a specific element: AuthorDocumentController.findNodesByXPath(String, boolean, boolean, boolean, boolean)
Best Regards,
Mihaela
If I understand correctly, you want to obtain the element named "disclaimer", whatever the current position of the caret.
If this is the case I think you should:
- first, get the current element using the AuthorDocumentController.getNodeAtOffset(int), where the offset is the caret offset: authorAccess.getEditorAccess().getCaretOffset()
- if this is not the disclamer element search in parents until you find it.
Also, you can use XPath to search for a specific element: AuthorDocumentController.findNodesByXPath(String, boolean, boolean, boolean, boolean)
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service