Révision 3922
TXM/trunk/bundles/org.txm.core/src/java/org/txm/scripts/importer/XMLTXM2WTC.groovy (revision 3922) | ||
---|---|---|
35 | 35 |
import javax.xml.stream.*; |
36 | 36 |
import java.net.URL; |
37 | 37 |
import org.txm.importer.filters.*; |
38 |
// TODO: Auto-generated Javadoc |
|
39 | 38 |
|
40 | 39 |
/** |
41 | 40 |
* The Class XMLTXM2CQP. |
... | ... | |
44 | 43 |
* simple transofmration of a xml-tei-txm file into cqp file |
45 | 44 |
*/ |
46 | 45 |
|
47 |
class XMLTXM2CQP |
|
48 |
{ |
|
46 |
class XMLTXM2CQP { |
|
49 | 47 |
|
50 | 48 |
/** The url. */ |
51 | 49 |
private def url; |
... | ... | |
109 | 107 |
* @param lang the lang |
110 | 108 |
* @return the java.lang. object |
111 | 109 |
*/ |
112 |
public setLang(String lang) |
|
113 |
{ |
|
110 |
public setLang(String lang) {
|
|
111 |
|
|
114 | 112 |
this.lang = lang; |
115 | 113 |
} |
116 | 114 |
|
... | ... | |
119 | 117 |
* |
120 | 118 |
* @param url the url |
121 | 119 |
*/ |
122 |
public XMLTXM2CQP(URL url){ |
|
120 |
public XMLTXM2CQP(URL url) { |
|
121 |
|
|
123 | 122 |
try { |
124 | 123 |
this.url = url; |
125 | 124 |
inputData = url.openStream(); |
... | ... | |
127 | 126 |
|
128 | 127 |
parser = factory.createXMLStreamReader(inputData); |
129 | 128 |
|
130 |
|
|
131 | 129 |
} catch (XMLStreamException ex) { |
132 | 130 |
System.out.println(ex); |
133 | 131 |
}catch (IOException ex) { |
... | ... | |
142 | 140 |
* @param base the base |
143 | 141 |
* @param project the project |
144 | 142 |
*/ |
145 |
public void setTextInfo(String name, String base, String project) |
|
146 |
{ |
|
143 |
public void setTextInfo(String name, String base, String project) {
|
|
144 |
|
|
147 | 145 |
this.addinfos = true; |
148 | 146 |
this.txtname= name; |
149 | 147 |
this.base = base; |
... | ... | |
156 | 154 |
* @param outfile the outfile |
157 | 155 |
* @return true, if successful |
158 | 156 |
*/ |
159 |
private boolean createOutput(File outfile) |
|
160 |
{ |
|
157 |
private boolean createOutput(File outfile) { |
|
161 | 158 |
try { |
162 | 159 |
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile, outfile.exists()) , "UTF-8")); |
163 | 160 |
return true; |
... | ... | |
179 | 176 |
* @param outfile the outfile |
180 | 177 |
* @return true, if successful |
181 | 178 |
*/ |
182 |
public boolean transformFile(File outfile) |
|
183 |
{ |
|
184 |
if(balisesToKeep == null) |
|
185 |
{ |
|
179 |
public boolean transformFile(File outfile) { |
|
180 |
|
|
181 |
if (balisesToKeep == null) { |
|
186 | 182 |
println "no element has been defined to be keeped" |
187 | 183 |
return false; |
188 | 184 |
} |
... | ... | |
204 | 200 |
balisesfound = new HashMap<String, List<String>>(); |
205 | 201 |
|
206 | 202 |
|
207 |
if(!createOutput(outfile))
|
|
203 |
if (!createOutput(outfile)) {
|
|
208 | 204 |
return false; |
205 |
} |
|
209 | 206 |
|
210 |
if(sendToPAttributes != null) |
|
211 |
{ |
|
207 |
if (sendToPAttributes != null) { |
|
212 | 208 |
for(String tag: sendToPAttributes.keySet()) |
213 | 209 |
for(String attr : sendToPAttributes.get(tag)) |
214 | 210 |
injectedPAttributes.add(tag+attr); |
... | ... | |
401 | 397 |
* |
402 | 398 |
* @return the p attributs |
403 | 399 |
*/ |
404 |
public List<String> getpAttributs() |
|
405 |
{ |
|
400 |
public List<String> getpAttributs() {
|
|
401 |
|
|
406 | 402 |
def pAttributs = []; |
407 | 403 |
|
408 | 404 |
for (String wordattr : wordattributes.keySet()) { |
409 | 405 |
pAttributs.add(wordattr); |
410 | 406 |
} |
411 | 407 |
|
412 |
if (sendToPAttributes != null) |
|
413 |
for (String pAttr : this.injectedPAttributes) |
|
408 |
if (sendToPAttributes != null) {
|
|
409 |
for (String pAttr : this.injectedPAttributes) {
|
|
414 | 410 |
pAttributs.add(pAttr); |
411 |
} |
|
412 |
} |
|
415 | 413 |
|
416 | 414 |
for (String anakey : anahash.keySet()) { |
417 | 415 |
pAttributs.add(anakey); |
... | ... | |
425 | 423 |
* |
426 | 424 |
* @return the s attributs |
427 | 425 |
*/ |
428 |
public List<String> getsAttributs() |
|
429 |
{ |
|
426 |
public List<String> getsAttributs() {
|
|
427 |
|
|
430 | 428 |
def sAttributs = []; |
431 | 429 |
for (String balise : this.balisesfound.keySet()) { |
432 | 430 |
List<String> sAtt = this.balisesfound.get(balise); |
... | ... | |
448 | 446 |
* |
449 | 447 |
* @param balisesToKeep the new balises to keep |
450 | 448 |
*/ |
451 |
public void setBalisesToKeep(List<String> balisesToKeep) |
|
452 |
{ |
|
449 |
public void setBalisesToKeep(List<String> balisesToKeep) { |
|
453 | 450 |
if (balisesToKeep != null) |
454 | 451 |
this.balisesToKeep = balisesToKeep; |
455 | 452 |
else |
... | ... | |
457 | 454 |
} |
458 | 455 |
|
459 | 456 |
/** |
460 |
* Sets the defautl reference pattern
|
|
457 |
* Sets the default reference pattern
|
|
461 | 458 |
* TODO: not implemented |
462 | 459 |
* |
463 |
* @param balisesToKeep the new balises to keep |
|
460 |
* @param pattern the sprintf pattern |
|
461 |
* @param structProperties list of structure properties to use |
|
464 | 462 |
*/ |
465 |
public void setDefaultReference(String pattern, List<String> strucProperties) |
|
466 |
{ |
|
463 |
public void setDefaultReference(String pattern, List<String> strucProperties) { |
|
467 | 464 |
if (defaultReferencePattern != null) { |
468 | 465 |
this.defaultReferences = defaultReferences; |
469 | 466 |
defaultReferencePattern = pattern; |
... | ... | |
475 | 472 |
* |
476 | 473 |
* @param sendus the sendus |
477 | 474 |
*/ |
478 |
public void setSendToPAttributes(HashMap<String, List<String>> sendus) |
|
479 |
{ |
|
475 |
public void setSendToPAttributes(HashMap<String, List<String>> sendus) { |
|
480 | 476 |
if (sendus != null) |
481 | 477 |
this.sendToPAttributes = sendus; |
482 | 478 |
else |
Formats disponibles : Unified diff