[profile generation] Use standard xml:id instead of seda:profid
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Nov 2017 08:14:05 +0100
changeset 2821 aad582bae5c8
parent 2820 7b5e567e6f00
child 2822 29b99ee6ff4c
[profile generation] Use standard xml:id instead of seda:profid In later commit we will insert identifiers using xml:id on more node. It sounds like there are no benefit in using a custom attribute, so uniformize toward using xml:id everywhere. Related to extranet #39304385
cubicweb_seda/entities/profile_generation.py
doc/profils.rst
test/data/seda_02_export.rng
test/data/seda_02_export.xsd
test/test_profile_generation.py
--- a/cubicweb_seda/entities/profile_generation.py	Fri Nov 03 12:06:28 2017 +0100
+++ b/cubicweb_seda/entities/profile_generation.py	Fri Nov 03 08:14:05 2017 +0100
@@ -1,4 +1,4 @@
-# copyright 2016-2017 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr -- mailto:contact@logilab.fr
 #
 # This program is free software: you can redistribute it and/or modify it under
@@ -396,6 +396,7 @@
     namespaces = {
         None: 'fr:gouv:culture:archivesdefrance:seda:v2.0',
         'seda': 'fr:gouv:culture:archivesdefrance:seda:v2.0',
+        'xml': 'http://www.w3.org/XML/1998/namespace',
         'xsd': 'http://www.w3.org/2001/XMLSchema',
         'xlink': 'http://www.w3.org/1999/xlink',
         'rng': 'http://relaxng.org/ns/structure/1.0',
@@ -607,7 +608,7 @@
                                         {'name': xselement.local_name})
             if value is not None:
                 if xselement.local_name == 'id':
-                    attr_element.attrib[self.qname('seda:profid')] = value
+                    attr_element.attrib[self.qname('xml:id')] = value
                     self.element('rng:data', attr_element, {'type': 'ID'})
                 else:
                     self.element('rng:value', attr_element, {'type': xstype}, text=value)
