Commit 2a8e1aa3 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[profile gen] Fix some content description elements of SEDA 1.0 / 0.2 export

* ContentDescription should always appears for first level archive unit but not
  necessarily for sub-levels

* LatestDate should appear before OldestDate in content description

* but language should occur first anyway

Merge xsd_content_description implementations along the way, not worth for a
single changing line.
parent e1cff0d624f1
......@@ -908,14 +908,14 @@ class SEDA1XSDExport(SEDA2XSDExport):
fixed_value=name_entity.title,
documentation=name_entity.user_annotation,
xsd_attributes=[XAttr('languageID', 'xsd:language')])
content_entity = self.archive_unit_content(archive_unit)
self.xsd_content_description(archive_node, content_entity)
appraisal_rule_entity = self.archive_unit_appraisal_rule(archive_unit)
if appraisal_rule_entity:
self.xsd_appraisal_rule(archive_node, appraisal_rule_entity)
# not optional in seda 1
access_rule_entity = self.archive_unit_access_rule(archive_unit)
self.xsd_access_rule(archive_node, access_rule_entity)
content_entity = self.archive_unit_content(archive_unit)
self.xsd_content_description(archive_node, content_entity)
self.xsd_children(archive_node, archive_unit)
def archive_unit_name(self, archive_unit):
......@@ -982,8 +982,12 @@ class SEDA1XSDExport(SEDA2XSDExport):
# cardinality=content.user_cardinality,
documentation=content.user_annotation,
xsd_attributes=[XAttr('Id', 'xsd:ID')])
self.xsd_description_level(cd_node, content.description_level_concept)
for seda2_name, seda1_name in (('start', 'oldest'), ('end', 'latest')):
if self.__regid__.startswith('SEDA-1.0'):
self.xsd_description_level(cd_node, content.description_level_concept)
self.element_schema(cd_node, 'Language', 'qdt:CodeLanguageType',
fixed_value='fr',
xsd_attributes=[LIST_VERSION_ID_2009])
for seda2_name, seda1_name in (('end', 'latest'), ('start', 'oldest')):
date_entity = getattr(content, '%s_date' % seda2_name)
if date_entity:
self.element_schema(cd_node, '%sDate' % seda1_name.capitalize(), 'udt:DateType',
......@@ -1062,13 +1066,18 @@ class SEDA1XSDExport(SEDA2XSDExport):
fixed_value=content_entity.title.title,
documentation=content_entity.title.user_annotation,
xsd_attributes=[XAttr('languageID', 'xsd:language')])
if (self.__regid__.startswith('SEDA-1.0')
or content_entity.start_date
or content_entity.end_date
or content_entity.description
or content_entity.keywords):
self.xsd_content_description(ao_node, content_entity)
appraisal_rule_entity = self.archive_unit_appraisal_rule(archive_unit)
if appraisal_rule_entity:
self.xsd_appraisal_rule(ao_node, appraisal_rule_entity)
access_rule_entity = self.archive_unit_access_rule(archive_unit)
if access_rule_entity:
self.xsd_access_rule(ao_node, access_rule_entity)
self.xsd_content_description(ao_node, content_entity)
self.xsd_children(ao_node, archive_unit)
return ao_node
......@@ -1185,6 +1194,8 @@ class SEDA02XSDExport(SEDA1XSDExport):
fixed_value=name_entity.title,
documentation=name_entity.user_annotation,
xsd_attributes=[XAttr('languageID', 'xsd:language')])
self.xsd_content_description(archive_node, content_entity)
appraisal_rule_entity = self.archive_unit_appraisal_rule(archive_unit)
if appraisal_rule_entity:
self.xsd_appraisal_rule(archive_node, appraisal_rule_entity)
......@@ -1192,35 +1203,8 @@ class SEDA02XSDExport(SEDA1XSDExport):
access_rule_entity = self.archive_unit_access_rule(archive_unit)
if access_rule_entity:
self.xsd_access_rule(archive_node, access_rule_entity)
content_entity = self.archive_unit_content(archive_unit)
self.xsd_content_description(archive_node, content_entity)
self.xsd_children(archive_node, archive_unit)
def xsd_content_description(self, parent, content):
"""Append XSD elements for a description content to the given parent node"""
if not (content.start_date or content.end_date or content.description or content.keywords):
return
cd_node = self.element_schema(parent, 'ContentDescription',
# XXX should always be 1
# cardinality=content_description.user_cardinality,
documentation=content.user_annotation,
xsd_attributes=[XAttr('Id', 'xsd:ID')])
for seda2_name, seda1_name in (('start', 'oldest'), ('end', 'latest')):
date_entity = getattr(content, '%s_date' % seda2_name)
if date_entity:
self.element_schema(cd_node, '%sDate' % seda1_name.capitalize(), 'udt:DateType',
cardinality=date_entity.user_cardinality,
documentation=date_entity.user_annotation)
if content.description:
self.xsd_description(cd_node, content.description)
self.element_schema(cd_node, 'Language', 'qdt:CodeLanguageType',
fixed_value='fr',
xsd_attributes=[LIST_VERSION_ID_2009])
for keyword in content.keywords:
self.xsd_keyword(cd_node, keyword)
# in SEDA 0.2, there may be some access restriction on the content description but it's on
# the archive in our model
def xsd_archive_object(self, parent, archive_unit):
"""Append XSD elements for the archive object to the given parent node."""
ao_node = super(SEDA02XSDExport, self).xsd_archive_object(parent, archive_unit)
......
......@@ -51,47 +51,20 @@
<rng:element name="Name">
<rng:data type="string"/>
</rng:element>
<rng:optional>
<rng:element name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<rng:element name="Code">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">detruire</rng:value>
</rng:element>
<rng:element name="Duration">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
<rng:value type="string">P10Y</rng:value>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:optional>
<rng:element name="AccessRestriction">
<rng:element name="Code">
<rng:element name="ContentDescription">
<rng:element name="Language">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:data type="string"/>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
<rng:value type="string">fr</rng:value>
</rng:element>
</rng:element>
<rng:element name="ContentDescription">
<rng:optional>
<rng:element name="OldestDate">
<rng:element name="LatestDate">
<rng:data type="string"/>
</rng:element>
</rng:optional>
<rng:optional>
<rng:element name="LatestDate">
<rng:element name="OldestDate">
<rng:data type="string"/>
</rng:element>
</rng:optional>
......@@ -100,12 +73,6 @@
<rng:data type="string"/>
</rng:element>
</rng:optional>
<rng:element name="Language">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">fr</rng:value>
</rng:element>
<rng:zeroOrMore>
<rng:element name="ContentDescriptive">
<rng:element name="KeywordContent">
......@@ -123,6 +90,39 @@
</rng:element>
</rng:zeroOrMore>
</rng:element>
<rng:optional>
<rng:element name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<rng:element name="Code">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">detruire</rng:value>
</rng:element>
<rng:element name="Duration">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
<rng:value type="string">P10Y</rng:value>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:optional>
<rng:element name="AccessRestriction">
<rng:element name="Code">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:data type="string"/>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
</rng:element>
</rng:element>
<rng:oneOrMore>
<rng:element name="Contains">
<rng:element name="DescriptionLevel">
......
......@@ -102,53 +102,20 @@
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element fixed="detruire" name="Code">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAppraisalType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element fixed="P10Y" name="Duration" type="qdt:ArchivesDurationType">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="AccessRestriction">
<xsd:element name="ContentDescription">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Code">
<xsd:element fixed="fr" name="Language">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAccessRestrictionType">
<xsd:extension base="qdt:CodeLanguageType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="ContentDescription">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="OldestDate" type="udt:DateType"/>
<xsd:element minOccurs="0" name="LatestDate" type="udt:DateType"/>
<xsd:element minOccurs="0" name="OldestDate" type="udt:DateType"/>
<xsd:element minOccurs="0" name="Description">
<xsd:complexType>
<xsd:simpleContent>
......@@ -158,15 +125,6 @@
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element fixed="fr" name="Language">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeLanguageType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="ContentDescriptive">
<xsd:complexType>
<xsd:sequence>
......@@ -201,6 +159,48 @@
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element fixed="detruire" name="Code">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAppraisalType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element fixed="P10Y" name="Duration" type="qdt:ArchivesDurationType">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="AccessRestriction">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Code">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAccessRestrictionType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element maxOccurs="unbounded" name="Contains">
<xsd:complexType>
<xsd:sequence>
......
......@@ -54,53 +54,26 @@
<rng:element name="Name">
<rng:data type="string"/>
</rng:element>
<rng:optional>
<rng:element name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<rng:element name="Code">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">detruire</rng:value>
</rng:element>
<rng:element name="Duration">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
<rng:value type="string">P10Y</rng:value>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:optional>
<rng:element name="AccessRestrictionRule">
<rng:element name="Code">
<rng:element name="ContentDescription">
<rng:element name="DescriptionLevel">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:data type="string"/>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
<rng:value type="string">file</rng:value>
</rng:element>
</rng:element>
<rng:element name="ContentDescription">
<rng:element name="DescriptionLevel">
<rng:element name="Language">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">file</rng:value>
<rng:value type="string">fr</rng:value>
</rng:element>
<rng:optional>
<rng:element name="OldestDate">
<rng:element name="LatestDate">
<rng:data type="string"/>
</rng:element>
</rng:optional>
<rng:optional>
<rng:element name="LatestDate">
<rng:element name="OldestDate">
<rng:data type="string"/>
</rng:element>
</rng:optional>
......@@ -126,11 +99,58 @@
</rng:element>
</rng:zeroOrMore>
</rng:element>
<rng:optional>
<rng:element name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<rng:element name="Code">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">detruire</rng:value>
</rng:element>
<rng:element name="Duration">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
<rng:value type="string">P10Y</rng:value>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:optional>
<rng:element name="AccessRestrictionRule">
<rng:element name="Code">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:data type="string"/>
</rng:element>
<rng:element name="StartDate">
<rng:data type="string"/>
</rng:element>
</rng:element>
<rng:oneOrMore>
<rng:element name="ArchiveObject">
<rng:element name="Name">
<rng:data type="string"/>
</rng:element>
<rng:element name="ContentDescription">
<rng:element name="DescriptionLevel">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:data type="string"/>
</rng:element>
<rng:element name="Language">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">fr</rng:value>
</rng:element>
</rng:element>
<rng:optional>
<rng:element name="Appraisal">
<rng:element name="Code">
......@@ -161,6 +181,13 @@
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:element>
</rng:oneOrMore>
<rng:oneOrMore>
<rng:element name="ArchiveObject">
<rng:element name="Name">
<rng:data type="string"/>
</rng:element>
<rng:element name="ContentDescription">
<rng:element name="DescriptionLevel">
<rng:attribute name="listVersionID">
......@@ -168,13 +195,12 @@
</rng:attribute>
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:element>
</rng:oneOrMore>
<rng:oneOrMore>
<rng:element name="ArchiveObject">
<rng:element name="Name">
<rng:data type="string"/>
<rng:element name="Language">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:value type="string">fr</rng:value>
</rng:element>
</rng:element>
<rng:optional>
<rng:element name="Appraisal">
......@@ -209,14 +235,6 @@
<rng:data type="string"/>
</rng:element>
</rng:element>
<rng:element name="ContentDescription">
<rng:element name="DescriptionLevel">
<rng:attribute name="listVersionID">
<rng:value type="token">edition 2009</rng:value>
</rng:attribute>
<rng:data type="string"/>
</rng:element>
</rng:element>
</rng:element>
</rng:oneOrMore>
<rng:zeroOrMore>
......
......@@ -93,62 +93,29 @@
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element fixed="detruire" name="Code">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAppraisalType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element fixed="P10Y" name="Duration" type="qdt:ArchivesDurationType">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="AccessRestrictionRule">
<xsd:element name="ContentDescription">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Code">
<xsd:element fixed="file" name="DescriptionLevel">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAccessRestrictionType">
<xsd:extension base="qdt:CodeDescriptionLevelType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="ContentDescription">
<xsd:complexType>
<xsd:sequence>
<xsd:element fixed="file" name="DescriptionLevel">
<xsd:element fixed="fr" name="Language">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeDescriptionLevelType">
<xsd:extension base="qdt:CodeLanguageType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="OldestDate" type="udt:DateType"/>
<xsd:element minOccurs="0" name="LatestDate" type="udt:DateType"/>
<xsd:element minOccurs="0" name="OldestDate" type="udt:DateType"/>
<xsd:element minOccurs="0" name="Description">
<xsd:complexType>
<xsd:simpleContent>
......@@ -193,6 +160,48 @@
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Appraisal">
<xsd:annotation>
<xsd:documentation>detruire le document</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element fixed="detruire" name="Code">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAppraisalType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element fixed="P10Y" name="Duration" type="qdt:ArchivesDurationType">
<xsd:annotation>
<xsd:documentation>C'est dans 10ans je m'en irai</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="AccessRestrictionRule">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Code">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="qdt:CodeAccessRestrictionType">
<xsd:attribute fixed="edition 2009" name="listVersionID" type="xsd:token" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="StartDate" type="udt:DateType"/>
</xsd:sequence>
<xsd:attribute name="Id" type="xsd:ID" use="prohibited"/>
</xsd:complexType>
</xsd:element>
<xsd:element maxOccurs="unbounded" name="ArchiveObject">
<xsd:complexType>
<xsd:sequence>
......@@ -205,56 +214,65 @@
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Appraisal">