Révision 1687
| tmp/org.txm.core/src/java/org/txm/scripts/importer/HasElement.groovy (revision 1687) | ||
|---|---|---|
| 12 | 12 |
|
| 13 | 13 |
HashSet<String> localnames = new HashSet<String>(); |
| 14 | 14 |
File xmlfile; |
| 15 |
def inputData |
|
| 15 | 16 |
XMLStreamReader parser; |
| 16 | 17 |
HashMap<String, Boolean> elements = [:]; |
| 17 | 18 |
|
| ... | ... | |
| 31 | 32 |
// println "uri: "+ xmlfile.toURI() |
| 32 | 33 |
// println "url: "+ xmlfile.toURI().toURL() |
| 33 | 34 |
// |
| 34 |
def inputData = xmlfile.toURI().toURL().openStream();
|
|
| 35 |
inputData = xmlfile.toURI().toURL().openStream(); |
|
| 35 | 36 |
def inputFactory = XMLInputFactory.newInstance(); |
| 36 | 37 |
parser = inputFactory.createXMLStreamReader(inputData); |
| 37 | 38 |
} catch (Exception ex) {
|
| ... | ... | |
| 41 | 42 |
} |
| 42 | 43 |
|
| 43 | 44 |
public boolean process() {
|
| 45 |
if (inputData == null) return false; |
|
| 44 | 46 |
if (parser == null) return false; |
| 45 | 47 |
|
| 46 | 48 |
for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
|
| ... | ... | |
| 48 | 50 |
String localname = parser.getLocalName(); |
| 49 | 51 |
if (localnames.contains(localname)) {
|
| 50 | 52 |
parser.close(); |
| 53 |
inputData.close(); |
|
| 51 | 54 |
return true; |
| 52 | 55 |
} |
| 53 | 56 |
} |
| 54 | 57 |
} |
| 55 | 58 |
parser.close(); |
| 59 |
inputData.close(); |
|
| 60 |
return false; |
|
| 56 | 61 |
} |
| 57 | 62 |
|
| 58 | 63 |
public static void main(String[] args) {
|
Formats disponibles : Unified diff