2007-07-10 Alex Roitman <shura@gramps-project.org>

* src/GrampsDb/_GrampsDbWriteXML.py (write_date): Write datespan.
	* src/GrampsDbUtils/_ReadXML.py: (start_compound_date): Add new
	method; (start_datespan): Add new method.
	* data/grampsxml.dtd: Add datespan.
	* data/grampsxml.rng: Add datespan.



svn: r8712
This commit is contained in:
Alex Roitman 2007-07-11 04:56:11 +00:00
parent b836a61cff
commit 5984415471
5 changed files with 45 additions and 9 deletions

View File

@ -1,3 +1,10 @@
2007-07-10 Alex Roitman <shura@gramps-project.org>
* src/GrampsDb/_GrampsDbWriteXML.py (write_date): Write datespan.
* src/GrampsDbUtils/_ReadXML.py: (start_compound_date): Add new
method; (start_datespan): Add new method.
* data/grampsxml.dtd: Add datespan.
* data/grampsxml.rng: Add datespan.
2007-07-08 Alex Roitman <shura@gramps-project.org>
* configure.in: Add check for python-cairo>=1.2.6.

View File

@ -111,7 +111,7 @@ GENDER has values of M, F, or U.
<!ELEMENT gender (#PCDATA)>
<!ELEMENT name (first?,call?,last?,suffix?,patronymic?,title?,
(daterange|dateval|datestr)?,noteref*,sourceref*)>
(daterange|datespan|dateval|datestr)?,noteref*,sourceref*)>
<!ATTLIST name
alt (0|1) #IMPLIED
type CDATA #IMPLIED
@ -147,8 +147,8 @@ GENDER has values of M, F, or U.
rel CDATA #REQUIRED
>
<!ELEMENT address ((daterange|dateval|datestr)?,street?,city?,county?,state?,
country?,postal?,phone?,noteref*,sourceref*)>
<!ELEMENT address ((daterange|datespan|dateval|datestr)?,street?,city?,
county?,state?,country?,postal?,phone?,noteref*,sourceref*)>
<!ATTLIST address priv (0|1) #IMPLIED>
<!ELEMENT street (#PCDATA)>
@ -201,7 +201,7 @@ EVENT
-->
<!ELEMENT events (event)*>
<!ELEMENT event (type?,(daterange|dateval|datestr)?,place?,cause?,
<!ELEMENT event (type?,(daterange|datespan|dateval|datestr)?,place?,cause?,
description?,attribute*,noteref*,sourceref*,objref*)>
<!ATTLIST event
id CDATA #REQUIRED
@ -271,8 +271,8 @@ OBJECTS
<!ELEMENT objects (object)*>
<!ELEMENT object (file,attribute*,noteref*,(daterange|dateval|datestr)?,
sourceref*)>
<!ELEMENT object (file,attribute*,noteref*,
(daterange|datespan|dateval|datestr)?,sourceref*)>
<!ATTLIST object
id CDATA #REQUIRED
handle ID #REQUIRED
@ -358,6 +358,14 @@ SHARED ELEMENTS
cformat CDATA #IMPLIED
>
<!ELEMENT datespan EMPTY>
<!ATTLIST datespan
start CDATA #REQUIRED
stop CDATA #REQUIRED
quality (estimated|calculated) #IMPLIED
cformat CDATA #IMPLIED
>
<!ELEMENT dateval EMPTY>
<!ATTLIST dateval
val CDATA #REQUIRED

View File

@ -263,6 +263,15 @@
</choice></attribute></optional>
<optional><attribute name="cformat"><text/></attribute></optional>
</element>
<element name="datespan">
<attribute name="start"><text/></attribute>
<attribute name="stop"><text/></attribute>
<optional><attribute name="quality"><choice>
<value>estimated</value>
<value>calculated</value>
</choice></attribute></optional>
<optional><attribute name="cformat"><text/></attribute></optional>
</element>
<element name="dateval">
<attribute name="val"><text/></attribute>
<optional><attribute name="cformat"><text/></attribute></optional>

View File

@ -793,11 +793,16 @@ class GrampsDbXmlWriter(object):
mode = date.get_modifier()
if date.is_compound():
if mode == RelLib.Date.MOD_RANGE:
tagname = 'daterange'
else:
tagname = 'datespan'
d1 = self.get_iso_date(date.get_start_date())
d2 = self.get_iso_date(date.get_stop_date())
if d1 != "" or d2 != "":
self.g.write('%s<daterange start="%s" stop="%s"%s%s/>\n'
% (sp,d1,d2,qual_str,calstr))
self.g.write('%s<%s start="%s" stop="%s"%s%s/>\n'
% (sp,tagname,d1,d2,qual_str,calstr))
elif mode != RelLib.Date.MOD_TEXTONLY:
date_str = self.get_iso_date(date.get_start_date())
if date_str == "":

View File

@ -412,6 +412,7 @@ class GrampsParser(UpdateCallback):
"place" : (self.start_place, self.stop_place),
"dateval" : (self.start_dateval, None),
"daterange" : (self.start_daterange, None),
"datespan" : (self.start_datespan, None),
"datestr" : (self.start_datestr, None),
"places" : (None, self.stop_places),
"placeobj" : (self.start_placeobj,self.stop_placeobj),
@ -1421,6 +1422,12 @@ class GrampsParser(UpdateCallback):
self.placeobj.add_media_reference(self.pref)
def start_daterange(self,attrs):
self.start_compound_date(attrs,RelLib.Date.MOD_RANGE)
def start_datespan(self,attrs):
self.start_compound_date(attrs,RelLib.Date.MOD_SPAN)
def start_compound_date(self,attrs,mode):
if self.source_ref:
dv = self.source_ref.get_date_object()
elif self.ord:
@ -1483,7 +1490,7 @@ class GrampsParser(UpdateCallback):
else:
qual = RelLib.Date.QUAL_NONE
dv.set(qual,RelLib.Date.MOD_RANGE,cal,(d,m,y,False,rd,rm,ry,False))
dv.set(qual,mode,cal,(d,m,y,False,rd,rm,ry,False))
def start_dateval(self,attrs):
if self.source_ref: