Help:Type Record/Defining a record

From semantic-mediawiki.org
< Help:Datatype "Record"
Help:Datatype "Record"Help:Type Record/Defining a record

For example you would define a property of datatype record like this: [[Has fields::name of my property of datatype Page; name of my property of datatype Number; name of my property of datatype Text]]

Hence the single fields refer to properties and not to datatypes as in versions of Semantic MediaWiki 1.6.0Released on 30 July 2011 and compatible with MW 1.15.x - 1.18.x.. The use of properties instead of datatypes is better since it allows custom settings beyond the datatype of a field (e.g. conversion factors). In case your are upgrading your wiki containing properties of type record from a version of SMW prior to 1.6.0 to 1.6.0 or above see the instructions on this help page for steps on how to do this.

In a similar way as explained above, you can set any list of properties for the record. It is recommended that the number of fields in a record does not exceed five, but larger records are possible. There are some technical restrictions on record sizes, so record declarations with more than 50 fields are likely to fail. Note that records are already unusable for human editors at much shorter lengths.

When using a record-type property on a page, the values for the individual fields are given as a value, separated by semicolons. If the property "MyRecord" were declared as above, one could write the following annotation on a page:

[[MyRecord::Some pagename; 1234; some string]]

Empty values[edit]

When setting a value for a record-type property, it is also possible to leave some of the fields unset by leaving them empty or setting question marks:

[[MyRecord::Some pagename; ?; some string]]
[[MyRecord::Some pagename;; some string]]

Values at the end of the record can also be omitted completely:

[[MyRecord::Some pagename; 1234]]

Encode ;[edit]

Since Semantic MediaWiki 2.1.0Released on 19 January 2015 and compatible with MW 1.19.0 - 1.24.x. it is also possible to use a semicolon ";" as part of the property value to be annotated via a property of type "Record".1 Otherwise the semicolon will be treated as a delimiter between the values set. To also add a semicolon to a property value it needs to be escaped like "\;" e.g.

[[MyRecord::Some pagename; 1234; some string with \; inbetween]]

References

  1. ^  Semantic MediaWiki: GitHub issue gh:smw:664