TextContentIterator return processing instructions?

Post here questions and problems related to oXygen frameworks/document types.
daniel7
Posts: 10

TextContentIterator return processing instructions?

Wed Apr 08, 2015 12:46 pm

Hi,

I'm using Oxygen Author 16.1, build 2015012213 with code like this:

Code: Select all

AuthorDocumentController docController = authorEditorPage.getDocumentController();
AuthorDocument authorDocumentNode = docController.getAuthorDocumentNode();
TextContentIterator textContentIterator =
  docController.getTextContentIterator(0, docController.getAuthorDocumentNode().getEndOffset());
while (textContentIterator.hasNext()) {
  System.out.println(textContentIterator.next().getText());
}


Other than the text, I also get back this:

Code: Select all

xml-stylesheet type="text/css" href="/lt/rules.css" title="..."


obviously it comes from the PI in my XML:

Code: Select all

<?xml-stylesheet type="text/css" href="/lt/rules.css" title="..."?>


Is the TextContentIterator supposed to return PIs? I'd like to have the text without PIs.

Regards
Daniel
alex_jitianu
Posts: 603

Re: TextContentIterator return processing instructions?

Wed Apr 08, 2015 1:57 pm

Hello Daniel,

You can check the context node and skip PIs like this:

Code: Select all

TextContext next = textContentIterator.next();
AuthorNode nodeAtOffset = docController.getNodeAtOffset(next.getTextEndOffset());
if (nodeAtOffset.getType() != AuthorNode.NODE_TYPE_PI) {
  System.out.println(next.getText());
}


Best regards,
Alex
daniel7
Posts: 10

Re: TextContentIterator return processing instructions?

Wed Apr 08, 2015 2:58 pm

alex_jitianu wrote:You can check the context node and skip PIs like this:


Thanks, that's working nicely.

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 2 guests