Spell checker


This page is obsolete and available for historical purposes only.

Overview

You typically use the spell checker component by placing it next to a control, for instance next to a text area:

<xforms:textarea ref="."/>
<fr:spell-checker ref="."/>

You bind the component to the node that contains the text you want to check. On the page, the component will show as an icon (here next to a text area):


When users click on the icon, the spell checker dialog becomes visible, allowing them to make corrections:



As with the <xxforms:dialog>, set the close="false" attribute if you don't want the spell checker dialog to have a "x" on the toolbar, allowing users to close the dialog. If you don't set the close="false" attribute, the "x" in the title bar acts a sort of cancel: when pressed, changes users may have made with the spell checker will be undone, and the value of the node to which the spell checker is bound will be left unchanged.

Configuration

Icon

You can change the spell checker icon () by overriding the definition provided by the component for the CSS class xbl-fr-spell-checker-icon, for instance:

.xbl-fr-spell-checker .xbl-fr-spell-checker-icon { 
    background-image: url('../../../path/to/my/icon.png'); 
    display: inline-block; 
    width: 16px; height: 16px 
}


Spell checker service

By default, the component uses the Google spell checker service. If you wish to use your own service, provide the end point for that service by setting the following property in your properties-local.xml:

<property as="xs:string" 
          name="oxf.xforms.xbl.fr.spell-checker.service"
          value="/path/to/service"/>

When the service is called, the following XML is posted to your service:

<spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="1">
    <text>Ths is a tst</text>
</spellrequest>

Your service only needs to use the content of <text> and can ignore the attributes on <spellrequest> which are always the same. Your service must respond with:

<spellresult>
    <c o="0" l="3" s="1">This Th's Thus Th HS</c>
    <c o="9" l="3" s="0">test tat ST St st</c>
</spellresult>

For each word that is misspelled, the response contains a <c> containing a space separated list of suggestions. The values of the attributes on <c> is as follows:
  • o: the zero-based offset of the misspelled word in the request.
  • l: the length of misspelled word.
  • s: how confident the spell checker is that the first suggestion is the right one (1 if very confident, 0 otherwise). At this point, this value isn't used by the spell checker.

Comments