Révision 2958
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/BuildAFMetadataMacro.groovy (revision 2958) | ||
---|---|---|
57 | 57 |
|
58 | 58 |
searchAndReplaceRules.put("textorder", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3$2$1'] as String[]); // not working yet |
59 | 59 |
|
60 |
|
|
61 |
|
|
60 | 62 |
process(excel, table2File, lineRules, columnsSelection, columnsToCopy, searchAndReplaceRules, columnsToRenameRules, normalizeSearchAndReplacePattern, dateColumnsSelection, datePattern) |
61 | 63 |
} |
62 | 64 |
|
tmp/org.txm.core/src/java/org/txm/metadatas/Metadatas.java (revision 2958) | ||
---|---|---|
223 | 223 |
// if(!headers[i].equals("id"))// the first |
224 | 224 |
// { |
225 | 225 |
writer.writeStartElement("metadata"); |
226 |
writer.writeAttribute("id", AsciiUtils.buildId(headers.get(i))); |
|
226 |
writer.writeAttribute("id", AsciiUtils.buildAttributeId(headers.get(i)));
|
|
227 | 227 |
writer.writeAttribute("shortname", headers.get(i)); |
228 | 228 |
writer.writeAttribute("longname", headers.get(i)); |
229 | 229 |
writer.writeAttribute("type", "String"); |
... | ... | |
479 | 479 |
// if(!headers[i].equals("id"))// the first |
480 | 480 |
// { |
481 | 481 |
writer.writeStartElement("metadata"); |
482 |
writer.writeAttribute("id", AsciiUtils.buildId(headers[i])); |
|
482 |
writer.writeAttribute("id", AsciiUtils.buildAttributeId(headers[i]));
|
|
483 | 483 |
writer.writeAttribute("shortname", headers[i]); |
484 | 484 |
writer.writeAttribute("longname", longnames[i]); |
485 | 485 |
writer.writeAttribute("type", types[i]); |
... | ... | |
510 | 510 |
for (int i = 0; i < headers.length; i++) |
511 | 511 |
if (!headers[i].equals("id") && !headers[i].equals("xpath")) { |
512 | 512 |
writer.writeEmptyElement("entry"); |
513 |
writer.writeAttribute("id", AsciiUtils.buildId(headers[i])); |
|
513 |
writer.writeAttribute("id", AsciiUtils.buildAttributeId(headers[i]));
|
|
514 | 514 |
String value = reader.get(headers[i]); |
515 | 515 |
if (value.length() == 0) |
516 | 516 |
writer.writeAttribute("value", "N/A"); |
... | ... | |
628 | 628 |
|
629 | 629 |
// ensure attribute names format |
630 | 630 |
for (org.txm.metadatas.Entry e : metas) { |
631 |
e.o1 = AsciiUtils.buildId(e.o1); |
|
631 |
e.o1 = AsciiUtils.buildAttributeId(e.o1);
|
|
632 | 632 |
} |
633 | 633 |
|
634 | 634 |
AddAttributeInXml builder = new AddAttributeInXml(infile, tag, metas); |
tmp/org.txm.utils/src/org/txm/utils/AsciiUtils.java (revision 2958) | ||
---|---|---|
77 | 77 |
|
78 | 78 |
public static Transliterator asciiFormmater = Transliterator.getInstance("Any-Latin; NFD; [^\\p{Alnum}\\p{p}] Remove"); |
79 | 79 |
|
80 |
// remove accentued from a string and replace with ascii equivalent |
|
81 | 80 |
/** |
82 | 81 |
* Convert non ascii characters. Warning punctuations are not removed |
83 | 82 |
* |
... | ... | |
172 | 171 |
if (s.length() == 0) { |
173 | 172 |
return s; |
174 | 173 |
} |
175 |
|
|
176 |
String rez = convertNonAscii(s).toLowerCase(); |
|
177 |
rez = rez.replaceAll("\\p{Space}++", "_"); |
|
174 |
String rez = s.replaceAll("\\p{Space}++", "_"); |
|
178 | 175 |
rez = rez.replaceAll("_", "-"); |
176 |
rez = convertNonAscii(rez).toLowerCase(); |
|
177 |
|
|
179 | 178 |
rez = rez.replaceAll("[¤€§µ£°().,;:/?!@§%\\\\\"’ʹ'*+\\}\\]\\[{#~&]", ""); //$NON-NLS-1$ //$NON-NLS-2$ |
180 | 179 |
// remove first chars if number |
181 | 180 |
char c = rez.charAt(0); |
... | ... | |
197 | 196 |
* the arguments |
198 | 197 |
*/ |
199 | 198 |
public static void main(String args[]) { |
200 |
String s = "01The result : _ тврьдо È,É,Ê,Ë,Û,Ù,Ï,Î,À,Â,Ô,è,é,ê,ë,û,ù,ï,î,à,â,ô,ç 0 1 2 3 4 5 6 7 8 9 10"; //$NON-NLS-1$ |
|
199 |
String s = "01The result : - - _ тврьдо È,É,Ê,Ë,Û,Ù,Ï,Î,À,Â,Ô,è,é,ê,ë,û,ù,ï,î,à,â,ô,ç 0 1 2 3 4 5 6 7 8 9 10"; //$NON-NLS-1$
|
|
201 | 200 |
System.out.println(AsciiUtils.convertNonAscii(s)); |
202 | 201 |
//System.out.println(AsciiUtils.buildId(s)); |
203 | 202 |
String s2 = "w_ТВРЬДОтврьдо_123&é\"'(-è_çà)=/*-+~#{[|`\\^@]}¤;:!§/.?µ%£°"; |
Formats disponibles : Unified diff