Page 1 of 1

TextContentIterator return processing instructions?

Posted: Wed Apr 08, 2015 12:46 pm
by daniel7
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

Re: TextContentIterator return processing instructions?

Posted: Wed Apr 08, 2015 1:57 pm
by alex_jitianu
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

Re: TextContentIterator return processing instructions?

Posted: Wed Apr 08, 2015 2:58 pm
by daniel7
alex_jitianu wrote: You can check the context node and skip PIs like this:
Thanks, that's working nicely.