How to find next node
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 68
- Joined: Mon Jul 04, 2022 8:42 am
How to find next node
Hi Team,
I am using Web author, In below xml say my caret position is in first figure node and i would like to know what is the next node is it figure or not how to check that? Need Java api to check the following node of <figure>
Please help on this.
<venue.name>
<figure>
<embedded.figure.reference image-key="RPT.CC.11111111111.00010"
rendition-type="online">Image Online</embedded.figure.reference>
</figure>
<figure>
<embedded.figure.reference image-key="RPT.CC.11111111111.00020"
rendition-type="online">Image Online</embedded.figure.reference>
</figure>
UNITED STATES SUPREME COURT
</venue.name>
Thanks & Regards
Shilpa.P
I am using Web author, In below xml say my caret position is in first figure node and i would like to know what is the next node is it figure or not how to check that? Need Java api to check the following node of <figure>
Please help on this.
<venue.name>
<figure>
<embedded.figure.reference image-key="RPT.CC.11111111111.00010"
rendition-type="online">Image Online</embedded.figure.reference>
</figure>
<figure>
<embedded.figure.reference image-key="RPT.CC.11111111111.00020"
rendition-type="online">Image Online</embedded.figure.reference>
</figure>
UNITED STATES SUPREME COURT
</venue.name>
Thanks & Regards
Shilpa.P
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: How to find next node
Post by cristi_talau »
Hello,
I will assume you have an instance of AuthorNode. In this case you can obtain its siblings using a code like below:
Now you can just the element after node in the list.
Best,
Cristian
I will assume you have an instance of AuthorNode. In this case you can obtain its siblings using a code like below:
Code: Select all
AuthorNode node = ...;
AuthorParentNode parent = (AuthorParentNode) node.getParent();
List<AuthorNode> siblings = parent.getContentNodes();
Best,
Cristian
-
- Posts: 68
- Joined: Mon Jul 04, 2022 8:42 am
Re: How to find next node
Hi Cristian,
Actually our requirement is to place the Image Print figure tag below the Image Online figure tag. Below is the example.
<venue.name>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="print">Image print</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="print">Image print</embedded.figure.reference></figure>
</venue.name>
Say now we have 3 Image online tags in the document and i want to insert Print tag below the each of the online tag.
Before inserting i need to verify weather print tag already exist or not.
<venue.name>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
</venue.name>
first we are getting all the Online nodes by xpath //figure and then we are iterating the first node say first tag is Online tag, and then here we need to verify what is next node how to do that?
suppose when we write below code to fetch next code then instead of next node(figure) its giving <venue.name> node
AuthorNode nextNode = docCtrl.getNodeAtOffset(node.getEndOffset()+1);
Please suggest on this.
Actually our requirement is to place the Image Print figure tag below the Image Online figure tag. Below is the example.
<venue.name>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="print">Image print</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="print">Image print</embedded.figure.reference></figure>
</venue.name>
Say now we have 3 Image online tags in the document and i want to insert Print tag below the each of the online tag.
Before inserting i need to verify weather print tag already exist or not.
<venue.name>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
<figure><embedded.figure.reference rendition-type="online">Image Online</embedded.figure.reference></figure>
</venue.name>
first we are getting all the Online nodes by xpath //figure and then we are iterating the first node say first tag is Online tag, and then here we need to verify what is next node how to do that?
suppose when we write below code to fetch next code then instead of next node(figure) its giving <venue.name> node
AuthorNode nextNode = docCtrl.getNodeAtOffset(node.getEndOffset()+1);
Please suggest on this.
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: How to find next node
Post by cristi_talau »
Hello,
The code that I included in the first reply can be continued to return the next sibling.
node.getEndOffset() is inclusive, this means that it returns the offset before the end tag of the node. So "node.getEndOffset()+1" returns the offset after the end tag, which is included in the "venue.name" element. For this example, "node.getEndOffset()+2" is in the next figure element.
Best,
Cristian
The code that I included in the first reply can be continued to return the next sibling.
node.getEndOffset() is inclusive, this means that it returns the offset before the end tag of the node. So "node.getEndOffset()+1" returns the offset after the end tag, which is included in the "venue.name" element. For this example, "node.getEndOffset()+2" is in the next figure element.
Best,
Cristian
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