how to the list of which elements can be wrapped a element
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 99
- Joined: Fri Jul 01, 2022 12:08 pm
how to the list of which elements can be wrapped a element
Post by shikhar_472 »
Hi Team,
Is there any inbuild method or way to get the list of element which can wrapped on selection.
USE CASE - suppose i am selecting a node and i want to change that selected node with the possible wrap element i need the list of element which should allow on that position while replacing the tag with another one.
<disclaimer>
<para><paratext></paratext></para>
</disclaimer>
here i want to select the disclaimer and want to change the disclaimer with the possible allowed elements which should be wrapper outside of para i want that element of list
Is there any inbuild method or way to get the list of element which can wrapped on selection.
USE CASE - suppose i am selecting a node and i want to change that selected node with the possible wrap element i need the list of element which should allow on that position while replacing the tag with another one.
<disclaimer>
<para><paratext></paratext></para>
</disclaimer>
here i want to select the disclaimer and want to change the disclaimer with the possible allowed elements which should be wrapper outside of para i want that element of list
Re: how to the list of which elements can be wrapped a element
Hello,
Try to use this code, and optionally add more logging if you encounter errors to investigate them:
Best Regards,
Cosmin
Try to use this code, and optionally add more logging if you encounter errors to investigate them:
Code: Select all
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws AuthorOperationException {
AuthorElement nodeToRename = ...;
AuthorSchemaManager schemaManager = authorAccess.getDocumentController().getAuthorSchemaManager();
Map<QName, Collection<QName>> elementToParentsMap = schemaManager.getElementToParentsMap(nodeToRename);
try {
WhatElementsCanGoHereContext context = schemaManager.createWhatElementsCanGoHereContext(nodeToRename.getStartOffset());
List<CIElement> allPossibleElementsWhichCanBeInsertedInsteadOfNodeToRename = schemaManager.getChildrenElements(context);
//Now we need to filter all possible elements and leave only the ones which can contain the selected content.
List<AuthorNode> childrenOfNodeToRename = nodeToRename.getContentNodes();
if(childrenOfNodeToRename != null && ! childrenOfNodeToRename.isEmpty()) {
for (AuthorNode childInsideSelection : childrenOfNodeToRename) {
Collection<QName> possibleParentsForChild = elementToParentsMap.get(new QName(childInsideSelection.getName()));
if(possibleParentsForChild != null) {
Iterator<CIElement> iter = allPossibleElementsWhichCanBeInsertedInsteadOfNodeToRename.iterator();
while(iter.hasNext()) {
CIElement possibleReplacement = iter.next();
if(! possibleParentsForChild.contains(new QName(possibleReplacement.getName()))) {
iter.remove();
}
}
}
}
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cosmin
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
-
- Posts: 99
- Joined: Fri Jul 01, 2022 12:08 pm
Re: how to the list of which elements can be wrapped a element
Post by shikhar_472 »
Hi Cosmin,
Thank you very much for the solution i have one more doubt if child element is not present in that scenarion i wanted the filtered list for sure I can get all PossibleElements when child is not present but what if some tags does now allow text in that list how to differentiate that
Thank you very much for the solution i have one more doubt if child element is not present in that scenarion i wanted the filtered list for sure I can get all PossibleElements when child is not present but what if some tags does now allow text in that list how to differentiate that
Re: how to the list of which elements can be wrapped a element
Hello,
Can you please give us a specific example to better understand what you are trying to obtain?
Best Regards,
Mihaela
Can you please give us a specific example to better understand what you are trying to obtain?
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