From 590794d27fc46553bbd8a2c851e682b74d2e9a4f Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Mon, 11 Oct 2004 23:38:03 +0000 Subject: [PATCH] ICU-2055 Fix bunch of bugs and make sure ICU data is correctly generated from CLDR X-SVN-Rev: 16452 --- .../icu/dev/tool/cldr/LDML2ICUConverter.java | 290 +++++++++++------- .../ibm/icu/dev/tool/cldr/LDMLConstants.java | 1 + .../ibm/icu/dev/tool/cldr/LDMLUtilities.java | 20 ++ 3 files changed, 194 insertions(+), 117 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java index 8fb5a5e3417..01f93674ea7 100644 --- a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java +++ b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDML2ICUConverter.java @@ -391,9 +391,7 @@ public class LDML2ICUConverter { private ICUResourceWriter.Resource parseCurrencyFraction(Node root, StringBuffer xpath){ ICUResourceWriter.ResourceTable table = new ICUResourceWriter.ResourceTable(); ICUResourceWriter.Resource current = null; - int savedLength = xpath.length(); - getXPath(root, xpath); - int oldLength = xpath.length(); + if(isDraft(root, xpath)&& !writeDraft){ return null; } @@ -401,6 +399,10 @@ public class LDML2ICUConverter { if(isAlternate(root)){ return null; } + int savedLength = xpath.length(); + getXPath(root, xpath); + int oldLength = xpath.length(); + table.name = (String) keyNameMap.get(root.getNodeName()); for(Node node=root.getFirstChild(); node!=null; node=node.getNextSibling()){ @@ -459,9 +461,7 @@ public class LDML2ICUConverter { private ICUResourceWriter.Resource parseCurrencyRegion(Node root, StringBuffer xpath){ ICUResourceWriter.ResourceTable table = new ICUResourceWriter.ResourceTable(); ICUResourceWriter.Resource current = null; - int savedLength = xpath.length(); - getXPath(root, xpath); - int oldLength = xpath.length(); + if(isDraft(root, xpath)&& !writeDraft){ return null; } @@ -469,6 +469,9 @@ public class LDML2ICUConverter { if(isAlternate(root)){ return null; } + int savedLength = xpath.length(); + getXPath(root, xpath); + int oldLength = xpath.length(); table.name = (String) keyNameMap.get(root.getNodeName()); for(Node node=root.getFirstChild(); node!=null; node=node.getNextSibling()){ @@ -527,9 +530,7 @@ public class LDML2ICUConverter { private ICUResourceWriter.Resource parseCurrencyData(Node root, StringBuffer xpath){ ICUResourceWriter.Resource first = null; ICUResourceWriter.Resource current = null; - int savedLength = xpath.length(); - getXPath(root, xpath); - int oldLength = xpath.length(); + if(isDraft(root, xpath)&& !writeDraft){ return null; } @@ -537,6 +538,9 @@ public class LDML2ICUConverter { if(isAlternate(root)){ return null; } + int savedLength = xpath.length(); + getXPath(root, xpath); + int oldLength = xpath.length(); for(Node node=root.getFirstChild(); node!=null; node=node.getNextSibling()){ if(node.getNodeType()!=Node.ELEMENT_NODE){ continue; @@ -795,13 +799,14 @@ public class LDML2ICUConverter { private ICUResourceWriter.Resource parseLocaleDisplayNames(Node root, StringBuffer xpath){ ICUResourceWriter.Resource first = null; ICUResourceWriter.Resource current = null; - int savedLength = xpath.length(); - getXPath(root,xpath); - int oldLength = xpath.length(); + // the locale display names are maked draft if(isDraft(root, xpath)&& !writeDraft){ return null; } + int savedLength = xpath.length(); + getXPath(root,xpath); + int oldLength = xpath.length(); for(Node node=root.getFirstChild(); node!=null; node=node.getNextSibling()){ if(node.getNodeType()!=Node.ELEMENT_NODE){ continue; @@ -857,12 +862,7 @@ public class LDML2ICUConverter { if(list.getLength()!=0){ ICUResourceWriter.ResourceTable subTable = new ICUResourceWriter.ResourceTable(); subTable.name = registeredKeys[i]; - if(table.first==null){ - table.first = current = subTable; - }else{ - current.next = subTable; - current = (ICUResourceWriter.ResourceTable)current.next; - } + ICUResourceWriter.ResourceString currentString = null; for(int j=0; j0){ @@ -2067,9 +2094,13 @@ public class LDML2ICUConverter { Node node =null; for(int i =0; i0){ + ICUResourceWriter.ResourceTable table = new ICUResourceWriter.ResourceTable(); + ICUResourceWriter.Resource current=null; + table.name = LDMLConstants.VALID_SUBLOCALE; + for(int i=0; i "yi" HashMap fromXpathMap = new HashMap(); // ex: "th_TH_TRADITIONAL" -> "@some xpath.." - HashMap fromFiles = new HashMap(); // ex: "mt.xml" -> File . Ordinary XML source files - HashMap generatedAliasFiles = new HashMap(); // ex: th_TH_TRADITIONAL.xml -> File Files generated directly from the alias list. (no XML actually exists) - HashMap aliasFromFiles = new HashMap(); // ex: zh_MO.xml -> File Files which actually exist in LDML and contain aliases + Map fromFiles = new TreeMap(); // ex: "mt.xml" -> File . Ordinary XML source files + Map generatedAliasFiles = new TreeMap(); // ex: th_TH_TRADITIONAL.xml -> File Files generated directly from the alias list. (no XML actually exists) + Map aliasFromFiles = new TreeMap(); // ex: zh_MO.xml -> File Files which actually exist in LDML and contain aliases // 1. get the list of input XML files FileFilter myFilter = new FileFilter() { @@ -3492,7 +3548,7 @@ public class LDML2ICUConverter { for(Iterator e = files.values().iterator();e.hasNext();) { File f = (File)e.next(); if((++i%5)==0) { - out = out + "\\\n"; + out = out + "\\"+LINESEP; } out = out +(i==0?" ":" ") + (f.getName()).substring(0,f.getName().indexOf('.'))+".txt"; } diff --git a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLConstants.java b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLConstants.java index 892cdafc330..c031d3405fd 100644 --- a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLConstants.java +++ b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLConstants.java @@ -168,6 +168,7 @@ public class LDMLConstants { public static final String ROUNDING = "rounding"; public static final String REGION = "region"; public static final String ISO_3166 = "iso3166"; + public static final String VALID_SUBLOCALE = "validSubLocales"; } diff --git a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLUtilities.java b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLUtilities.java index e84b877be03..343ea401027 100644 --- a/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLUtilities.java +++ b/icu4j/src/com/ibm/icu/dev/tool/cldr/LDMLUtilities.java @@ -667,6 +667,26 @@ public class LDMLUtilities { } return false; } + + public static void appendAllAttributes(Node node, StringBuffer xpath){ + NamedNodeMap attr = node.getAttributes(); + int len = attr.getLength(); + if(len>0){ + xpath.append("["); + for(int i=0; i0){ + xpath.append(" and "); + } + Node item = attr.item(i); + xpath.append("@"); + xpath.append(item.getNodeName()); + xpath.append("='"); + xpath.append(item.getNodeValue()); + xpath.append("'"); + } + xpath.append("]"); + } + } /** * Appends the attribute values that make differentiate 2 siblings * in LDML