]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/load/xml/GzipFileLoader.java
Version 16, February 2014
[GpsPrune.git] / tim / prune / load / xml / GzipFileLoader.java
index 70419f36681a8076dcb65c40f8ca3eb569733c2f..4be2bab3fc521627a65b793d490f5a01c173bfd4 100644 (file)
@@ -3,12 +3,10 @@ package tim.prune.load.xml;
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.zip.GZIPInputStream;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
 import tim.prune.App;
 import tim.prune.I18nManager;
-import tim.prune.data.Altitude;
 import tim.prune.data.SourceInfo;
+import tim.prune.load.MediaLinkInfo;
 
 /**
  * Class to handle the loading of gzipped xml files
@@ -42,21 +40,24 @@ public class GzipFileLoader
                {
                        istream = new GZIPInputStream(new FileInputStream(inFile));
                        _xmlLoader.reset();
-                       SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
-                       saxParser.parse(istream, _xmlLoader);
+                       // Parse the stream using either Xerces or java classes
+                       _xmlLoader.parseXmlStream(istream);
                        XmlHandler handler = _xmlLoader.getHandler();
                        if (handler == null) {
                                _app.showErrorMessage("error.load.dialogtitle", "error.load.noread");
                        }
-                       else {
+                       else
+                       {
                                // Send back to app
                                SourceInfo sourceInfo = new SourceInfo(inFile,
                                        (handler instanceof GpxHandler?SourceInfo.FILE_TYPE.GPX:SourceInfo.FILE_TYPE.KML));
                                _app.informDataLoaded(handler.getFieldArray(), handler.getDataArray(),
-                                       Altitude.Format.METRES, sourceInfo, handler.getTrackNameList());
+                                       null, sourceInfo, handler.getTrackNameList(),
+                                       new MediaLinkInfo(inFile, handler.getLinkArray()));
                        }
                }
-               catch (Exception e) {
+               catch (Exception e)
+               {
                        // Error occurred, could be a non-xml file borking the parser
                        _app.showErrorMessageNoLookup("error.load.dialogtitle",
                                I18nManager.getText("error.load.othererror") + " " + e.getClass().getName());