@@ -941,6 +941,48 @@ Also note that any style that is saved with an odML document will be lost, when
941
941
document is loaded again and changes to the content are added. In this case the required
942
942
style needs to be specified again when saving the changed file as described above.
943
943
944
+
945
+ Defining and working with feature cardinality
946
+ ---------------------------------------------
947
+
948
+ The odML format allows users to define a cardinality for
949
+ the number of subsections and properties of Sections and
950
+ the number of values a Property might have.
951
+
952
+ A cardinality is checked when it is set, when its target is
953
+ set and when a document is saved or loaded. If a specific
954
+ cardinality is violated, a corresponding warning will be printed.
955
+
956
+ Setting a cardinality
957
+ *********************
958
+
959
+ A cardinality can be set for sections or properties of sections
960
+ or for values of properties. By default every cardinality is None,
961
+ but it can be set to a defined minimal and/or a maximal number of
962
+ an element.
963
+
964
+ A cardinality is set via its convenience method:
965
+
966
+ >>> # Set the cardinality of the properties of a Section 'sec' to
967
+ >>> # a maximum of 5 elements.
968
+ >>> sec = odml.Section(name = " cardinality" , type = " test" )
969
+ >>> sec.set_properties_cardinality(max_val = 5 )
970
+
971
+ >>> # Set the cardinality of the subsections of Section 'sec' to
972
+ >>> # a minimum of one and a maximum of 2 elements.
973
+ >>> sec.set_sections_cardinality(min_val = 1 , max_val = 2 )
974
+
975
+ >>> # Set the cardinality of the values of a Property 'prop' to
976
+ >>> # a minimum of 1 element.
977
+ >>> prop = odml.Property(name = " cardinality" )
978
+ >>> prop.set_values_cardinality(min_val = 1 )
979
+
980
+ >>> # Re-set the cardinality of the values of a Property 'prop' to not set.
981
+ >>> prop.set_values_cardinality()
982
+ >>> # or
983
+ >>> prop.val_cardinality = None
984
+
985
+
944
986
Advanced knowledge on Values
945
987
----------------------------
946
988
0 commit comments