Changeset 18954 in josm for trunk/src/org/openstreetmap/josm/io/session/NoteSessionImporter.java
- Timestamp:
- 2024-01-23T15:17:43+01:00 (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/session/NoteSessionImporter.java
r18208 r18954 7 7 import java.io.InputStream; 8 8 9 import javax.xml.xpath.XPath;10 import javax.xml.xpath.XPathConstants;11 import javax.xml.xpath.XPathExpression;12 import javax.xml.xpath.XPathExpressionException;13 import javax.xml.xpath.XPathFactory;14 15 9 import org.openstreetmap.josm.gui.io.importexport.NoteImporter; 16 10 import org.openstreetmap.josm.gui.layer.Layer; … … 19 13 import org.openstreetmap.josm.io.IllegalDataException; 20 14 import org.openstreetmap.josm.io.session.SessionReader.ImportSupport; 21 import org.openstreetmap.josm.tools.Utils;22 15 import org.w3c.dom.Element; 23 16 import org.xml.sax.SAXException; … … 35 28 throw new IllegalDataException(tr("Version ''{0}'' of meta data for note layer is not supported. Expected: 0.1", version)); 36 29 } 37 try {38 XPathFactory xPathFactory = XPathFactory.newInstance();39 XPath xpath = xPathFactory.newXPath();40 XPathExpression fileExp = xpath.compile("file/text()");41 String fileStr = (String) fileExp.evaluate(elem, XPathConstants.STRING);42 if (Utils.isEmpty(fileStr)) {43 throw new IllegalDataException(tr("File name expected for layer no. {0}", support.getLayerIndex()));44 }45 30 46 NoteImporter importer = new NoteImporter(); 47 try (InputStream in = support.getInputStream(fileStr)) { 48 return importer.loadLayer(in, support.getFile(fileStr), support.getLayerName(), progressMonitor); 49 } 50 } catch (XPathExpressionException | SAXException e) { 31 String fileStr = OsmDataSessionImporter.extractFileName(elem, support); 32 33 NoteImporter importer = new NoteImporter(); 34 try (InputStream in = support.getInputStream(fileStr)) { 35 return importer.loadLayer(in, support.getFile(fileStr), support.getLayerName(), progressMonitor); 36 } catch (SAXException e) { 51 37 throw new IllegalDataException(e); 52 38 }
Note:
See TracChangeset
for help on using the changeset viewer.