Text item¶
The purpose of a text item
is to provide a way to capture and manipulate the object position in statements.
The allowed values for the object position are steered by providing certain restrictions on the text item
.
In the editing view the user typically provides the value by typing in one or several input fields.
Text item reference¶
Key | Explanation |
---|---|
type | Must be "text" for text items |
id | Identifier for the item |
property | A leading property required to be matched for this text item. For example, http://purl.org/dc/terms/title corresponding to the predicate of a RDF statement where the object is specified to be a language controlled literal via the nodeType. The property must always be specified for text items, except when used in the group URI special case. |
pattern | A regular expression to match the provided value against. |
valueTemplate | Will be used when updating the statement where any occurence of $1 is replaced with the value provided by the user (if no $1 is provided the user provided value is added at the end). |
cardinality | See separate section on cardinality. |
nodetype | Allowed values are ONLY_LITERAL, LANGUAGE_LITERAL, DATATYPE_LITERAL, and URI, see separate section on nodetypes. |
datatype | A single datatype or an array of datatypes. May be namespaced. Only used if nodeType is DATATYPE_LITERAL. |
deps | Dependency path that determines if the statement will be expressed. See separate section on dependency paths. |
value | A hardcoded value that will be used to create a statement if no matching statement is found. |
language | A language value that will be used to create a statement if no matching statement is found, only used if nodetype is LANGUAGE_LITERAL. |
label | A multi-language label for the text item. |
editLabel | A multi-language edit label for the text item, has higher priority than label in edit view (if provided). |
description | A multi-language description for the text item. |
editDescription | A multi-language edit description for the text item, has higher priority than label in edit view (if provided). |
placeholder | A multi-language text that will be shown in input fields before user starts to type. |
help | A multi-language help text that will be shown if the provided value does not fit the pattern. |
text | A set of multi-language texts, parametrized by keys. The keys are typically something like "title", "purpose", "usagenote", "mapping", "example" etc. |
styles | An open-ended list of attributes that is used by the different views to control behaviour. See separate section of well supported attributes. |
cls | An array of css classes that will be inserted in the DOM structure for this text item when renderered in a view. |
uriValueLabelProperties | An array of properties to be used to detect a suitable label if the nodetype is a URI. |
Example¶
Below a text item for presenting / validating / editing a single statement with property foaf:firstName
is examplified, no language or datatype is proscribed.
{
"id": "foaf::firstname",
"type": "text",
"property": "http://xmlns.com/foaf/0.1/firstName",
"label": { "en":"First name", "sv": "Förnamn" },
"cardinality": { "min": 1, "max": 1},
"nodetype": "ONLY_LITERAL"
}
Binding mechanism¶
A text item can be used to bind existing statements as well as create new statements. The binding step is performed by the RDForms engine that takes an RDF graph a template and a staring node as input and produces a binding tree as output. Below we describe both the matching and the creation step for statements.
Matching statements¶
A binding is created for every statements that matches:
- the subject from the surrounding group
- the given property
- the given nodetype
- the pattern (if any)
- one of the given datatypes (if any)
- one of the given languages (if any)
Creating statements¶
A text item can be used to create a statement based on the user input, the restrictions from the matching step and the following rules applies:
- Any pattern provided in the item will prohibit creation of statement until it is fullfilled.
- If the nodetype is set to
RESOURCE
aURI
will be created, not a blank node. - If the nodetype is set to
ANY_LITERAL
orPLAIN_LITERAL
a literal will be created without a language or datatype. - If the nodetype is set to
DATATYPE_LITERAL
and the datatype contains a list of datatypes to be accepted the first will be used by default.