@@ -677,6 +678,7 @@
 
     namespaces = {
         None: 'fr:gouv:culture:archivesdefrance:seda:v1.0',
+        'xml': 'http://www.w3.org/XML/1998/namespace',
         'xsd': 'http://www.w3.org/2001/XMLSchema',
         'qdt': 'fr:gouv:culture:archivesdefrance:seda:v1.0:QualifiedDataType:1',
         'udt': 'urn:un:unece:uncefact:data:standard:UnqualifiedDataType:10',
@@ -1168,7 +1170,6 @@
     namespaces[None] = 'fr:gouv:ae:archive:draft:standard_echange_v0.2'
     namespaces['qdt'] = 'fr:gouv:ae:archive:draft:standard_echange_v0.2:QualifiedDataType:1'
     namespaces['udt'] = 'urn:un:unece:uncefact:data:standard:UnqualifiedDataType:6'
-    namespaces['seda'] = 'fr:gouv:culture:archivesdefrance:seda:v2.0'
 
     root_attributes = SEDA1XSDExport.root_attributes.copy()
     root_attributes['targetNamespace'] = 'fr:gouv:ae:archive:draft:standard_echange_v0.2'
@@ -1233,13 +1234,13 @@
 
     def xsd_document(self, parent, data_object):
         """Append XSD elements for the document to the given parent node."""
-        xmlid = eid2xmlid(data_object.eid)
-        document_node = self.element_schema(parent, 'Document',
-                                            cardinality=data_object.user_cardinality,
-                                            documentation=data_object.user_annotation,
-                                            extra_attributes={'seda:profid': xmlid},
-                                            xsd_attributes=[XAttr('Id', 'xsd:ID')])
-
+        document_node = self.element_schema(
+            parent, 'Document',
+            cardinality=data_object.user_cardinality,
+            documentation=data_object.user_annotation,
+            extra_attributes={'xml:id': eid2xmlid(data_object.eid)},
+            xsd_attributes=[XAttr('Id', 'xsd:ID')],
+        )
         self.xsd_attachment(document_node, data_object)
         self.xsd_date_created(document_node, data_object)
         self.xsd_system_id(document_node, data_object)
@@ -1352,7 +1353,6 @@
     namespaces = SEDA1XSDExport.namespaces.copy()
     namespaces['rng'] = 'http://relaxng.org/ns/structure/1.0'
     namespaces['a'] = 'http://relaxng.org/ns/compatibility/annotations/1.0'
-    namespaces['seda'] = 'fr:gouv:culture:archivesdefrance:seda:v2.0'
     root_attributes = {
         'ns': 'fr:gouv:ae:archive:draft:standard_echange_v0.2',
         'datatypeLibrary': 'http://www.w3.org/2001/XMLSchema-datatypes',
--- a/doc/profils.rst	Fri Nov 03 12:06:28 2017 +0100
+++ b/doc/profils.rst	Fri Nov 03 08:14:05 2017 +0100
@@ -29,7 +29,7 @@
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Les identifiants spécifiés dans l'interface utilisateur sur les objets-données et les unités
-d'archives sont reportés via un attribut `seda:profid` sur l'élément correspond dans le profil
+d'archives sont reportés via un attribut `xml:id` sur l'élément correspond dans le profil
 RelaxNG_ généré ([1]_). La valeur de cette attribut est ensuite utilisée comme valeur par défaut des
 éléments référençant cet élément.
 
@@ -39,7 +39,7 @@
 largement usage de telles références. Il est à noter qu'il est donc à la
 responsabilité de l'outil qui génère le bordereau de gérer les définitions de
 références ainsi créées en substituant dans les éléments référencés la valeur de
-l'identifiant qu'il a attribué à l'élément portant le `seda:profid`
+l'identifiant qu'il a attribué à l'élément portant le `xml:id`
 correspondant.
 
 Ceci n'étant pas un mécanisme standard de RelaxNG_, la cohérence des références entre
--- a/test/data/seda_02_export.rng	Fri Nov 03 12:06:28 2017 +0100
+++ b/test/data/seda_02_export.rng	Fri Nov 03 08:14:05 2017 +0100
@@ -7,7 +7,6 @@
     xmlns:clm60133="urn:un:unece:uncefact:codelist:standard:6:0133:40106"
     xmlns:qdt="fr:gouv:culture:archivesdefrance:seda:v1.0:QualifiedDataType:1"
     xmlns:rng="http://relaxng.org/ns/structure/1.0"
-    xmlns:seda="fr:gouv:culture:archivesdefrance:seda:v2.0"
     xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:10"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns="fr:gouv:culture:archivesdefrance:seda:v1.0"
@@ -373,7 +372,7 @@
             </rng:element>
           </rng:element>
           <rng:zeroOrMore>
-            <rng:element name="Document" seda:profid="id%(bdo-eid)s">
+            <rng:element name="Document" xml:id="id%(bdo-eid)s">
               <xsd:annotation>
                 <xsd:documentation>data object title</xsd:documentation>
               </xsd:annotation>
--- a/test/data/seda_02_export.xsd	Fri Nov 03 12:06:28 2017 +0100
+++ b/test/data/seda_02_export.xsd	Fri Nov 03 08:14:05 2017 +0100
@@ -5,7 +5,6 @@
     xmlns:clmIANACharacterSetCode="urn:un:unece:uncefact:codelist:standard:IANA:CharacterSetCode:2007-05-14"
     xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:standard:IANA:MIMEMediaType:2008-11-12"
     xmlns:qdt="fr:gouv:culture:archivesdefrance:seda:v1.0:QualifiedDataType:1"
-    xmlns:seda="fr:gouv:culture:archivesdefrance:seda:v2.0"
     xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:10"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns="fr:gouv:culture:archivesdefrance:seda:v1.0"
@@ -272,7 +271,7 @@
                   <xsd:attribute name="Id" type="xsd:ID" use="optional"/>
                 </xsd:complexType>
               </xsd:element>
-              <xsd:element maxOccurs="unbounded" minOccurs="0" name="Document" seda:profid="id%(bdo-eid)s">
+              <xsd:element maxOccurs="unbounded" minOccurs="0" name="Document" xml:id="id%(bdo-eid)s">
                 <xsd:annotation>
                   <xsd:documentation>data object title</xsd:documentation>
                 </xsd:annotation>
--- a/test/test_profile_generation.py	Fri Nov 03 12:06:28 2017 +0100
+++ b/test/test_profile_generation.py	Fri Nov 03 08:14:05 2017 +0100
@@ -699,9 +699,9 @@
 class SEDARNGExportFuncTC(SEDAExportFuncTCMixIn, RelaxNGTestMixin, CubicWebTC):
 
     def assertProfileDetails(self, root):
-        # ensure profile's temporary id are exported in custom seda:profid attribute
-        self.assertEqual(len(self.xpath(root, '//rng:attribute[@seda:profid]')), 2)
-        for attrdef in self.xpath(root, '//xs:attribute[@seda:profid]'):
+        # ensure profile's temporary id are exported in xml:id attribute
+        self.assertEqual(len(self.xpath(root, '//rng:attribute[@xml:id]')), 2)
+        for attrdef in self.xpath(root, '//xs:attribute[@xml:id]'):
             self.assertEqual(attrdef[0]['type'], 'ID')
         # ensure they are properly referenced using 'default' attribute
         xmlid = pg.eid2xmlid(self.bdo_eid)