Commit 17f4e73b authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[profile gen] Reintroduce overriding of xsd_content_description method

to avoid too much switches depending on SEDA version (more to come...).

Extract most of its content to separated methods so differences between the two implementations
is clear.
parent e56776dcea2a
......@@ -1018,30 +1018,27 @@ class SEDA1XSDExport(SEDA2XSDExport):
# cardinality=content.user_cardinality,
documentation=content.user_annotation,
xsd_attributes=[XAttr('Id', 'xsd:ID')])
if self.__regid__.startswith('SEDA-1.0'):
self.xsd_description_level(cd_node, content.description_level_concept)
self.xsd_description_level(cd_node, content.description_level_concept)
self.xsd_language(cd_node, content)
self.xsd_content_dates(cd_node, content)
self.xsd_description(cd_node, content)
self.xsd_keywords(cd_node, content)
self.xsd_originating_agency(cd_node, content)
def xsd_language(self, parent, content):
# XXX language is 0..1 in SEDA 2, 1..n in earlier version
language = content.language.concept if content.language else None
self.element_schema(cd_node, 'Language', 'qdt:CodeLanguageType',
self.element_schema(parent, 'Language', 'qdt:CodeLanguageType',
fixed_value=_concept_value(language, self.concepts_language),
xsd_attributes=[LIST_VERSION_ID_2009])
def xsd_content_dates(self, parent, content):
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',
self.element_schema(parent, '%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)
if self.__regid__.startswith('SEDA-0.2') and content.originating_agency:
self.xsd_agency(cd_node, 'OriginatingAgency', content.originating_agency)
for keyword in content.keywords:
self.xsd_keyword(cd_node, keyword)
if self.__regid__.startswith('SEDA-1.0') and content.originating_agency:
self.xsd_agency(cd_node, 'OriginatingAgency', content.originating_agency)
def xsd_description_level(self, parent, concept):
"""Append XSD elements for a description level to the given parent node"""
......@@ -1050,13 +1047,22 @@ class SEDA1XSDExport(SEDA2XSDExport):
fixed_value=value,
xsd_attributes=[LIST_VERSION_ID_2009])
def xsd_description(self, parent, description):
def xsd_description(self, parent, content):
"""Append XSD elements for a description to the given parent node"""
self.element_schema(parent, 'Description', 'udt:TextType',
cardinality=description.user_cardinality,
documentation=description.user_annotation,
fixed_value=description.description,
xsd_attributes=[XAttr('languageID', 'xsd:language')])
if content.description:
self.element_schema(parent, 'Description', 'udt:TextType',
cardinality=content.description.user_cardinality,
documentation=content.description.user_annotation,
fixed_value=content.description.description,
xsd_attributes=[XAttr('languageID', 'xsd:language')])
def xsd_keywords(self, parent, content):
for keyword in content.keywords:
self.xsd_keyword(parent, keyword)
def xsd_originating_agency(self, parent, content):
if content.originating_agency:
self.xsd_agency(parent, 'OriginatingAgency', content.originating_agency)
# extracted from xsd_keyword to allow parametrization for SEDA 1.0 vs 0.2 generation
kw_tag_name = 'Keyword'
......@@ -1277,6 +1283,17 @@ class SEDA02XSDExport(SEDA1XSDExport):
# elements)
ao_node.insert(0, ao_node[-1])
def xsd_content_description(self, parent, content):
"""Append XSD elements for a description content to the given parent node"""
cd_node = self.element_schema(parent, 'ContentDescription',
documentation=content.user_annotation,
xsd_attributes=[XAttr('Id', 'xsd:ID')])
self.xsd_language(cd_node, content)
self.xsd_content_dates(cd_node, content)
self.xsd_description(cd_node, content)
self.xsd_originating_agency(cd_node, content)
self.xsd_keywords(cd_node, content)
# in SEDA 0.2, ArchiveObject tag name is 'Contains' (as for Archive)
archive_object_tag_name = 'Contains'
# in SEDA 0.2, AccessRestrictionRule tag name is 'AccessRestriction'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment