The version and xmlns
namespace declaration attributes are static values, so nothing exciting to see
there, as usual. The xml:lang attribute, however,
is required, and must reflect the language of the entries contained in the
lexicon. Here we’re declaring that all the entries are in English.
The root would normally contain many more lexeme
elements than in this example, as each defines the word(s) the rule applies to
in the child grapheme element(s). (Graphemes, of
course, don’t have to take the form of words, but for simplicity of explanation
I’ll stick to the general concept.) When the string is matched, the
pronunciation in the phoneme element gets rendered
in place of the default rendering the engine would have performed.
Or, if it helps conceptualize, when the word “acetaminophen” is encountered in the prose, before passing the word to the rendering engine to voice, an internal lookup of the defined graphemes occurs. Because we’ve defined a match, the phoneme and the alphabet it adheres to are swapped in instead for voicing.
That you can include multiple graphemes may not seem immediately useful, but it enables you to create a single entry for regional variations in spelling, for example. British and American variants of “defense” could be defined in a single rule as:
<lexeme>
<grapheme>defense</grapheme>
<grapheme>defence</grapheme>
<phoneme>dI'fEns</phoneme>
</lexeme>
It is similarly possible to define more than one pronunciation by adding multiple
phoneme elements. We could add the IPA spelling
to the last example as follows, in case reading systems end up only supporting
one or the other alphabet:
<lexeme>
<grapheme>defense</grapheme>
<grapheme>defence</grapheme>
<phoneme>dI'fEns</phoneme>
<phoneme alphabet="ipa">dɪˈfɛns</phoneme>
</lexeme>
The alphabet attribute on the new phoneme element is required because its spelling
doesn’t conform to the default defined on the root. If the rendering engine
doesn’t support X-SAMPA, it could now possibly make use of this embedded IPA
version instead.
The phoneme doesn’t have to be in another alphabet, however; you could add a regional dialect as a secondary pronunciation, for example. The specification unfortunately doesn’t provide any mechanisms to indicate why you’ve included such additional pronunciations or when they should be used, so there’s not much value in doing so at this time.
There’s much more to creating PLS files than can be covered here, of course, but you’re now versed in the basics and ready to start compiling your own lexicons. You only need to attach your PLS file to your publication to complete the process of enhancing your ebook.