Home Forums General XMetaL Discussion Using xml:lang Values to Control Spell Checking Reply To: Using xml:lang Values to Control Spell Checking

MrPaul

Reply to: Using xml:lang Values to Control Spell Checking

Derek,

Some of our documents have mixed languages. Mainly, I need to be able to switch between “en-ce” and “fr-cf” depending on the current position of the cursor (we have a custom spell checking module that loops through the document using a range and calls XMAX spell checking functionality). In our XML, the different language sections have a lang=1 or lang=2 attribute that I can use to determine which spell checker dictionary to use.

My question is: in which XMAX call does the value of xml:lang get read to determine if the word is spelled correctly or not? Is it inside the call to ActiveDocument.IsSpellingCorrect()? Is it a bad idea to continuously change the value of the document's doctype on the fly?

I tried testing this but using the example you provided, I am getting an “attribute exists” exception from XMAX the 2nd time it tries to set the value (since the code that checks if the word is spelled correctly loops as the range changes its selection).

Also, the first time it's added, when I view the ActiveDocument.Document.xml value, I cannot see the set xml:lang attribute. Is that normal?

Can I call docType.addAttribute with an element that isn't the root (in the 1st param)? How should I go about this?

Thank you.

EDIT: Just to add to this, if I check docType.hasAttribute(“Root”, “xml:lang”) before adding it, it will properly return false the 1st time, then true the 2nd time as to not re-add it. However, when I get to a section in the XML that is in a different language, I'd like to update this value. What's weird is that docType.attributes is empty and there doesn't seem to be a “updateAttribute” or other similar function. And again, if I re-call docType.addAttribute, it crashes with the error: “attribute exists.”. I tried playing with the intDeclType param in addAttribute (I noticed you set this to sqDTFIXED or 3 in your example) but to no avail.
The good news is that when the xml:lang attribute is set to the value “en-ce” or “fr-cf”, the proper dictionaries are used! I just need to be able to update this dynamically.

Reply

Products
Downloads
Support