Revision 1688 tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxmpara/ValidateXmlTXM.groovy

ValidateXmlTXM.groovy (revision 1688)
70 70
				}
71 71
			}
72 72
		}
73
		parser.close();
73
		if (parser != null) parser.close();
74
		if (inputData != null) inputData.close();
74 75
		println "get infos from $alignxml"
75 76
		return true;
76 77
	}
......
103 104

  
104 105
			factory = XMLInputFactory.newInstance();
105 106
			parser = factory.createXMLStreamReader(inputData);
106
		} catch (XMLStreamException ex) {
107
			System.out.println(ex);
108
			return false;
109
		}catch (IOException ex) {
110
			System.err.println("IOException while parsing ");
111
			return false
112
		}
107
		
113 108
		String localname = ""
114 109
		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next())
115 110
		{
......
186 181
				}
187 182
			}
188 183
		}
189
		parser.close();
190
		
184
		if (parser != null) parser.close();
185
			if (inputData != null) inputData.close();
186
		} catch (XMLStreamException ex) {
187
			System.out.println(ex);
188
			if (parser != null) parser.close();
189
			if (inputData != null) inputData.close();
190
			return false;
191
		}
191 192
		if(checkteiCorpus &
192 193
			!(hasTeiCorpus & hasTeiCorpusID & hasTeiCorpusHeader & hasTeiCorpusHeaderVersion))
193 194
		{	println "wrong <teiCorpus> format: $hasTeiCorpus & $hasTeiCorpusID & $hasTeiCorpusHeader & $hasTeiCorpusHeaderVersion"
......
197 198
		if(checkAlignStruct &
198 199
			!hasAlignStruct)
199 200
		{   println "wrong align structure format: $hasAlignStruct"
201
			if (parser != null) parser.close();
202
			if (inputData != null) inputData.close();
200 203
			return false;
201 204
		}
202 205
		
203 206
		if(checkTEI & !(hasTei == hasTeiID))
204 207
		{	println "wrong <TEI> format: $hasTei == $hasTeiID"
208
			if (parser != null) parser.close();
209
			if (inputData != null) inputData.close();
205 210
			return false;
206 211
		}
207 212
		

Also available in: Unified diff