Changeset 35722 in osm for applications/editors/josm
- Timestamp:
- 2021-03-13T13:23:28+01:00 (4 years ago)
- Location:
- applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/ValidatingImageryReader.java
r33493 r35722 4 4 import java.io.IOException; 5 5 6 import javax.xml.XMLConstants;7 6 import javax.xml.transform.stream.StreamSource; 8 import javax.xml.validation.Schema;9 import javax.xml.validation.SchemaFactory;10 7 11 8 import org.openstreetmap.josm.io.CachedFile; 12 9 import org.openstreetmap.josm.io.imagery.ImageryReader; 13 10 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants; 11 import org.openstreetmap.josm.tools.XmlUtils; 14 12 import org.xml.sax.SAXException; 15 13 … … 52 50 */ 53 51 public static void validate(String source) throws SAXException, IOException { 54 SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);55 52 try (CachedFile xmlSchema = new CachedFile(XML_SCHEMA)) { 56 Schema schema = factory.newSchema(new StreamSource(xmlSchema.getInputStream())); 57 schema.newValidator().validate(new StreamSource(source)); 53 XmlUtils.newXmlSchemaFactory() 54 .newSchema(new StreamSource(xmlSchema.getInputStream())) 55 .newValidator().validate(new StreamSource(source)); 58 56 } 59 57 } -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/XmlBoundsImporter.java
r34518 r35722 64 64 entries = reader.parse(); 65 65 } catch (SAXException e) { 66 Logging. trace(e);67 if (JOptionPane.showConfirmDialog(66 Logging.warn(e); 67 if (JOptionPane.YES_OPTION != GuiHelper.runInEDTAndWaitAndReturn(() -> JOptionPane.showConfirmDialog( 68 68 MainApplication.getMainFrame(), 69 69 tr("Validating error in file {0}:\n{1}\nDo you want to continue without validating the file ?", 70 70 source != null ? source : file.getPath(), e.getLocalizedMessage()), 71 71 tr("Open Imagery XML file"), 72 JOptionPane.YES_NO_CANCEL_OPTION) != JOptionPane.YES_OPTION) {73 74 72 JOptionPane.YES_NO_CANCEL_OPTION))) { 73 return null; 74 } 75 75 76 76 try (ImageryReader reader = new ImageryReader(source != null ? source : file.getAbsolutePath())) {
Note:
See TracChangeset
for help on using the changeset viewer.