Index: /trunk/src/org/openstreetmap/josm/data/osm/User.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/User.java	(revision 1603)
+++ /trunk/src/org/openstreetmap/josm/data/osm/User.java	(revision 1604)
@@ -21,4 +21,7 @@
     /** the username. */
     public String name;
+    
+    /** the user ID (since API 0.6) */
+    public String uid;
 
     /** private constructor, only called from get method. */
Index: /trunk/src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 1603)
+++ /trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 1604)
@@ -206,10 +206,8 @@
 
                     } else if (qName.equals("relation")) {
-//                         relationsN++;
                          current = new OsmPrimitiveData();
                          readCommon(atts, current);
                          relations.put((OsmPrimitiveData)current, new LinkedList<RelationMemberData>());
                     } else if (qName.equals("member")) {
-//                         membersN++;
                          Collection<RelationMemberData> list = relations.get(current);
                          if (list == null)
@@ -217,8 +215,24 @@
                          RelationMemberData emd = new RelationMemberData();
                          emd.relationMember = new RelationMember();
-                         emd.id = getLong(atts, "ref");
-                         emd.type=atts.getValue("type");
-                         emd.relationMember.role = atts.getValue("role");
-
+                         String value = atts.getValue("ref");
+                         if (value == null) {
+                             throw new SAXException(tr("Missing attribute \"ref\" on member in relation {0}",current.id));
+                         }
+                         try {
+                             emd.id = Long.parseLong(value);
+                         } catch(NumberFormatException e) {
+                             throw new SAXException(tr("Illegal value for attribute \"ref\" on member in relation {0}, got {1}", Long.toString(current.id),value));
+                         }
+                         value = atts.getValue("type");
+                         if (value == null) {
+                             throw new SAXException(tr("Missing attribute \"type\" on member {0} in relation {1}", Long.toString(emd.id), Long.toString(current.id)));
+                         }
+                         if (! (value.equals("way") || value.equals("node") || value.equals("relation"))) {
+                             throw new SAXException(tr("Unexpected \"type\" on member {0} in relation {1}, got {2}.", Long.toString(emd.id), Long.toString(current.id), value));
+                         }
+                         emd.type= value;
+                         value = atts.getValue("role");
+                         emd.relationMember.role = value;
+                         
                          if (emd.id == 0)
                               throw new SAXException(tr("Incomplete <member> specification with ref=0"));
@@ -271,4 +285,12 @@
                current.user = User.get(user);
           }
+          
+          // uid attribute added in 0.6 API 
+          String uid = atts.getValue("uid");
+          if (uid != null) {
+              if (current.user != null) {
+                  current.user.uid = uid;
+              }
+         }
 
           // visible attribute added in 0.4 API
@@ -278,18 +300,18 @@
           }
 
-          // oldversion attribute added in 0.6 API
-
-          // Note there is an asymmetry here: the server will send
-          // the version as "version" the client sends it as
-          // "oldversion". So we take both since which we receive will
-          // depend on reading from a file or reading from the server
-
           String version = atts.getValue("version");
+          current.version = 0;
           if (version != null) {
-               current.version = Integer.parseInt(version);
-          }
-          version = atts.getValue("old_version");
-          if (version != null) {
-               current.version = Integer.parseInt(version);
+              try {
+                  current.version = Integer.parseInt(version);
+              } catch(NumberFormatException e) {
+                  throw new SAXException(tr("Illegal value for attribute \"version\" on OSM primitive with id {0}, got {1}", Long.toString(current.id), version));
+              }
+          } else {
+              // version expected for OSM primitives with an id assigned by the server (id > 0), since API 0.6
+              //
+              if (current.id > 0 && ds.version != null && ds.version.equals("0.6")) {
+                  throw new SAXException(tr("Missing attribute \"version\" on OSM primitive with id {0}", Long.toString(current.id)));
+              }
           }
 
Index: /trunk/src/org/openstreetmap/josm/io/OsmWriter.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmWriter.java	(revision 1603)
+++ /trunk/src/org/openstreetmap/josm/io/OsmWriter.java	(revision 1604)
@@ -130,5 +130,5 @@
                 out.print(OsmApi.which(em.member));
                 out.println("' ref='"+getUsedId(em.member)+"' role='" +
-                        XmlWriter.encode(em.role) + "' />");
+                        XmlWriter.encode(em.role == null ? "" : em.role) + "' />");
             }
             addTags(e, "relation", false);
