Opened 11 years ago

Closed 8 years ago

#274 closed enhancement (fixed)

Minimal occurences for attributes

Reported by: twagoo Owned by: Dieter Van Uytvanck
Priority: major Milestone: CMDI 1.2
Component: ComponentSchema Version:
Keywords: attributes, mandatoryattributes Cc:

Description

In CMDI 1.1 attributes are always optional. In CMDI 1.2, add a minimal occurences property for attributes that can be either 0 or 1 so that specific attributes can be made required.

Change History (5)

comment:1 Changed 11 years ago by mwindhouwer

Here is the contextual diff to add a Required flag to the Attribute specification in the general component schema and its use in comp2schema.xsl to generate the XSD @use="required".

Index: general-component-schema.xsd
===================================================================
--- general-component-schema.xsd	(revision 2308)
+++ general-component-schema.xsd	(working copy)
@@ -113,6 +113,11 @@
                                 </xs:annotation>
                             </xs:element>
                         </xs:choice>
+                        <xs:element name="Required" type="xs:boolean" default="false" minOccurs="0">
+                            <xs:annotation>
+                                <xs:documentation>Is the attribute required or not.</xs:documentation>
+                            </xs:annotation>
+                        </xs:element>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
Index: xslt/comp2schema-v2/comp2schema.xsl
===================================================================
--- xslt/comp2schema-v2/comp2schema.xsl	(revision 2311)
+++ xslt/comp2schema-v2/comp2schema.xsl	(working copy)
@@ -315,6 +314,11 @@
                 </xsl:attribute>
             </xsl:if>
             
+            <!-- Check if the attribute is required -->
+            <xsl:if test="normalize-space(./Required)='true'">
+                <xsl:attribute name="use">required</xsl:attribute>
+            </xsl:if>
+
             <!-- add some extra stuff if we have a CV attribute -->
             <xsl:choose>
 

comment:2 Changed 11 years ago by twagoo

Keywords: attributes added

comment:3 Changed 11 years ago by twagoo

Keywords: mandatoryattributes added

comment:4 Changed 10 years ago by Dieter Van Uytvanck

Owner: changed from dietuyt to Dieter Van Uytvanck
Status: newassigned

comment:5 Changed 8 years ago by Twan Goosen

Resolution: fixed
Status: assignedclosed

Fixed as part of CMDI 1.2 (See CMDI 1.2/Specification)

Note: See TracTickets for help on using tickets.