diff --git a/README.md b/README.md index ea24b6d2..21e1e72e 100644 --- a/README.md +++ b/README.md @@ -280,19 +280,24 @@ Internally, an `RDF::Statement` is treated as another resource, along with `RDF: **Note: This feature is subject to change or elimination as the standards process progresses.** -### Serializing a Graph containing quoted triples +### Serializing a Graph containing triple terms require 'rdf/ntriples' statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23)) - graph = RDF::Graph.new << [statement, RDF::URI("ex:certainty"), RDF::Literal(0.9)] + reifier = RDF::Node.new + graph = RDF::Graph.new do |g| + g << [reifier, RDF.reifies, statement] + g << [reifier, RDF::URI("ex:certainty"), RDF::Literal(0.9)] + end graph.dump(:ntriples, validate: false) - # => '<< "23"^^>> "0.9"^^ .' + # ==> '_:bn <<( "23"^^)>> . + _:bn "0.9"^^ .' -### Reading a Graph containing quoted triples +### Reading a Graph containing triple terms By default, the N-Triples reader will reject a document containing a subject resource. - nt = '<< "23"^^>> "0.9"^^ .' + nt = '<<( "23"^^)>> "0.9"^^ .' graph = RDF::Graph.new do |graph| RDF::NTriples::Reader.new(nt) {|reader| graph << reader} end diff --git a/lib/rdf/model/statement.rb b/lib/rdf/model/statement.rb index dffdd3a4..4ae025da 100644 --- a/lib/rdf/model/statement.rb +++ b/lib/rdf/model/statement.rb @@ -476,7 +476,7 @@ def to_h(subject_key = :subject, predicate_key = :predicate, object_key = :objec def to_s (graph_name ? to_quad : to_triple).map do |term| if term.is_a?(Statement) - "<<#{term.to_s[0..-3]}>>" + "<<(#{term.to_s[0..-3]})>>" elsif term.respond_to?(:to_base) term.to_base else diff --git a/lib/rdf/ntriples/reader.rb b/lib/rdf/ntriples/reader.rb index 54b90d72..d8f65548 100644 --- a/lib/rdf/ntriples/reader.rb +++ b/lib/rdf/ntriples/reader.rb @@ -30,7 +30,7 @@ module RDF::NTriples # # ** RDF=star # - # Supports statements as resources using `<>`. + # Supports statements as resources using `<<(s p o)>>`. # # @see http://www.w3.org/TR/rdf-testcases/#ntriples # @see http://www.w3.org/TR/n-triples/ @@ -73,8 +73,8 @@ class Reader < RDF::Reader TT_START = /^<<\(/.freeze TT_END = /^\s*\)>>/.freeze - QT_START = /^<>/.freeze + QT_START = /^<>/.freeze # DEPRECATED # @see http://www.w3.org/TR/rdf-testcases/#ntrip_grammar COMMENT = /^#\s*(.*)$/.freeze