sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Desruisseaux (JIRA)" <j...@apache.org>
Subject [jira] [Created] (SIS-153) XML marshalling of country codes shall use ISO 3166 alpha-2 (not alpha-3)
Date Sat, 14 Dec 2013 18:14:06 GMT
Martin Desruisseaux created SIS-153:
---------------------------------------

             Summary: XML marshalling of country codes shall use ISO 3166 alpha-2 (not alpha-3)
                 Key: SIS-153
                 URL: https://issues.apache.org/jira/browse/SIS-153
             Project: Spatial Information Systems
          Issue Type: Bug
          Components: Utilities
    Affects Versions: 0.3
            Reporter: Martin Desruisseaux
            Assignee: Martin Desruisseaux
             Fix For: 0.4


{{java.util.Locale}} can represent language and country codes using 2 letters or 3 letters
codes. Conversions from 2 to 3 letters codes are performed by the {{Locale.getISO3Language()}}
and {{Locale.getISO3Country()}} methods.

When marshalling an ISO 19139 document, Apache SIS 0.3 uses the 3 letters variant in both
cases. However this cause SIS to be unable to unmarshal its own documents, because the {{java.util.Locale}}
does not recognize 3 letters country codes. Example:

{code:java}
Locale locale = new Locale("en", "GB");
System.out.println(locale.getLanguage());        // Prints "en"
System.out.println(locale.getISO3Language());    // Prints "eng"
System.out.println(locale.getDisplayLanguage()); // Prints "anglais" on a French system.
System.out.println(locale.getCountry());         // Prints "GB"
System.out.println(locale.getISO3Country());     // Prints "GBR"
System.out.println(locale.getDisplayCountry());  // Prints "Royaume-Uni" on a French system.

locale = new Locale("eng", "GBR");               // GBR is the 3 letters code for GB
System.out.println(locale.getLanguage());        // Prints "eng"
System.out.println(locale.getISO3Language());    // Prints "eng"
System.out.println(locale.getDisplayLanguage()); // Prints "anglais" on a French system.
System.out.println(locale.getCountry());         // Prints "GBR"
System.out.println(locale.getISO3Country());     // MissingResourceException: Couldn't find
3-letter country code for GBR
{code}

Note that this behaviour is consistent with {{java.util.Locale}} javadoc. Looking at what
OGC/ISO does on [schemas.opengis.net|http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml],
we can see that they use:

* 3 letters codes for languages
* 2 letters code for countries

We should align Apache SIS 0.4 on the same practice. This would allow SIS to unmarshal its
own documents. However this would not solve the issue when reading a document from an other
producer using the 3 letters country codes. For now we hope that those cases are rare...

Note that this JIRA task is about the country code only. Leaving the language codes as 3 letters
codes leaves an other issue: while {{java.util.Locale}} works fine with them, we did not verified
if {{java.util.ResourceBundle}} is capable to convert back to 2 letters language codes before
to lookup for resources.




--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

Mime
View raw message