[profile gen] filename should never be prohibited, and its value may be fixed
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Nov 2016 17:25:22 +0100
changeset 2008 564ad2fb5af7
parent 2007 f849b3521fd3
child 2009 8eee5c9d1ec4
[profile gen] filename should never be prohibited, and its value may be fixed
entities/profile_generation.py
test/data/seda_02_export.rng
test/data/seda_02_export.xsd
test/data/seda_1_export.rng
test/data/seda_1_export.xsd
test/test_profile_generation.py
--- a/entities/profile_generation.py	Wed Nov 16 11:30:40 2016 +0100
+++ b/entities/profile_generation.py	Wed Nov 09 17:25:22 2016 +0100
@@ -1065,12 +1065,14 @@
                                       'clm60133:CharacterSetEncodingCodeContentType',
                                       cardinality=safe_cardinality(encoding),
                                       fixed_value=safe_concept_value(encoding)),
+                                XAttr('filename', 'xsd:string',
+                                      cardinality='0..1',
+                                      fixed_value=data_object.filename),
                                 # hard-coded attributes
                                 XAttr('characterSetCode',
                                       'clmIANACharacterSetCode:CharacterSetCodeContentType'),
                                 XAttr('mimeCode', 'clmIANAMIMEMediaType:MIMEMediaTypeContentType'),
                                 XAttr('uri', 'xsd:anyURI'),
-                                XAttr('filename', 'xsd:string'),
                             ])
         references = list(data_object.referenced_by)
         assert len(references) == 1
--- a/test/data/seda_02_export.rng	Wed Nov 16 11:30:40 2016 +0100
+++ b/test/data/seda_02_export.rng	Wed Nov 09 17:25:22 2016 +0100
@@ -168,6 +168,11 @@
                 <rng:attribute name="encodingCode">
                   <rng:value datatypeLibrary="urn:un:unece:uncefact:codelist:standard:6:0133:40106" type="CharacterSetEncodingCodeContentType">6</rng:value>
                 </rng:attribute>
+                <rng:optional>
+                  <rng:attribute name="filename">
+                    <rng:value type="string">this_is_the_filename.pdf</rng:value>
+                  </rng:attribute>
+                </rng:optional>
                 <rng:data datatypeLibrary="fr:gouv:culture:archivesdefrance:seda:v1.0:QualifiedDataType:1" type="ArchivesBinaryObjectType"/>
               </rng:element>
               <rng:element name="Type">
--- a/test/data/seda_02_export.xsd	Wed Nov 16 11:30:40 2016 +0100
+++ b/test/data/seda_02_export.xsd	Wed Nov 09 17:25:22 2016 +0100
@@ -256,10 +256,10 @@
                           <xsd:extension base="qdt:ArchivesBinaryObjectType">
                             <xsd:attribute fixed="fmt/123" name="format" type="clmDAFFileTypeCode:FileTypeCodeType" use="required"/>
                             <xsd:attribute fixed="6" name="encodingCode" type="clm60133:CharacterSetEncodingCodeContentType" use="required"/>
+                            <xsd:attribute fixed="this_is_the_filename.pdf" name="filename" type="xsd:string" use="optional"/>
                             <xsd:attribute name="characterSetCode" type="clmIANACharacterSetCode:CharacterSetCodeContentType" use="prohibited"/>
                             <xsd:attribute name="mimeCode" type="clmIANAMIMEMediaType:MIMEMediaTypeContentType" use="prohibited"/>
                             <xsd:attribute name="uri" type="xsd:anyURI" use="prohibited"/>
-                            <xsd:attribute name="filename" type="xsd:string" use="prohibited"/>
                           </xsd:extension>
                         </xsd:simpleContent>
                       </xsd:complexType>
--- a/test/data/seda_1_export.rng	Wed Nov 16 11:30:40 2016 +0100
+++ b/test/data/seda_1_export.rng	Wed Nov 09 17:25:22 2016 +0100
@@ -175,6 +175,11 @@
                 <rng:attribute name="encodingCode">
                   <rng:value datatypeLibrary="urn:un:unece:uncefact:codelist:standard:6:0133:40106" type="CharacterSetEncodingCodeContentType">6</rng:value>
                 </rng:attribute>
+                <rng:optional>
+                  <rng:attribute name="filename">
+                    <rng:value type="string">this_is_the_filename.pdf</rng:value>
+                  </rng:attribute>
+                </rng:optional>
                 <rng:data datatypeLibrary="fr:gouv:culture:archivesdefrance:seda:v1.0:QualifiedDataType:1" type="ArchivesBinaryObjectType"/>
               </rng:element>
               <rng:element name="Type">
--- a/test/data/seda_1_export.xsd	Wed Nov 16 11:30:40 2016 +0100
+++ b/test/data/seda_1_export.xsd	Wed Nov 09 17:25:22 2016 +0100
@@ -262,10 +262,10 @@
                           <xsd:extension base="qdt:ArchivesBinaryObjectType">
                             <xsd:attribute fixed="fmt/123" name="format" type="clmDAFFileTypeCode:FileTypeCodeType" use="required"/>
                             <xsd:attribute fixed="6" name="encodingCode" type="clm60133:CharacterSetEncodingCodeContentType" use="required"/>
+                            <xsd:attribute fixed="this_is_the_filename.pdf" name="filename" type="xsd:string" use="optional"/>
                             <xsd:attribute name="characterSetCode" type="clmIANACharacterSetCode:CharacterSetCodeContentType" use="prohibited"/>
                             <xsd:attribute name="mimeCode" type="clmIANAMIMEMediaType:MIMEMediaTypeContentType" use="prohibited"/>
                             <xsd:attribute name="uri" type="xsd:anyURI" use="prohibited"/>
-                            <xsd:attribute name="filename" type="xsd:string" use="prohibited"/>
                           </xsd:extension>
                         </xsd:simpleContent>
                       </xsd:complexType>
--- a/test/test_profile_generation.py	Wed Nov 16 11:30:40 2016 +0100
+++ b/test/test_profile_generation.py	Wed Nov 09 17:25:22 2016 +0100
@@ -749,6 +749,7 @@
             # Add minimal document to first level archive
             ref = create('SEDADataObjectReference', seda_data_object_reference=unit_alt_seq)
             bdo = create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
+                                     filename=u'this_is_the_filename.pdf',
                                      reverse_seda_data_object_reference_id=ref)
 
             create('SEDAFormatId',