Next: , Previous: , Up: Top   [Contents][Index]

9 Remote Descriptors

The %rec special field is used for two main purposes: to identify a record as a record descriptor, and to provide a name for the described record set. The synopsis of the usage of the field is the following:

%rec: type [url_or_file]

type is the name of the kind of records described by the descriptor. It is mandatory to specify it, and it follows the same lexical conventions used by field names. See Fields. There is a non-enforced convention to use singular nouns, because the name makes reference to the type of a single entity, even if it applies to all the records contained in the record set. For example, the following record set contains transactions, and the type specified in the record descriptor is Transaction.

%rec: Transaction

Id: 10
Title: House rent

Id: 11
Title: Loan

Only one %rec field should be in a record descriptor. If there are more it is an integrity violation. It is highly recommended (but not enforced) to place this field in the first position of the record descriptor.

Sometimes it is convenient to store records of the same type in different files. The duplication of record descriptors in this case would surely lead to consistency problems. A possible solution would be to keep the record descriptor in a separated file and then include it in any operation by using pipes. For example:

$ cat descriptor.rec data.rec | recsel …

For those cases it is more convenient to use a external descriptor. External descriptors can be built appending a file path to the %rec field value, like:

%rec: FSD_Entry /path/to/file.rec

The previous example indicates that a record descriptor describing the FSD_Entry records shall be read from the file /path/to/file.rec. A record descriptor for FSD_Entry may not exist in the external file. Both relative and absolute paths can be specified there.

URLs can be used as sources for external descriptors as well. In that case we talk about remote descriptors. For example:

%rec: Department

The URL shall point to a text file containing rec data. If there is a record descriptor in the remote file documenting the Department type, it will be used.

Note that the local record descriptor can provide additional fields to “expand” the record type. For example:

%rec: FSD_Entry
%mandatory: Rating

The record descriptor above is including the contents of the FSD_Entry record descriptor from the URL, and adding them to the local record descriptor, that in this case contains just the %mandatory field.

If you are using GNU recutils (see Invoking the Utilities) to process your recfiles, any URL schema supported by libcurl will work.

Next: , Previous: , Up: Top   [Contents][Index]