rudof dctap
rudof supports DCTAP (Dublin Core Tabular Application Profiles).
DCTAP is a simple tabular template that can be used to describe application profiles.
As an example, the following example represents 2 shapes: Person and Company.
Each row in DCTAP can contain a statement template that describes a property of that shape and some constraints.
For example, the shape Person has 4 templates about the properties name, birthDate, knows and gender.
| shapeId | propertyId | valueShape | valueDatatype | valueConstraint | mandatory | repeatable |
|---|---|---|---|---|---|---|
| Person | name | xsd:string | true | false | ||
| birthDate | xsd:date | false | false | |||
| knows | Person | false | true | |||
| gender | male female other | false | false | |||
| Company | founder | Person | false | false |
rudof supports DCTAP files in both CSV format and Excel spreadsheets.
Assuming the previous table is represented in a user.csv file as this one:
shapeId,propertyId,valueShape, valueDatatype, valueConstraint, mandatory, repeatable
Person,name,,xsd:string,,true,false
,birthDate,,xsd:date,,false,false
,gender,,,male female other,false,false
,knows, Person,,,false,true
,worksFor, Company,,,false,true
,,,,
Company,founder, Person,,,false,false
The following command can process the file and represent the shapes that it contains:
$ rudof dctap -s user.csv
Shape(Person)
name xsd:string
birthDate xsd:date ?
gender [male female other]?
knows @Person *
worksFor @Company *
Shape(Company)
founder @Person ?
rudof also reads spreadsheet formats such as xlsx. If the table above is in the file user.xlsx, run:
$ rudof dctap -s user.xlsx -f xlsx
DCTAP command
The general format of the DCTAP subcommand is:
--source-file is optional: a bare rudof dctap shows the DCTap already loaded in the current session (relevant inside rudof shell).
DCTAP Configuration file
The parameter --config-file (-c in short form) can be used to pass a configuration file in TOML format.
The fields that it can contain are:
- delimiter: field delimiter to use when parsing CSV. The default value is
,. Another typical value is;. - quote: The quote character to use when parsing CSV. The default is
". It can be used to indicate single quotes instead of double quotes. - flexible: whether records can have different numbers of fields. If it is off, a record with a different number of fields than the previous records is an error. It is on by default.
- picklist_delimiter: character that is used to separate values in a picklist cell. The default value is a bar
|.
These fields are experimental, and they can change:
-
property_placeholders: a table that generates values for some keys. If a cell contains one of those keys, rudof generates a value with the placeholder resolver of the key. The only placeholder resolver is
Stem, which replaces the key with a stem value. For example, the entryxhas the resolverStemand the valuestem = "Pending". A cell withx:Userthen givespending:User. -
empty_property_placeholder: Indicates how to generate a value for a row whose property ID is empty. The value is a placeholder resolver similar to the values in
property_placeholders.
The following TOML file can be an example:
[dctap]
delimiter = ","
picklist_delimiter = " "
[property_placeholders.x.Stem]
stem = "pending"
[empty_property_placeholder.Stem]
stem = "empty"
Options
$ rudof dctap --help
Arguments for the `dctap` command
Usage: rudof dctap [OPTIONS]
Options:
-s, --source-file <FILE> DCTap source file. If omitted, shows the currently loaded DCTap
-f, --format <FORMAT> DCTap file format [default: csv] [possible values: csv, xlsx, xlsb, xlsm, xls]
-r, --result-format <FORMAT> Output results format [default: internal] [possible values: internal, json]
-c, --config-file <FILE> Config file name
-o, --output-file <FILE> Output file name, default = terminal
--force-overwrite Force overwrite to output file if it already exists
-h, --help Print help