Revision 479 tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/teitxm/Xml2Ana.groovy

Xml2Ana.groovy (revision 479)
21 21
//
22 22
//
23 23
//
24
// $LastChangedDate: 2016-06-14 10:33:10 +0200 (Tue, 14 Jun 2016) $
25
// $LastChangedRevision: 3234 $
24
// $LastChangedDate: 2017-04-19 16:23:38 +0200 (mer. 19 avril 2017) $
25
// $LastChangedRevision: 3430 $
26 26
// $LastChangedBy: mdecorde $
27 27
//
28 28
package org.txm.scripts.teitxm;
29 29

  
30 30
import org.txm.importer.HasElement;
31 31
import org.txm.importer.StaxIdentityParser;
32

  
32 33
import java.text.DateFormat;
33 34
import java.util.ArrayList;
34 35
import java.util.Date;
35 36
import java.util.HashMap;
36 37
import java.util.Locale;
38

  
37 39
import javax.xml.stream.*;
40

  
38 41
import java.net.URL;
42

  
39 43
import org.txm.importer.filters.*;
44
import org.txm.utils.AsciiUtils;
40 45

  
41 46
// TODO: Auto-generated Javadoc
42 47
/**
......
99 104
		super(file.toURI().toURL());
100 105
		//File file = new File(url.getFile()).getAbsoluteFile()
101 106
		textname = file.getName();
102
		int idx = textname.indexOf(".");
107
		int idx = textname.lastIndexOf(".");
103 108
		if (idx > 0)
104 109
			textname = textname.substring(0, idx)
105 110

  
......
169 174
						String corresptype = correspType.get(type);
170 175
						String ref = correspRef.get(type);
171 176
						anabalises.add(["#"+ref, "#"+corresptype, value]);
172
					} else if (type == ID) {// keep attribute id
177
					} else if (type == ID) { // keep id attribute 
173 178
						String wordid = value
174 179
						if (wordid.startsWith("w")) {
175 180
							if (!wordid.startsWith("w_"))
......
178 183
//						else {
179 184
//							wordid = "w_"+textname+"_"+wordid;
180 185
//						}
181

  
186
						
187
						wordid = AsciiUtils.buildAttributeId(wordid); // remove characters not compatible with the id attribute value
188
						
182 189
						writer.writeAttribute(type, wordid);
190
						
183 191
					} else { // add attributes that was in the original <w>
184 192
						if (convertAllAttributes)
185 193
							anabalises.add(["none","#"+type, value])

Also available in: Unified diff