Working xml export

svn: r15948
This commit is contained in:
Benny Malengier 2010-10-02 13:38:36 +00:00
parent 043d35a354
commit 0ca48dd811
5 changed files with 39 additions and 20 deletions

View File

@ -133,7 +133,7 @@ GENDER has values of M, F, or U.
<!ELEMENT surname (#PCDATA)> <!ELEMENT surname (#PCDATA)>
<!ATTLIST surname <!ATTLIST surname
prefix CDATA #IMPLIED prefix CDATA #IMPLIED
primary (0|1) #IMPLIED primary (1|0) #IMPLIED
derivation CDATA #IMPLIED derivation CDATA #IMPLIED
connector CDATA #IMPLIED connector CDATA #IMPLIED
> >

View File

@ -242,8 +242,8 @@
<text/> <text/>
<optional><attribute name="prefix"><text/></attribute></optional> <optional><attribute name="prefix"><text/></attribute></optional>
<optional><attribute name="primary"><choice> <optional><attribute name="primary"><choice>
<value>0</value>
<value>1</value> <value>1</value>
<value>0</value>
</choice></attribute></optional> </choice></attribute></optional>
<optional><attribute name="derivation"><choice> <optional><attribute name="derivation"><choice>
<value>inherited</value> <value>inherited</value>

View File

@ -1356,7 +1356,12 @@ class DbBsddbRead(DbReadBase, Callback):
return self.__has_handle(self.source_map, handle) return self.__has_handle(self.source_map, handle)
def __sortbyperson_key(self, person): def __sortbyperson_key(self, person):
return locale.strxfrm(self.person_map.get(str(person))[3][5]) surnlist = self.person_map.get(str(person))[3][5]
if surnlist:
surn = " ".join([x[0] for x in surnlist])
else:
surn = ""
return locale.strxfrm(surn)
def __sortbyplace(self, first, second): def __sortbyplace(self, first, second):
return locale.strcoll(self.place_map.get(str(first))[2], return locale.strcoll(self.place_map.get(str(first))[2],

View File

@ -47,6 +47,7 @@ class Surname(SecondaryObject):
def __init__(self, source=None, data=None): def __init__(self, source=None, data=None):
"""Create a new Surname instance, copying from the source if provided. """Create a new Surname instance, copying from the source if provided.
By default a surname is created as primary, use set_primary to change
""" """
if source: if source:
self.surname = source.surname self.surname = source.surname
@ -57,7 +58,7 @@ class Surname(SecondaryObject):
else: else:
self.surname = "" self.surname = ""
self.prefix = "" self.prefix = ""
self.primary = False self.primary = True
self.origintype = NameOriginType() self.origintype = NameOriginType()
self.connector = "" self.connector = ""
if data: if data:

View File

@ -738,16 +738,26 @@ class GrampsXmlWriter(UpdateCallback):
if rel != "": if rel != "":
self.g.write(' %s<rel type="%s"/>\n' % (sp,rel) ) self.g.write(' %s<rel type="%s"/>\n' % (sp,rel) )
def write_last(self, name,indent=1): def write_surname(self, surname, indent=1):
p = name.get_surname_prefix() """
n = name.get_surname() Writes a surname of the name
g = name.get_group_as() """
self.g.write('%s<last' % (' '*indent)) pre = surname.get_prefix()
if p: con = surname.get_connector()
self.g.write(' prefix="%s"' % escxml(p)) nam = surname.get_surname()
if g: der = surname.get_origintype().xml_str()
self.g.write(' group="%s"' % escxml(g)) pri = surname.get_primary()
self.g.write('>%s</last>\n' % self.fix(n)) self.g.write('%s<surname' % (' '*indent))
if pre:
self.g.write(' prefix="%s"' % escxml(pre))
if not pri:
self.g.write(' prim="0"')
if con:
self.g.write(' connector="%s"' % escxml(con))
if der:
self.g.write(' derivation="%s"' % escxml(der))
self.g.write('>%s</surname>\n' % self.fix(nam))
def write_line(self,tagname,value,indent=1): def write_line(self,tagname,value,indent=1):
if value: if value:
@ -870,12 +880,15 @@ class GrampsXmlWriter(UpdateCallback):
if name.get_display_as() != 0: if name.get_display_as() != 0:
self.g.write(' display="%d"' % name.get_display_as()) self.g.write(' display="%d"' % name.get_display_as())
self.g.write('>\n') self.g.write('>\n')
self.write_line("first", name.get_first_name(),index+1) self.write_line("first", escxml(name.get_first_name()),index+1)
self.write_line("call", name.get_call_name(),index+1) self.write_line("call", escxml(name.get_call_name()),index+1)
self.write_last(name,index+1) for surname in name.get_surname_list():
self.write_line("suffix", name.get_suffix(),index+1) self.write_surname(surname,index+1)
self.write_line("patronymic", name.get_patronymic(),index+1) self.write_line("suffix", escxml(name.get_suffix()),index+1)
self.write_line("title", name.get_title(),index+1) self.write_line("title", escxml(name.get_title()),index+1)
self.write_line("nick", escxml(name.get_nick_name()), index+1)
self.write_line("familynick", escxml(name.get_family_nick_name()), index+1)
self.write_line("group", escxml(name.get_group_as()), index+1)
if name.date: if name.date:
self.write_date(name.date,4) self.write_date(name.date,4)
self.write_note_list(name.get_note_list(),index+1) self.write_note_list(name.get_note_list(),index+1)