How to get marker content

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
manojdcoder
Posts: 67
Joined: Thu Oct 29, 2020 12:01 am

How to get marker content

Post by manojdcoder »

When a change marker is being removed, I would like to read the content of the marker. The code below gives me the plain text between the offsets, is it possible to get the actual XML content thats being removed or added by marker Or perhaps the HTML content in editor for this marker?

Code: Select all

Segment chars = new Segment();
model.getAuthorDocumentController().getChars(highlight.getStartOffset(), (highlight.getEndOffset() - highlight.getStartOffset()) + 1, chars);
data.put(RESPONSE_ATTRIBUTE_CONTENT, chars.toString());
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: How to get marker content

Post by cristi_talau »

Hello,

To get an XML representation you can use the AuthorDocumentController.createDocumentFragment() API. This returns an AuthorDocumentFragment that you can traverse and generate the XML text.

To get an HTML representation, you can use the "copy-as-html" feature, but without setting the user clipboard. This requires you to us a code as below:

Code: Select all

AuthorSelectionAndCaretModel selectionModel = authorDocModel.getSelectionModel();
selectionModel.moveTo(start);
selectionModel.moveTo(end, true);
AuthorClipboardObject clipboardObject = authorDocModel.getActionsSupport().handleCopy();
clipboardObject.getHtmlContent();
Best,
Cristian
manojdcoder
Posts: 67
Joined: Thu Oct 29, 2020 12:01 am

Re: How to get marker content

Post by manojdcoder »

From the fragment, we get access to all first level AuthorNode(s), not sure how to traverse through child nodes from there. Any pointers?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: How to get marker content

Post by cristi_talau »

Depending on the node's getType() result, you can cast it to AuthorParentNode and use getContentNodes() to access children.
Post Reply