Revision 3045

tmp/org.txm.core/src/java/org/txm/scripts/importer/StaxStackWriter.groovy (revision 3045)
8 8
import org.eclipse.core.runtime.Platform;
9 9

  
10 10
public class StaxStackWriter implements XMLStreamWriter {
11

  
11
	
12 12
	XMLStreamWriter writer;
13 13
	OutputStream output;
14 14
	def events = [];
......
31 31
		this.output = output
32 32
		this.writer = factory.createXMLStreamWriter(output, encoding);//create a new file
33 33
	}
34

  
34
	
35 35
	Charset UTF8 = Charset.forName("UTF-8");
36 36
	public void write(String txt) {
37 37
		output.write(txt.getBytes(UTF8))
......
44 44
		}
45 45
		events = [];
46 46
	}
47

  
47
	
48 48
	public void writeStartElements(def tagsToWrite) {
49 49
		for (String tag : tagsToWrite)
50 50
			writeStartElement(tag);
51 51
	}
52

  
52
	
53 53
	public def getTagStack() {
54 54
		return events;
55 55
	}
56

  
56
	
57 57
	@Override
58 58
	public void close () throws XMLStreamException {
59 59
		writer.close();
60 60
		output.close();
61 61
	}
62

  
62
	
63 63
	@Override
64 64
	public void flush () throws XMLStreamException {
65 65
		writer.flush();
66

  
67 66
	}
68

  
67
	
69 68
	@Override
70 69
	public NamespaceContext getNamespaceContext() {
71 70
		return writer.getNamespaceContext();
72 71
	}
73

  
72
	
74 73
	@Override
75 74
	public String getPrefix (String uri) throws XMLStreamException {
76 75
		return writer.getPrefix(uri);
77 76
	}
78

  
77
	
79 78
	@Override
80 79
	public Object getProperty (String name) throws IllegalArgumentException {
81 80
		return writer.getProperty(name);
82 81
	}
83

  
82
	
84 83
	@Override
85 84
	public void setDefaultNamespace (String uri) throws XMLStreamException {
86 85
		writer.setDefaultNamespace(uri);
87 86
	}
88

  
87
	
89 88
	@Override
90 89
	public void setNamespaceContext(NamespaceContext context)
91 90
	throws XMLStreamException {
92 91
		writer.setNamespaceContext(context);
93 92
	}
94

  
93
	
95 94
	@Override
96 95
	public void setPrefix (String prefix, String uri) throws XMLStreamException {
97 96
		writer.setPrefix(prefix, uri);
98 97
	}
99

  
98
	
100 99
	@Override
101 100
	public void writeAttribute (String localName, String value) throws XMLStreamException {
102 101
		writer.writeAttribute(localName, value);
103 102
	}
104

  
103
	
105 104
	@Override
106 105
	public void writeAttribute (String namespaceURI, String localName, String value) throws XMLStreamException {
107 106
		writer.writeAttribute(namespaceURI, localName, value);
108 107
	}
109

  
108
	
110 109
	@Override
111 110
	public void writeAttribute (String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
112 111
		writer.writeAttribute(prefix, namespaceURI, localName, value);
113 112
	}
114

  
113
	
115 114
	@Override
116 115
	public void writeCData (String data) throws XMLStreamException {
117 116
		writer.writeCData(data);
118 117
	}
119

  
118
	
120 119
	@Override
121 120
	public void writeCharacters (String text) throws XMLStreamException {
122 121
		writer.writeCharacters(text);
123 122
	}
124

  
123
	
125 124
	@Override
126 125
	public void writeCharacters (char[] text, int start, int len) throws XMLStreamException {
127 126
		writer.writeCharacters(text, start, len);
128 127
	}
129

  
128
	
130 129
	@Override
131 130
	public void writeComment (String data) throws XMLStreamException {
132 131
		writer.writeComment(data);
133 132
	}
134

  
133
	
135 134
	@Override
136 135
	public void writeDTD (String dtd) throws XMLStreamException {
137 136
		writer.writeDTD(dtd);
138 137
	}
139

  
138
	
140 139
	@Override
141 140
	public void writeDefaultNamespace(String namespaceURI)
142 141
	throws XMLStreamException {
143 142
		writer.writeDefaultNamespace(namespaceURI);
144 143
	}
145

  
144
	
145
	/**
146
	 * WARNING THE ELEMENT IS CLOSED
147
	 * @param localName
148
	 * @param text
149
	 * @throws XMLStreamException
150
	 */
146 151
	public void writeElement (String localName, String text) throws XMLStreamException {
147 152
		writer.writeStartElement(localName);
148 153
		writer.writeCharacters(text);
......
155 160
		writer.writeCharacters(text);
156 161
		writer.writeEndElement();
157 162
	}
