How can we get possible parent element
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
How can we get possible parent element
Post by SmitaPatil »
Hi Team.
can you please tell if node is fully selected then How can we get list of valid possible parent element using which we can wrap selected node.
as shown in below screenshot.
For example in this screenshot, venue.name has selected so we want to display the list of element which can insert as parent of selected element and children of content.venue element.
Thanks,
Smita
can you please tell if node is fully selected then How can we get list of valid possible parent element using which we can wrap selected node.
as shown in below screenshot.
For example in this screenshot, venue.name has selected so we want to display the list of element which can insert as parent of selected element and children of content.venue element.
image.png
Can you please tell if there is any method which will help me here?Thanks,
Smita
You do not have the required permissions to view the files attached to this post.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How can we get possible parent element
Hi Smita,
We do not have a specific API method for this.
Why don't you use our contextual menu "Surround with..." functionality?
We also have API to ask the associated schema what elements can be inserted at a certain offset:
Regards,
Radu
We do not have a specific API method for this.
Why don't you use our contextual menu "Surround with..." functionality?
We also have API to ask the associated schema what elements can be inserted at a certain offset:
Code: Select all
AuthorNode selected = authorAccess.getEditorAccess().getFullySelectedNode();
if(selected instanceof AuthorElement) {
AuthorElement elem = (AuthorElement) selected;
AuthorSchemaManager schemaManager = authorAccess.getDocumentController().getAuthorSchemaManager();
WhatElementsCanGoHereContext context = schemaManager.createWhatElementsCanGoHereContext(elem.getStartOffset());
List<CIElement> possibleElementsBeforeSelectedElement = schemaManager.getChildrenElements(context);
CIElement chosen = ...;
AuthorDocumentFragment fragForCIElement = schemaManager.createAuthorDocumentFragment(chosen);
authorAccess.getDocumentController().surroundInFragment(fragForCIElement, elem.getStartOffset(), elem.getEndOffset());
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: How can we get possible parent element
Post by SmitaPatil »
Hi Radu,
I think there is some confusion in requirement.
I will explain again the requirement is if user select venue.name node then we have to display the list of parent elements using which we can wrap it. Currently I am getting below list of elements. I am getting it using getchildren method. but the issue here is it also contain some elements which is not valid for wrapping venue.name.
In short, I have to give list of elements which is valid to use as parent of selected element before wrapping it and checking for validation.
If I go this way by getting ChildrenElements list and then creating fragment and checking for each element whether its valid to wrap it or not. In case of large list of childrenElement list it may take longer time. That's why I thought to check if there is any method present.
Please let me know if you need any more information
Thanks,
Smita
I think there is some confusion in requirement.
I will explain again the requirement is if user select venue.name node then we have to display the list of parent elements using which we can wrap it. Currently I am getting below list of elements. I am getting it using getchildren method. but the issue here is it also contain some elements which is not valid for wrapping venue.name.
image.png
So I thought if somehow I could able to get list of possible parent elements for selected element. that will help me here. In short, I have to give list of elements which is valid to use as parent of selected element before wrapping it and checking for validation.
If I go this way by getting ChildrenElements list and then creating fragment and checking for each element whether its valid to wrap it or not. In case of large list of childrenElement list it may take longer time. That's why I thought to check if there is any method present.
Please let me know if you need any more information
Thanks,
Smita
You do not have the required permissions to view the files attached to this post.
Last edited by SmitaPatil on Mon Dec 05, 2022 3:41 pm, edited 2 times in total.
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: How can we get possible parent element
Post by SmitaPatil »
Hi Radu,
oh okay.
I have seen if I select element and click on enter I am getting valid list of element using which I can wrap selected element as shown in below screenshot. selected element is venue.name
and one more question, can we create a context for completed selected node or if I can given and start and end offset somehow?
Thanks,
Smita
oh okay.
I have seen if I select element and click on enter I am getting valid list of element using which I can wrap selected element as shown in below screenshot. selected element is venue.name
image.png
To achieve this which other are getting used if you can tell me it will be helpful for me.and one more question, can we create a context for completed selected node or if I can given and start and end offset somehow?
Thanks,
Smita
You do not have the required permissions to view the files attached to this post.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How can we get possible parent element
Hi Smita,
Maybe you can implement a custom AuthorOperationWithResult and add it to the framework on the server side then invoke it from the Javascript code on the client side:
https://www.oxygenxml.com/maven/com/oxy ... esult.html
The method "AuthorOperationWithResult.doOperation(AuthorDocumentModel, ArgumentsMap)" receives an "AuthorDocumentModel" which could use this API to ask our code what proposed choices are to surround the current selected content:
Regards,
Radu
Maybe you can implement a custom AuthorOperationWithResult and add it to the framework on the server side then invoke it from the Javascript code on the client side:
https://www.oxygenxml.com/maven/com/oxy ... esult.html
The method "AuthorOperationWithResult.doOperation(AuthorDocumentModel, ArgumentsMap)" receives an "AuthorDocumentModel" which could use this API to ask our code what proposed choices are to surround the current selected content:
Code: Select all
List<CCItemProxy> proposedElementsForSurround = model.getContentCompletionManager().getProposedElementsForSurround(model.getSelectionModel());
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
Re: How can we get possible parent element
Post by SmitaPatil »
Hi Radu,
Thank you. It resolved.
Thanks,
Smita
Thank you. It resolved.
Thanks,
Smita
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