On 15/06/2020 19:59, Tomasz Pluskiewicz wrote:
Ah, yes, I realise that I eventually implemented it similarly with the
default value because always added for new values so indeed the
selection process is the same for existing and new objects.
Could you link to a diff of what you changed in forms.html?
Attached
Holger
W dniu poniedziałek, 15 czerwca 2020 02:23:31 UTC+2 użytkownik Holger
Knublauch napisał:
In our implementation each widget receives a "default" value when
initialized. In the case of literals, this is a literal with the
lexical form "", i.e. the empty string. In the case of URIs this
is an URI node with "" as its URI. This approach means that these
scoring rules can apply relatively consistently.
Having said this, the score functions in our implementation also
receive a second argument, which is metadata about the 'field',
which is basically the collection of applicable property shapes
for that property/path. Some widgets do use that metadata to make
further choices in cases where the node isn't sufficient to make a
decision.
Examples:
BlankNodeViewer.score = (value, field) => {
returnvalue.isBlankNode() ? 1 : 0;
};
The only widgets that use the 'field' above are dash:Editors:
BooleanSelectEditor.score = (value, field) => {
if(value.dt == 'boolean') {
return10;
}
if(field.isObjectProperty) {
return0;
}
if(field.hasDT('boolean')) {
return10;
}
if(field.hasAnyDT()) {
return0;
}
returnnull;
};
DatePickerEditor.score = (value, field) => {
returnvalue.dt == 'date'? 10 : field && field.hasDT('date') ? 5 : 0;
};
DateTimePickerEditor.score = (value, field) => {
returnvalue.dt == 'dateTime' ? 10 : field &&
field.hasDT('dateTime') ? 5 : 0;
};
EnumSelectEditor.score = (value, field) => {
returnfield && field.enumValues ? 10 : 0;
};
FromConceptSchemeEditor.score= (value, field) => {
if(field && field.hasAnyDT()) {
// Unsuitable for datatype fields
return0;
}
// We don't have enough info here to decide so leave
the choice to users
returnnull;
};
OWLManchesterSyntaxEditor.score = (value, field) => {
if (
!field.path.isInverse&&
(field.path.predicate==
'http://www.w3.org/2000/01/rdf-schema#domain
<http://www.w3.org/2000/01/rdf-schema#domain>' ||
field.path.predicate ==
'http://www.w3.org/2000/01/rdf-schema#range
<http://www.w3.org/2000/01/rdf-schema#range>' ||
field.path.predicate ==
'http://www.w3.org/2000/01/rdf-schema#subClassOf
<http://www.w3.org/2000/01/rdf-schema#subClassOf>' ||
field.path.predicate ==
'http://www.w3.org/2002/07/owl#disjointWith
<http://www.w3.org/2002/07/owl#disjointWith>' ||
field.path.predicate ==
'http://www.w3.org/2002/07/owl#equivalentClass
<http://www.w3.org/2002/07/owl#equivalentClass>')
) {
if (value.isBlankNode()) {
return50;
} else {
returnnull;
}
} else {
return0;
}
};
TextAreaEditor.score = (value, field) => {
if (value.isString()) {
if (field && field.singleLine === true) {
return0;
} elseif (field && field.singleLine === false) {
return20; // Prefer over single line editors
} elseif(DisplayUtil.containsLineBreak(value.lex) &&
field.singleLine !== false) {
return20; // Prefer over single line editors if line breaks exist
} else {
return5;
}
} elseif (field.hasDT('string')) {
return2;
}
elseif(field.hasCustomDatatype()) {
returnnull;
} else {
return0;
}
};
TextAreaWithLangEditor.score = (value, field) => {
if (value.isLangString() || (field && field.isStringOrLangString())) {
if (field && field.singleLine === true) {
return0;
} elseif (field && field.singleLine === false) {
return15; // Prefer over single line editors
} elseif(DisplayUtil.containsLineBreak(value.lex) &&
field.singleLine !== false) {
return15; // Prefer over single line editors if line breaks exist
} else {
return5;
}
} elseif (field &&
field.hasDT('langString') && !field.singleLine) {
return5;
} else {
return0;
}
};
TextFieldWithLangEditor.score= (value, field) => {
if (value.isLangString() || (field && field.isStringOrLangString())) {
return10;
} elseif (field &&
field.hasDT('langString') && !field.singleLine) {
return5;
} else {
return0;
}
};
TimeEditor.score = (value, field) => {
returnvalue.dt == 'time'? 15 : field && field.hasDT('time') ? 5 : 0;
};
URIEditor.score = (value, field) => {
if (value.isURI()) {
if (field.nodeKind && field.nodeKind.label == 'IRI'&&
field.isObjectProperty && field.classes.length == 0) {
return10;
} else {
returnnull;
}
} else {
return0;
}
};
I have made small updates to the forms.html online doc to clarify
this (and added dash:DateTimePicker which we have implemented in
the meantime).
Holger
On 12/06/2020 18:51, Tomasz Pluskiewicz wrote:
Hi
I am implementing a SHACL form builder in JavaScript and intended
to have DASH integrated by default.
I have a little difficulty with the scoring system. Let's take
the simplest text field as example. The spec says
* 10 if the value is a literal that is neither rdf:langString
nor xsd:boolean
* 0 otherwise
First question is in general about the rules which mention a
"value". This applies only to existing triples in the dataset at
the time the form is initialised, correct? For example
|
# score 10
<#me> rdfs:label "Tomasz Pluskiewicz" .
# score 0
<#me> rdfs:label "Tomasz Pluskiewicz"@pl .
|
I think this is missing a rule for adding new objects for a
property. Such as when a user clicks a (+) button. In that case
the property shape is the only information available as there is
no "value" yet.
The example snippet does show a "sh:datatype xsd:string" but it's
not mentioned in the score rules for the text field. A bit of a
grey area?
Best,
Tom
--
You received this message because you are subscribed to the
Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected] <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/14c15fa7-448a-4d00-9c9e-ca957e12f56co%40googlegroups.com
<https://groups.google.com/d/msgid/topbraid-users/14c15fa7-448a-4d00-9c9e-ca957e12f56co%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/01450f1d-ed27-40a3-a10d-19b9b70b00bao%40googlegroups.com
<https://groups.google.com/d/msgid/topbraid-users/01450f1d-ed27-40a3-a10d-19b9b70b00bao%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "TopBraid
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/6c87355d-5eae-5841-e963-790a4e02245d%40topquadrant.com.
diff --git
"a/C:\\Users\\Holger\\AppData\\Local\\Temp\\TortoiseGit\\forms-a6f1d91.001.html"
"b/C:\\Users\\Holger\\AppData\\Local\\Temp\\TortoiseGit\\forms-7efa883.001.html"
index 53d036f01b6..7fedc0eabb1 100644
---
"a/C:\\Users\\Holger\\AppData\\Local\\Temp\\TortoiseGit\\forms-a6f1d91.001.html"
+++
"b/C:\\Users\\Holger\\AppData\\Local\\Temp\\TortoiseGit\\forms-7efa883.001.html"
@@ -570,7 +570,9 @@ aushapes:PersonViewShape-address
sh:maxCount 1 ;
sh:nodeKind sh:IRI .</pre>
<p>
- Using <a
href="#DetailsViewer"><code>dash:DetailsViewer</code></a> as the
<code>dash:viewer</code> instructs a form engine to recursively "walk"
+ Using <a
href="#DetailsViewer"><code>dash:DetailsViewer</code></a> as the
<code>dash:viewer</code>
+ (or <a
href="#DetailsEditor"><code>dash:DetailsEditor</code></a> as the
<code>dash:editor</code> - not yet supported by TopBraid)
+ instructs a form engine to recursively
"walk"
into the linked resource and show its
values as a sub-form of the surrounding form.
The value of <code>sh:node</code> tells
the form engine which selection of properties to display, and in which order.
(In the case above, no property groups
are shown for nested forms, to reduce the complexity to users).
@@ -805,7 +807,8 @@ ex:Person-bornIn
<p>
<b>Score:</b>
10 for <code>xsd:boolean</code>
literals.
- 0 otherwise.
+ 0 for non-literals or if there
is a <code>sh:datatype</code> constraint.
+ <code>null</code> for
properties allowing literals without specifying a particular datatype.
</p>
<p>
<b>Rendering:</b>
@@ -825,6 +828,7 @@ ex:Person-married
<p>
<b>Score:</b>
10 for <code>xsd:date</code>
literals.
+ 5 if the property has
<code>sh:datatype xsd:date</code>.
0 otherwise.
</p>
<p>
@@ -839,11 +843,12 @@ ex:Person-dateOfBirth
<b>sh:datatype xsd:date ;</b>
...</pre>
</section>
- <!-- section id="DateTimePickerEditor">
+ <section id="DateTimePickerEditor">
<h4>dash:DateTimePickerEditor</h4>
<p>
<b>Score:</b>
10 for
<code>xsd:dateTime</code> literals.
+ 5 if the property has
<code>sh:datatype xsd:dateTime</code>.
0 otherwise.
</p>
<p>
@@ -857,7 +862,24 @@ ex:Customer-lastVisitTime
sh:path ex:lastVisitTime ;
<b>sh:datatype xsd:dateTime ;</b>
...</pre>
- </section-->
+ </section>
+ <section id="DetailsEditor">
+ <h4>dash:DetailsEditor</h4>
+ <p>
+ <b>Score:</b>
+ <code>null</code> for
non-literals, i.e. it can be selected manually via <code>dash:editor</code>.
+ 0 otherwise.
+ </p>
+ <p>
+ <b>Rendering:</b>
+ typically rendering as a nested
form, using the properties defined by the <code>sh:node</code> or
<code>sh:class</code> (in that order)
+ of the property as fields.
+ Alternative renderings are
possible, such as opening the resource in a separate dialog.
+ </p>
+ <p>
+ This is particularly useful for
some types of blank nodes that only make sense to be edited in the context of
their parent resource.
+ </p>
+ </section>
<section id="EnumSelectEditor">
<h4>dash:EnumSelectEditor</h4>
<p>
@@ -881,7 +903,8 @@ ex:AustralianAddressShape-addressRegion
<h4>dash:InstancesSelectEditor</h4>
<p>
<b>Score:</b>
- <code>null</code> if there
exists a <code>sh:class</code> for the same property at the current focus node.
+ <code>null</code> if there
exists a <code>sh:class</code> for the property.
+ 0 otherwise.
</p>
<p>
<b>Rendering:</b>
@@ -924,6 +947,7 @@ ex:Concept-definition
20 if the value is an
<code>xsd:string</code> literal and <code>dash:singleLine false</code>.
5 if the value is an
<code>xsd:string</code> literal.
2 if the property has
<code>xsd:string</code> among the permissible datatypes.
+ <code>null</code> if the
property has a custom datatype (not from xsd or rdf namespaces but for example
<code>geo:wktLiteral</code>).
0 otherwise.
</p>
<p>