From 27dab7c8116d219ed8445dba05119a8d4f480435 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 14 May 2014 22:10:38 +0100 Subject: [PATCH] Update Gramps XML schemas Also made a slight change to the XML format for places. --- data/grampsxml.dtd | 15 ++++++-- data/grampsxml.rng | 51 +++++++++++++++++++++++----- gramps/plugins/export/exportxml.py | 11 +++--- gramps/plugins/importer/importxml.py | 9 ++--- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/data/grampsxml.dtd b/data/grampsxml.dtd index d503d7eef..271429869 100644 --- a/data/grampsxml.dtd +++ b/data/grampsxml.dtd @@ -5,7 +5,7 @@ # # Copyright (C) 2001 Graham J. Williams # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2010-2011 Nick Hall +# Copyright (C) 2010-2014 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -248,16 +248,20 @@ PLACES - + + + + + + @@ -160,9 +159,6 @@ 0 1 - - - @@ -208,6 +204,9 @@ + + + @@ -403,6 +402,9 @@ + + + @@ -425,6 +427,9 @@ + + + @@ -444,6 +449,9 @@ + + + @@ -464,15 +472,25 @@ + + + + + + + + + + @@ -496,6 +514,9 @@ + + + @@ -503,8 +524,8 @@ - - + + @@ -516,6 +537,9 @@ + + + @@ -531,6 +555,9 @@ + + + @@ -574,6 +601,9 @@ + + + @@ -742,6 +772,11 @@ + + + + + diff --git a/gramps/plugins/export/exportxml.py b/gramps/plugins/export/exportxml.py index b592daf88..d3858dd82 100644 --- a/gramps/plugins/export/exportxml.py +++ b/gramps/plugins/export/exportxml.py @@ -1190,15 +1190,16 @@ class GrampsXmlWriter(UpdateCallback): ) def write_place_obj(self, place, index=1): - self.write_primary_tag("placeobj", place, index) + self.write_primary_tag("placeobj", place, index, close=False) + pname = self.fix(place.get_name()) + ptype = self.fix(place.get_type().xml_str()) + self.g.write(' name="%s"' % pname) + self.g.write(' type="%s"' % ptype) + self.g.write('>\n') title = self.fix(place.get_title()) - name = self.fix(place.get_name()) - ptype = self.fix(place.get_type().xml_str()) code = self.fix(place.get_code()) self.write_line_nofix("ptitle", title, index+1) - self.write_line_nofix("pname", name, index+1) - self.write_line_nofix("type", ptype, index+1) self.write_line_nofix("code", code, index+1) for name in place.get_alternative_names(): self.write_line("alt_name", name, index+1) diff --git a/gramps/plugins/importer/importxml.py b/gramps/plugins/importer/importxml.py index e02f79dd5..a519ce71d 100644 --- a/gramps/plugins/importer/importxml.py +++ b/gramps/plugins/importer/importxml.py @@ -689,7 +689,6 @@ class GrampsParser(UpdateCallback): "places": (None, self.stop_places), "placeobj": (self.start_placeobj, self.stop_placeobj), "placeref": (self.start_placeref, self.stop_placeref), - "pname": (None, self.stop_pname), "ptitle": (None, self.stop_ptitle), "location": (self.start_location, None), "lds_ord": (self.start_lds_ord, self.stop_lds_ord), @@ -1150,6 +1149,8 @@ class GrampsParser(UpdateCallback): self.inaugurate_id(attrs.get('id'), PLACE_KEY, self.placeobj) self.placeobj.private = bool(attrs.get("priv")) self.placeobj.change = int(attrs.get('change', self.change)) + self.placeobj.name = attrs.get("name") + self.placeobj.place_type.set_from_xml_str(attrs.get("type")) self.info.add('new-object', PLACE_KEY, self.placeobj) # GRAMPS LEGACY: title in the placeobj tag @@ -2578,9 +2579,6 @@ class GrampsParser(UpdateCallback): def stop_ptitle(self, tag): self.placeobj.title = tag - def stop_pname(self, tag): - self.placeobj.name = tag - def stop_code(self, tag): self.placeobj.code = tag @@ -2604,9 +2602,6 @@ class GrampsParser(UpdateCallback): elif self.repo: # Repository type self.repo.type.set_from_xml_str(tag) - elif self.placeobj: - # Place type - self.placeobj.place_type.set_from_xml_str(tag) def stop_childref(self, tag): self.childref = None