Changeset 28361 in osm for applications/editors
- Timestamp:
- 2012-04-29T15:38:56+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NeptuneReader.java
r28031 r28361 17 17 18 18 import java.io.File; 19 import java.io.FileInputStream; 20 import java.io.FileNotFoundException; 19 21 import java.io.IOException; 20 22 import java.io.InputStream; … … 107 109 } 108 110 109 Source xmlFile = new StreamSource(file);110 111 111 try { 112 SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 113 Schema schema = schemaFactory.newSchema(schemaURL); 114 Validator validator = schema.newValidator(); 115 validator.validate(xmlFile); 116 System.out.println(xmlFile.getSystemId() + " is valid"); 117 return true; 118 } catch (SAXException e) { 119 System.out.println(xmlFile.getSystemId() + " is NOT valid"); 120 System.out.println("Reason: " + e.getLocalizedMessage()); 121 } catch (IOException e) { 122 System.out.println(xmlFile.getSystemId() + " is NOT valid"); 123 System.out.println("Reason: " + e.getLocalizedMessage()); 112 FileInputStream in = new FileInputStream(file); 113 Source xmlFile = new StreamSource(in); 114 try { 115 SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 116 Schema schema = schemaFactory.newSchema(schemaURL); 117 Validator validator = schema.newValidator(); 118 validator.validate(xmlFile); 119 System.out.println(xmlFile.getSystemId() + " is valid"); 120 return true; 121 } catch (SAXException e) { 122 System.out.println(xmlFile.getSystemId() + " is NOT valid"); 123 System.out.println("Reason: " + e.getLocalizedMessage()); 124 } catch (IOException e) { 125 System.out.println(xmlFile.getSystemId() + " is NOT valid"); 126 System.out.println("Reason: " + e.getLocalizedMessage()); 127 } finally { 128 try { 129 in.close(); 130 } catch (IOException e) { 131 // Ignore exception 132 } 133 } 134 } catch (FileNotFoundException e) { 135 System.err.println(e.getMessage()); 124 136 } 125 137
Note:
See TracChangeset
for help on using the changeset viewer.