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

Derek Read

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

The DTD should be extended using addAttribute() in the event On_DTD_Open_Complete. It is best to not try to continuously modify the DTD. I can't see why that would be necessary, but perhaps I misunderstand.

You can specify any element in the addAttribute() API and that element will then allow the new attribute. I merely suggested the root element because (given what I know about your usage of XMAX) my assumption was that your documents would only use one language. You will need to call it for every element you wish to allow the attribute on.

If you need to switch the value for these elements or allow different values (for example: you want

to support xml:lang but the value for that attribute needs to be changeable) then you should not define the attribute as #FIXED (as in my previous example). Most likely you would want to create it as a CDATA #IMPLIED attribute. Here's an example:

//XMetaL Script Language JScript:
var elements = [“myElem1″,”myElem2″,”myElem3”];
for(i=0;i  var docType = ActiveDocument.doctype;
  docType.addAttribute(elements, “xml:lang”, “xml:lang”, 0, 0);
}

You will then need to have additional code that walks through the document to figure out which element should be CDN English and which should be CDN French and then set xml:lang appropriately. I'm sure how you are currently keeping track of the language but it sounds like you have other attributes for that. This could be done in On_Document_Open_Complete or anytime after the document is open. It could be in an MCR file (if you want to use XMAX events) or you might include it in your hosting application's own events.

Note: You should not repeatedly call addAttribute on the same element for a given DocType. You should only run this API to add the attribute definition to any element for a given DocType (DTD) once. I think this is normally pretty easy to manage (as in my example above).

Please keep in mind that although we're using standard and well-tested APIs here we are using them to work around limitations in the spell checking engine, so their usage for this particular context is not tested.

Reply

Products
Downloads
Support