Issue 15224: OCL 2.2 11.5.3 What is a locale? (ocl2-rtf) Source: Model Driven Solutions (Dr. Edward Willink, ed(at)willink.me.uk) Nature: Uncategorized Issue Severity: Summary: The new toUpperCase, toLowerCase and equalsIgnoreCase refer to case conversion if appropriate to the locale without ever defining what a locale is or defining the preconditions for appropriateness. These methods closely resemble Java Library methods, perhaps they should reference rather than duplicate the Java specification. The Java toUpperCase method provides locale-dependent and local-independent variants. Is it right for OCL to make it difficult to achieve predictable results under a Turkish locale? It seems that the OCL standard library must provide access to the Locale and provide both Java's toUpperCase variants. Resolution: Revised Text: At the end of 11.1 add Certain String operations depend on the prevailing locale to ensure that Strings are collated and characters are caseconverted in an appropriate fashion. A locale is defined as a concatenation of up to three character sequences separated by underscores, with the first sequence identifying the language and the second sequence identifying the country. The third sequence is empty but may encode an implementation-specific variant. Trailing empty strings and separators may be omitted. The character sequences for languages are defined by ISO 639. The character sequences for countries are defined by ISO 3166. 'fr_CA' therefore identifies the locale for the French language in the Canada country. Comparison of strings and consequently the collation order of Collection::sortedBy() conforms to the Unicode Collation algorithm defined by Unicode Technical Standard#10. The locale is 'en_us' by default but may be configured by a property constraint on OclAny::oclLocale. The prevailing locale is defined by the prevailing value of oclLocale within the current environment; it may therefore be changed temporarily by using a Let expression. let oclLocale : String = 'fr_CA' in aString.toUpperCase() At the end of 11.2.5 add oclLocale : String Defines the default locale for local-dependent library operations such as String::toUpperCase(). In 11.4.3 String add < (s : String) : Boolean True if self is less than s, using the locale defined by looking up oclLocale in the current environment. > (s : String) : Boolean True if self is greater than s, using the locale defined by looking up oclLocale in the current environment. post: result = not (self <= s) <= (s : String) : Boolean True if self is less than or equal to s, using the locale defined by looking up oclLocale in the current environment. post: result = ((self = s) or (self < s)) >= (s : String) : Boolean True if self is greater than or equal to s, using the locale defined by looking up oclLocale in the current environment. post: result = ((self = s) or (self > s)) In 11.4.3 String toUpperCase() replace if appropriate to the locale by using the locale defined by looking up oclLocale in the current environment. In 11.4.3 String toLowerCase() replace if appropriate to the locale by using the locale defined by looking up oclLocale in the current environment. Actions taken: April 23, 2010: received issue April 25, 2011: closed issue Discussion: Introduction of a Locale class into the OCL Standard Library to allow a Locale to be passed as an additional argument to all locale-dependent functions is a rather heavyweight solution to this problem. It seems much simpler to define OclAny::oclLocale as the default locale, with oclLocale in the current context as the prevailing locale so that users may temporarily change locale using a let expression. (Issue 15134 corrects the 'locale' reference in equalsIgnoreCase). End of Annotations:===== ronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkIFAJM00UvUnw4U/2dsb2JhbACQK4t/cb0khQsE Date: Fri, 23 Apr 2010 13:52:34 +0100 From: Ed Willink User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 To: issues@omg.org Subject: OCL 2.2 11.5.3 What is a locale? X-Plusnet-Relay: 621d2f72dc388cea023f7976890c0f77 Hi The new toUpperCase, toLowerCase and equalsIgnoreCase refer to case conversion if appropriate to the locale without ever defining what a locale is or defining the preconditions for appropriateness. These methods closely resemble Java Library methods, perhaps they should reference rather than duplicate the Java specification. The Java toUpperCase method provides locale-dependent and local-independent variants. Is it right for OCL to make it difficult to achieve predictable results under a Turkish locale? It seems that the OCL standard library must provide access to the Locale and provide both Java's toUpperCase variants. Regards Ed Willink