Find the name of a parent node/tag in EditorPage
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 48
- Joined: Sat Jan 04, 2020 1:17 am
Find the name of a parent node/tag in EditorPage
Hello,
We are working on a function that inserts a tag, but we want to validate the parent node, to make sure it is
valid.
For AuthorPage, we got this to work:
How can we do the same thing for EditorPage?
Thank you,
Will
We are working on a function that inserts a tag, but we want to validate the parent node, to make sure it is
valid.
For AuthorPage, we got this to work:
Code: Select all
AuthorAccess authorAccess = authorPage.getAuthorAccess();
AuthorElement nodeAtCaret = (AuthorElement) authorAccess.getEditorAccess().getFullySelectedNode();
if (nodeAtCaret == null) {
try {
nodeAtCaret = (AuthorElement) authorAccess.getDocumentController().getNodeAtOffset(offset);
} catch (BadLocationException e) {
e.printStackTrace();
}
System.out.println(nodeAtCaret.getDisplayName()); // it will display the parent tag name and using this we can validate the our condition.
}
Thank you,
Will
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: Find the name of a parent node/tag in EditorPage
Post by alex_jitianu »
Hello Will,
Here is how you can do that for the Text page:
The Grid page doesn't have an API though which to do that...
Best regards,
Alex
Here is how you can do that for the Text page:
Code: Select all
WSEditorPage currentPage = wsEditor.getCurrentPage();
if (currentPage instanceof WSXMLTextEditorPage) {
WSXMLTextEditorPage xmlTextPage = (WSXMLTextEditorPage) currentPage;
try {
Object[] evaluateXPath = xmlTextPage.evaluateXPath("local-name()");
if (evaluateXPath != null && evaluateXPath.length == 1 && evaluateXPath[0] instanceof String) {
String localName = (String)evaluateXPath[0];
}
} catch (XPathException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Best regards,
Alex
Return to “SDK-API, Frameworks - Document Types”
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