TextContentIterator return processing instructions?

Post here questions and problems related to oXygen frameworks/document types.
daniel7
Posts: 10
Joined: Tue May 27, 2014 10:00 am

TextContentIterator return processing instructions?

Post by daniel7 » 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: 663
Joined: Wed Nov 16, 2005 11:11 am

Re: TextContentIterator return processing instructions?

Post by alex_jitianu » 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
Joined: Tue May 27, 2014 10:00 am

Re: TextContentIterator return processing instructions?

Post by daniel7 » 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.

Post Reply