Ignore:
Timestamp:
2010-10-16T22:08:17+02:00 (14 years ago)
Author:
stoecker
Message:

add XML checking for mappaint files

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r2990 r3612  
    66import java.io.IOException;
    77import java.io.InputStream;
     8import java.io.InputStreamReader;
    89import java.util.Collection;
    910import java.util.Collections;
     
    1617import org.openstreetmap.josm.io.MirroredInputStream;
    1718import org.openstreetmap.josm.tools.ImageProvider;
    18 import org.xml.sax.InputSource;
     19import org.openstreetmap.josm.tools.XmlObjectParser;
    1920import org.xml.sax.SAXException;
    20 import org.xml.sax.XMLReader;
    21 import org.xml.sax.helpers.XMLReaderFactory;
     21import org.xml.sax.SAXParseException;
    2222
    2323public class MapPaintStyles {
     
    8686                    a = new String[] { null, file };
    8787                }
    88                 XMLReader xmlReader = XMLReaderFactory.createXMLReader();
    89                 ElemStyleHandler handler = new ElemStyleHandler(a[0]);
    90                 xmlReader.setContentHandler(handler);
    91                 xmlReader.setErrorHandler(handler);
     88                XmlObjectParser parser = new XmlObjectParser(new ElemStyleHandler(a[0]));
    9289                MirroredInputStream in = new MirroredInputStream(a[1]);
    9390                InputStream zip = in.getZipEntry("xml","style");
     91                InputStreamReader ins;
    9492                if(zip != null)
    9593                {
    9694                    zipIcons = in.getFile();
    97                     xmlReader.parse(new InputSource(zip));
     95                    ins = new InputStreamReader(zip);
    9896                } else {
    99                     xmlReader.parse(new InputSource(in));
     97                    ins = new InputStreamReader(in);
     98                }
     99                parser.startWithValidation(ins, "http://josm.openstreetmap.de/mappaint-styöe-1.0",
     100                "resource://data/mappaint-style.xsd");
     101                while(parser.hasNext()) {
    100102                }
    101103            } catch(IOException e) {
    102104                System.err.println(tr("Warning: failed to load Mappaint styles from ''{0}''. Exception was: {1}", a[1], e.toString()));
    103105                e.printStackTrace();
     106            } catch(SAXParseException e) {
     107                System.err.println(tr("Warning: failed to parse Mappaint styles from ''{0}''. Error was: [{1}:{2}] {3}", a[1], e.getLineNumber(), e.getColumnNumber(), e.getMessage()));
     108                e.printStackTrace();
    104109            } catch(SAXException e) {
    105                 System.err.println(tr("Warning: failed to parse Mappaint styles from ''{0}''. Exception was: {1}", a[1], e.toString()));
     110                System.err.println(tr("Warning: failed to parse Mappaint styles from ''{0}''. Error was: {1}", a[1], e.getMessage()));
    106111                e.printStackTrace();
    107112            }
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r3582 r3612  
    4040import javax.swing.JTextField;
    4141import javax.swing.SwingUtilities;
    42 import javax.xml.transform.stream.StreamSource;
    4342
    4443import org.openstreetmap.josm.Main;
     
    749748
    750749        if (validate) {
    751             parser.startWithValidation(in, "http://josm.openstreetmap.de/tagging-preset-1.0", new StreamSource(TaggingPreset.class.getResourceAsStream("/data/tagging-preset.xsd")));
     750            parser.startWithValidation(in, "http://josm.openstreetmap.de/tagging-preset-1.0", "resource://data/tagging-preset.xsd");
    752751        } else {
    753752            parser.start(in);
Note: See TracChangeset for help on using the changeset viewer.