lib/rdf/reasoner/schema.rb in rdf-reasoner-0.0.4 vs lib/rdf/reasoner/schema.rb in rdf-reasoner-0.1.0
- old
+ new
@@ -65,10 +65,12 @@
##
# Schema.org requires that if the property has a range, and the resource has a type that some type matches some range. If the resource is a datatyped Literal, and the range includes a datatype, the resource must be consistent with that.
#
# If `resource` is of type `schema:Role`, it is range acceptable if it has the same property with an acceptable value.
#
+ # If `resource` is of type `rdf:List` (must be previously entailed), it is range acceptable if all members of the list are otherwise range acceptable on the same property.
+ #
# Also, a plain literal (or schema:Text) is always compatible with an object range.
#
# @param [RDF::Resource] resource
# @param [RDF::Queryable] queryable
# @param [Hash{Symbol => Object}] options ({})
@@ -154,14 +156,20 @@
# Every range must match some entailed type
resource_acceptable = Array(types).empty? || ranges.any? {|d| types.include?(d)}
# Resource may still be acceptable if it has the same property with an acceptable value
resource_acceptable ||
- types.include?(RDF::SCHEMA.Role) &&
- queryable.query(subject: resource, predicate: self).any? do |stmt|
- acc = self.range_compatible_schema?(stmt.object, queryable)
- acc
- end
+
+ # Resource also acceptable if it is a Role, and the Role object contains the same predicate having a compatible object
+ types.include?(RDF::SCHEMA.Role) &&
+ queryable.query(subject: resource, predicate: self).any? do |stmt|
+ acc = self.range_compatible_schema?(stmt.object, queryable)
+ acc
+ end ||
+ # Resource also acceptable if it is a List, and every member of the list is range compatible with the predicate
+ (list = RDF::List.new(resource, queryable)).valid? && list.all? do |member|
+ self.range_compatible_schema?(member, queryable)
+ end
end
else
true
end
end
\ No newline at end of file