[PATCH 3 of 3 seda] [profile gen] Export URL for keyword reference content

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Mar 30 17:43:19 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490887351 -7200
#      Thu Mar 30 17:22:31 2017 +0200
# Node ID 6e2218181e43e963cc38b599286c0ba6d8934cff
# Parent  5ac2e82f9ced1b4036fad67340196b0c089ca3c5
[profile gen] Export URL for keyword reference content

not text. Consistently with SEDA 1/0.2 export.

diff --git a/cubicweb_seda/entities/profile_generation.py b/cubicweb_seda/entities/profile_generation.py
--- a/cubicweb_seda/entities/profile_generation.py
+++ b/cubicweb_seda/entities/profile_generation.py
@@ -536,12 +536,16 @@ class SEDA2RelaxNGExport(RNGMixin, SEDA2
         elif copy_attributes:
             for attrname, occ in xselement.attributes.items():
                 if attrname in ('id', 'href') or attrname.startswith(('list', 'scheme')):
                     parent_element = self._rng_attribute_parent(occ, None, profile_element)
                     self._rng_attribute(occ.target, parent_element)
-        fixed_value = serialize(value, self.cwuri_url)
+        if value is not None and xselement.local_name == 'KeywordReference':
+            fixed_value = self.cwuri_url(value)
+        else:
+            fixed_value = serialize(value, self.cwuri_url)
         if fixed_value is not None:
+            print xselement.local_name, fixed_value
             if _internal_reference(value):
                 profile_element.attrib[self.qname('a:defaultValue')] = fixed_value
                 self.element('rng:data', profile_element, {'type': 'NCName'})
             else:
                 if (len(profile_element)
diff --git a/test/test_profile_generation.py b/test/test_profile_generation.py
--- a/test/test_profile_generation.py
+++ b/test/test_profile_generation.py
@@ -493,11 +493,11 @@ class SEDA2RNGExportTC(RelaxNGTestMixin,
             kwr_e.cw_set(seda_keyword_reference_to=kw_type)
             profile = self.profile_etree(transfer)
             kwr = self.get_element(profile, 'KeywordReference')
             self.assertElementDefinition(kwr, {'name': 'KeywordReference',
                                                'type': 'xsd:token',
-                                               'fixed': 'theme'})
+                                               'fixed': kw_type.cwuri})
             self.assertXSDAttributes(
                 kwr,
                 [{'name': 'schemeURI', 'fixed': scheme.cwuri}])
 
     def test_code_list(self):


More information about the saem-devel mailing list