158

  
163
	
159 164
	@Override
160 165
	public void writeEmptyElement (String localName) throws XMLStreamException {
161 166
		writer.writeEmptyElement(localName);
162 167
	}
163

  
168
	
164 169
	public void writeEmptyElement (String localName, def map) throws XMLStreamException {
165 170
		writer.writeEmptyElement(localName);
166 171
		for (def key : map.keySet())
167 172
			writeAttribute(key.toString(), map[key].toString());
168 173
	}
169

  
174
	
170 175
	@Override
171 176
	public void writeEmptyElement(String namespaceURI, String localName)
172 177
	throws XMLStreamException {
173 178
		writer.writeEmptyElement(namespaceURI, localName);
174 179
	}
175

  
180
	
176 181
	@Override
177 182
	public void writeEmptyElement (String prefix, String localName, String namespaceURI) throws XMLStreamException {
178 183
		writer.writeEmptyElement(prefix, localName, namespaceURI);
179 184
	}
180

  
185
	
181 186
	@Override
182 187
	public void writeEndDocument () throws XMLStreamException {
183 188
		writer.writeEndDocument();
184 189
	}
185

  
190
	
186 191
	@Override
187 192
	public void writeEndElement () throws XMLStreamException {
188 193
		writer.writeEndElement();
189 194
		events.remove(events.size()-1)
190 195
		if (debug) println "END: $events"
191

  
192 196
	}
193

  
197
	
194 198
	@Override
195 199
	public void writeEntityRef (String name) throws XMLStreamException {
196 200
		writer.writeEntityRef(name);
197 201
	}
198

  
202
	
199 203
	@Override
200 204
	public void writeNamespace(String prefix, String namespaceURI)
201 205
	throws XMLStreamException {
202 206
		writer.writeNamespace(prefix, namespaceURI);
203 207
	}
204

  
208
	
205 209
	@Override
206 210
	public void writeProcessingInstruction(String target)
207 211
	throws XMLStreamException {
208 212
		writer.writeProcessingInstruction(target);
209 213
	}
210

  
214
	
211 215
	@Override
212 216
	public void writeProcessingInstruction(String target, String data)
213 217
	throws XMLStreamException {
214 218
		writer.writeProcessingInstruction(target, data);
215 219
	}
216

  
220
	
217 221
	@Override
218 222
	public void writeStartDocument () throws XMLStreamException {
219 223
		writer.writeStartDocument();
220

  
221 224
	}
222

  
225
	
223 226
	@Override
224 227
	public void writeStartDocument (String version) throws XMLStreamException {
225 228
		writer.writeStartDocument(version);
226 229
	}
227

  
230
	
228 231
	@Override
229 232
	public void writeStartDocument(String encoding, String version)
230 233
	throws XMLStreamException {
231 234
		writer.writeStartDocument(encoding, version);
232 235
	}
233

  
236
	
234 237
	@Override
235 238
	public void writeStartElement (String localName) throws XMLStreamException {
236 239
		writer.writeStartElement(localName);
237 240
		events << localName
238 241
		if (debug) println "START $localName $events"
239

  
240 242
	}
241 243
	
242 244
	public void writeStartElement (String localName, def map) throws XMLStreamException {
......
245 247
			writeAttribute(key.toString(), map[key].toString());
246 248
		}
247 249
	}
248

  
250
	
249 251
	@Override
250 252
	public void writeStartElement(String namespaceURI, String localName)
251 253
	throws XMLStreamException {
......
253 255
		events << localName
254 256
		if (debug) println "START $localName $events"
255 257
	}
256

  
258
	
257 259
	@Override
258 260
	public void writeStartElement(String prefix, String localName,
259
	String namespaceURI) throws XMLStreamException {
261
			String namespaceURI) throws XMLStreamException {
260 262
		writer.writeStartElement(prefix, localName, namespaceURI);
261 263
		events << localName
262 264
		if (debug) println "START $localName $prefix $events"
tmp/org.txm.core/src/java/org/txm/xml/XMLParser.java (revision 3045)
252 252
		}
253 253
	}
254 254
	
