accessing text in Text Mode
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 10
- Joined: Tue May 27, 2014 10:00 am
accessing text in Text Mode
Hi,
is there a recommended way to get the text content of a document in Text mode, similar to what TextContentIterator does in Author mode?
I see I could just parse the XML myself, but I'm trying to write a grammar checker for text mode, so I'd need to re-parse the whole XML on almost every key press (to underline mistakes as they are typed) and I'm afraid that becomes too slow.
I'm using Oxygen Author 16.0 but I can update to 16.1 if needed.
Regards
Daniel
is there a recommended way to get the text content of a document in Text mode, similar to what TextContentIterator does in Author mode?
I see I could just parse the XML myself, but I'm trying to write a grammar checker for text mode, so I'd need to re-parse the whole XML on almost every key press (to underline mistakes as they are typed) and I'm afraid that becomes too slow.
I'm using Oxygen Author 16.0 but I can update to 16.1 if needed.
Regards
Daniel
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: accessing text in Text Mode
Dear Daniel,
I will assume you are writing the customization for the standalone editor and not for the Oxygen Eclipse plugin.
So you are probably using the ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextEditorPage API to access the text page.
Unfortunately for the text page we do not have a fixed hierarchy of nodes and the API can mostly return the Swing JTextArea WSTextEditorPage.getTextComponent() and the Swing document WSTextEditorPage.getDocument().
So you would need to have your own small parser.
But sending to a grammar checker the entire text content of the document every time a key is pressed is a bad idea in terms of performance, either when working in the Text or the Author editing modes.
Here are some possible solutions:
1) Instead of automatic grammar checking have a custom manual grammar checking toolbar button which checks the entire document when pressed.
2) The auto spell checker functionality in Oxygen works by spell checking only the content in the visible area each time the user presses a key. As you have access to the JTextArea, you can gain access to its JScrollPane and obtain the visible rectangle, then try to parse and send to the checker only the text content which is visible in the visible rectangle.
Regards,
Radu
I will assume you are writing the customization for the standalone editor and not for the Oxygen Eclipse plugin.
So you are probably using the ro.sync.exml.workspace.api.editor.page.text.xml.WSXMLTextEditorPage API to access the text page.
Unfortunately for the text page we do not have a fixed hierarchy of nodes and the API can mostly return the Swing JTextArea WSTextEditorPage.getTextComponent() and the Swing document WSTextEditorPage.getDocument().
So you would need to have your own small parser.
But sending to a grammar checker the entire text content of the document every time a key is pressed is a bad idea in terms of performance, either when working in the Text or the Author editing modes.
Here are some possible solutions:
1) Instead of automatic grammar checking have a custom manual grammar checking toolbar button which checks the entire document when pressed.
2) The auto spell checker functionality in Oxygen works by spell checking only the content in the visible area each time the user presses a key. As you have access to the JTextArea, you can gain access to its JScrollPane and obtain the visible rectangle, then try to parse and send to the checker only the text content which is visible in the visible rectangle.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: accessing text in Text Mode
Hi,
One more thing, for spell checking instead of using the text content iterator in the Author mode API you could have used:
AuthorDocumentController.getFilteredContent(int, int, AuthorNodesFilter)
It's Javadoc says something like:
We created this API specifically for spell/grammar checking.
Regards,
Radu
One more thing, for spell checking instead of using the text content iterator in the Author mode API you could have used:
AuthorDocumentController.getFilteredContent(int, int, AuthorNodesFilter)
It's Javadoc says something like:
That filtered content has a method AuthorFilteredContent.getOriginalOffset(int) which maps an offset in the checked content to an actual offset in the Author document.* Retrieves the content between the given start and end offset, excluding the
* content of the invisible nodes (that have display none style property), the
* content deleted with track changes, the sentinels of inline elements and the
* content of filtered nodes
We created this API specifically for spell/grammar checking.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
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