Index: trunk/src/org/openstreetmap/josm/io/GpxExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxExporter.java	(revision 5396)
+++ trunk/src/org/openstreetmap/josm/io/GpxExporter.java	(revision 5397)
@@ -33,5 +33,4 @@
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
-import org.openstreetmap.josm.io.auth.CredentialsManager;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.openstreetmap.josm.tools.GBC;
Index: trunk/src/org/openstreetmap/josm/io/GpxReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxReader.java	(revision 5396)
+++ trunk/src/org/openstreetmap/josm/io/GpxReader.java	(revision 5397)
@@ -93,8 +93,11 @@
                 currentData.creator = atts.getValue("creator");
                 version = atts.getValue("version");
-                if (!equal(version, "1.0") && !equal(version, "1.1")) {
+                if (version != null && version.startsWith("1.0")) {
+                    version = "1.0";
+                } else if (!"1.1".equals(version)) {
+                    // unknown version, assume 1.1
                     version = "1.1";
                 }
-                System.err.println("Version: "+version);
+                break;
             case gpx:
                 if (qName.equals("metadata")) {
@@ -229,5 +232,6 @@
             elements.pop();
             switch (currentState) {
-            case metadata:
+            case gpx:       // GPX 1.0
+            case metadata:  // GPX 1.1
                 if (qName.equals("name")) {
                     currentData.attr.put(GpxData.META_NAME, accumulator.toString());
@@ -238,5 +242,11 @@
                 } else if (qName.equals("keywords")) {
                     currentData.attr.put(GpxData.META_KEYWORDS, accumulator.toString());
-                } else if (qName.equals("metadata")) {
+                } else if (version.equals("1.0") && qName.equals("author")) {
+                    // author is a string in 1.0, but complex element in 1.1
+                    currentData.attr.put(GpxData.META_AUTHOR_NAME, accumulator.toString());
+                } else if (version.equals("1.0") && qName.equals("email")) {
+                    currentData.attr.put(GpxData.META_AUTHOR_EMAIL, accumulator.toString());
+                } else if ((currentState == State.metadata && qName.equals("metadata")) ||
+                        (currentState == State.gpx && qName.equals("gpx"))) {
                     currentState = states.pop();
                 }
@@ -334,7 +344,4 @@
                     currentState = states.pop();
                 }
-                break;
-            case gpx:
-                currentState = states.pop();
                 break;
             default:
Index: trunk/src/org/openstreetmap/josm/io/GpxWriter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 5396)
+++ trunk/src/org/openstreetmap/josm/io/GpxWriter.java	(revision 5397)
@@ -9,5 +9,7 @@
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 
@@ -61,17 +63,19 @@
     }
 
+    public static List<String> WPT_KEYS = Arrays.asList("ele", "time", "magvar", "geoidheight",
+            "name", "cmt", "desc", "src", GpxData.META_LINKS, "sym", "number", "type",
+            "fix", "sat", "hdop", "vdop", "pdop", "ageofdgpsdata", "dgpsid");
     @SuppressWarnings("unchecked")
     private void writeAttr(Map<String, Object> attr) {
-        // FIXME this loop is evil, because it does not assure the
-        // correct element order specified by the xml schema.
-        // for now it works, but future extension could get very complex and unmaintainable
-        for (Map.Entry<String, Object> ent : attr.entrySet()) {
-            String k = ent.getKey();
-            if (k.equals(GpxData.META_LINKS)) {
-                for (GpxLink link : (Collection<GpxLink>) ent.getValue()) {
-                    gpxLink(link);
+        for (String key : WPT_KEYS) {
+            Object value = attr.get(key);
+            if (value != null) {
+                if (key.equals(GpxData.META_LINKS)) {
+                    for (GpxLink link : (Collection<GpxLink>) value) {
+                        gpxLink(link);
+                    }
+                } else {
+                    simpleTag(key, value.toString());
                 }
-            } else {
-                simpleTag(k, ent.getValue().toString());
             }
         }