255
	public final String getLocation() {
255
	/**
256
	 * 
257
	 * @param line show the line number
258
	 * @param col show the column number
259
	 * @param fullPath show the file full path
260
	 * 
261
	 * @return
262
	 */
263
	public String getLocation(boolean line, boolean col, boolean fullPath) {
264
		StringBuilder b = new StringBuilder();
256 265
		if (parser != null) {
257
			return "Line: " + parser.getLocation().getLineNumber() + " Col: " + parser.getLocation().getColumnNumber() + " of " + inputurl;
266
			
267
			if (line) b.append("Line: " + parser.getLocation().getLineNumber());
268
			
269
			if (col) {
270
				if (line) b.append(" ");
271
				b.append("Col: " + parser.getLocation().getLineNumber());
272
			}
273
			
274
			if (line || col) b.append(" ");
275
			
276
			if (fullPath) {
277
				b.append("in File:" + this.inputurl.toString());
278
			}
279
			else {
280
				b.append("in File:" + this.inputurl.getFile());
281
			}
282
			
283
			if (b.length() == 0) return parser.getLocation().toString();
258 284
		}
259
		return null;
285
		return b.toString();
260 286
	}
261 287
	
288
	public String getLocation() {
289
		return getLocation(true, true, true);
290
	}
291
	
262 292
	private Stack<LinkedHashMap<String, String>> attributesStack = new Stack<>();
263 293
	
264 294
	private final HashMap<String, String> popCurrentAttributes() {
tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java (revision 3045)
360 360
		}
361 361
	}
362 362
	
363
	/**
364
	 * 
365
	 * @param line show the line number
366
	 * @param col show the column number
367
	 * @param fullPath show the file full path
368
	 * 
369
	 * @return
370
	 */
371
	public String getLocation(boolean line, boolean col, boolean fullPath) {
372
		StringBuilder b = new StringBuilder();
373
		if (parser != null) {
374
			if (line) b.append("Line: " + parser.getLocation().getLineNumber());
375
			
376
			if (col) {
377
				if (line) b.append(" ");
378
				b.append("Col: " + parser.getLocation().getLineNumber());
379
			}
380
			
381
			if (line || col) b.append(" ");
382
			if (fullPath) {
383
				b.append("in File:" + this.inputurl.toString());
384
			}
385
			else {
386
				b.append("in File:" + this.inputurl.getFile());
387
			}
388
			
389
			if (b.length() == 0) return parser.getLocation().toString();
390
		}
391
		return b.toString();
392
	}
393
	
363 394
	public String getLocation() {
364
		if (parser != null)
365
			return "Line: " + parser.getLocation().getLineNumber() + " Col: " + parser.getLocation().getColumnNumber();
366
		return null;
395
		return getLocation(true, true, true);
367 396
	}
368 397
	
369 398
	protected void processNamespace() throws XMLStreamException {
tmp/org.txm.core/src/java/org/txm/importer/ApplyXsl2.java (revision 3045)
152 152
		tFactory = new net.sf.saxon.TransformerFactoryImpl();
153 153
		// Log.info("new tFactory: "+tFactory);
154 154
		tFactory.getConfiguration().registerExtensionFunction(new SaxonNodeSet());
155
		Log.info(NLS.bind("ApplyXsl2 with the {0} stylesheet.", xsltfile));
155
		Log.fine(NLS.bind("ApplyXsl2 with the {0} stylesheet.", xsltfile));
156 156
		reload();
157 157
		// Log.info("new transformer: "+transformer);
158 158
	}
......
428 428
			File[] files = listFiles(srcdir); // get files XSL compatible
429 429
			if (files == null) return false;
430 430
			
431
			System.out.println("-- Applying " + xslFile + " XSL to " + files.length + " (from " + srcdir + ") files with parameters: " + params + " on directory " + srcdir + " result written in "
432
					+ outdir);
431
			System.out.println("-- Applying '" + xslFile + "' XSL to " + files.length + " files from  directory '" + srcdir + "' with parameters: " + params + " result written in '" + outdir + "'");
433 432
			
434 433
			ConsoleProgressBar cpb = new ConsoleProgressBar(files.length);
435 434
			for (File f : files) {
tmp/org.txm.core/src/java/org/txm/metadatas/Metadatas.java (revision 3045)
222 222
		for (int i = 1; i < headers.size(); i++) {
223 223
			if (headers.get(i).length() == 0) {
224 224
				headers.set(i, "noname");
225
				System.out.println("Warning: the " + (i + 1) + "the column name is empty");
225
				System.out.println("Warning: the " + (i + 1) + "th column name is empty");
226 226
			}
227 227
			// if(!headers[i].equals("id"))// the first
228 228
			// {
tmp/org.txm.core/res/org/txm/css/txm.css (revision 3045)
74 74
	margin: 10px 10px 10px 10px;
75 75
}
76 76

  
77
.metadata {
78
	margin-left: auto;
79
	margin-right: auto;
80
	margin-bottom: 50px;
81
}
82

  
83
.metadata-line {
84

  
85
}
86

  
87
.metadata-cell {
88

  
89
}
90

  
77 91
td[rend="table-cell-align-right"] {
78 92
	text-align: right;
79 93
}

Also available in: Unified diff