Skip to content

Commit 12aee59

Browse files
committed
More moves towards Triple Terms vs Quoted Triples.
1 parent d5b00f1 commit 12aee59

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,24 @@ Internally, an `RDF::Statement` is treated as another resource, along with `RDF:
280280

281281
**Note: This feature is subject to change or elimination as the standards process progresses.**
282282

283-
### Serializing a Graph containing quoted triples
283+
### Serializing a Graph containing triple terms
284284

285285
require 'rdf/ntriples'
286286
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
287-
graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
287+
reifier = RDF::Node.new
288+
graph = RDF::Graph.new do |g|
289+
g << [reifier, RDF.reifies, statement]
290+
g << [reifier, RDF::URI("ex:certainty"), RDF::Literal(0.9)]
291+
end
288292
graph.dump(:ntriples, validate: false)
289-
# => '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
293+
# ==> '_:bn <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>)>> .
294+
_:bn <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
290295

291-
### Reading a Graph containing quoted triples
296+
### Reading a Graph containing triple terms
292297

293298
By default, the N-Triples reader will reject a document containing a subject resource.
294299

295-
nt = '<<<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
300+
nt = '<<(<bob> <http://xmlns.com/foaf/0.1/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer>)>> <ex:certainty> "0.9"^^<http://www.w3.org/2001/XMLSchema#double> .'
296301
graph = RDF::Graph.new do |graph|
297302
RDF::NTriples::Reader.new(nt) {|reader| graph << reader}
298303
end

lib/rdf/model/statement.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def to_h(subject_key = :subject, predicate_key = :predicate, object_key = :objec
476476
def to_s
477477
(graph_name ? to_quad : to_triple).map do |term|
478478
if term.is_a?(Statement)
479-
"<<#{term.to_s[0..-3]}>>"
479+
"<<(#{term.to_s[0..-3]})>>"
480480
elsif term.respond_to?(:to_base)
481481
term.to_base
482482
else

lib/rdf/ntriples/reader.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module RDF::NTriples
3030
#
3131
# ** RDF=star
3232
#
33-
# Supports statements as resources using `<<s p o>>`.
33+
# Supports statements as resources using `<<(s p o)>>`.
3434
#
3535
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
3636
# @see http://www.w3.org/TR/n-triples/
@@ -73,8 +73,8 @@ class Reader < RDF::Reader
7373
TT_START = /^<<\(/.freeze
7474
TT_END = /^\s*\)>>/.freeze
7575

76-
QT_START = /^<</.freeze
77-
QT_END = /^\s*>>/.freeze
76+
QT_START = /^<</.freeze # DEPRECATED
77+
QT_END = /^\s*>>/.freeze # DEPRECATED
7878

7979
# @see http://www.w3.org/TR/rdf-testcases/#ntrip_grammar
8080
COMMENT = /^#\s*(.*)$/.freeze

0 commit comments

Comments
 (0)