Skip to content

Commit b7fdd1a

Browse files
committed
Turtle-style version announcement.
1 parent 3afa645 commit b7fdd1a

File tree

3 files changed

+117
-71
lines changed

3 files changed

+117
-71
lines changed

spec/index.html

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ <h2>TriG Language</h2>
175175
and <a href="#sec-parsing" class="sectionRef"></a>.
176176
</p>
177177

178+
<section id="sec-version">
179+
<h3>Version Announcement</h3>
180+
<p>TriG uses the same version announcement mechanism as Turtle [[RDF12-TURTLE]].</p>
181+
</section>
182+
178183
<section id="sec-triple-statements">
179184
<h3>Triple Statements</h3>
180185
<p>As TriG is an extention of the Turtle language it allows for any constructs from the
@@ -301,6 +306,7 @@ <h3>Triple Terms</h3>
301306
<pre id="ex-triple-term" class="example turtle" data-transform="updateExample"
302307
title="Triple Term">
303308
<!--
309+
VERSION "1.2"
304310
PREFIX : <http://www.example.org/>
305311
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
306312
@@ -381,8 +387,12 @@ <h3>White Space</h3>
381387
<h3>Comments</h3>
382388

383389
<p>Comments in TriG start with a <a href="#cp-number-sign"><code title="number sign">#</code></a> outside an
384-
<a href="#grammar-production-IRIREF"><code>IRIREF</code></a> or <a href="#grammar-production-String"><code>String</code></a>,
385-
and continue to the end of line (marked by
390+
<a href="#grammar-production-IRIREF" ><code>IRIREF</code> </a>,
391+
<a href="#grammar-production-STRING_LITERAL_SINGLE_QUOTE" ><code>STRING_LITERAL_SINGLE_QUOTE</code> </a>,
392+
<a href="#grammar-production-STRING_LITERAL_QUOTE" ><code>STRING_LITERAL_QUOTE</code> </a>,
393+
<a href="#grammar-production-STRING_LITERAL_LONG_SINGLE_QUOTE"><code>STRING_LITERAL_LONG_SINGLE_QUOTE</code></a>, or
394+
<a href="#grammar-production-STRING_LITERAL_LONG_QUOTE" ><code>STRING_LITERAL_LONG_QUOTE</code> </a>,
395+
and continue to the end of line (marked by
386396
<a href="#cp-line-feed"><code title="line feed">LF</code></a>, or
387397
<a href="#cp-carriage-return"><code title="carriage return">CR</code></a>),
388398
or end of file if there is no end of line after the comment marker.
@@ -608,14 +618,15 @@ <h3>Grammar</h3>
608618
Keywords in single quotes
609619
('<code class="grammar-literal">@base</code>',
610620
'<code class="grammar-literal">@prefix</code>',
621+
'<code class="grammar-version">@version</code>',
611622
'<code class="grammar-literal">a</code>',
612-
'<code class="grammar-literal">true</code>',
623+
'<code class="grammar-literal">true</code>', and
613624
'<code class="grammar-literal">false</code>')
614625
are case-sensitive.
615626
Keywords in quotation marks
616627
("<code class="grammar-literal">BASE</code>",
617-
"<code class="grammar-literal">PREFIX</code>",
618-
"<code class="grammar-graph">GRAPH</code>")
628+
"<code class="grammar-literal">PREFIX</code>"), and
629+
"<code class="grammar-literal">VERSION</code>")
619630
are case-insensitive.
620631
</li>
621632
<li>
@@ -637,11 +648,12 @@ <h3>Grammar</h3>
637648
In signed numbers, no white space is allowed between the sign and the number.
638649
</li>
639650
<li>
640-
The strings '<a href="#grammar-production-prefixID"><code class="grammar-literal">@prefix</code></a>'
641-
and '<a href="#grammar-production-base"><code class="grammar-literal">@base</code></a>'
651+
The strings '<a href="#grammar-production-prefixID"><code class="grammar-literal">@prefix</code></a>',
652+
'<a href="#grammar-production-base"><code class="grammar-literal">@base</code></a>', and
653+
'<a href="#grammar-production-version"><code class="grammar-literal">@version</code></a>'
642654
match the pattern for <a href="#grammar-production-LANG_DIR"><code>LANG_DIR</code></a>,
643-
though neither <code class="grammar-literal">prefix</code>
644-
nor <code class="grammar-literal">base</code>
655+
though neither <code class="grammar-literal">prefix</code>,
656+
<code class="grammar-literal">base</code>, nor <code class="grammar-literal">version</code>
645657
are <a data-cite="?LANG-SUBTAG-REGISTRY#">registered language subtags</a>.
646658
This specification does not define whether a quoted literal
647659
followed by either of these tokens (e.g., <code>"A"@base</code>)
@@ -772,7 +784,7 @@ <h2>Parsing</h2>
772784

773785
<section id="sec-parsing-state">
774786
<h3>Parser State</h3>
775-
<p>Parsing TriG requires a state of nine items:</p>
787+
<p>Parsing TriG requires a state of ten items:</p>
776788

777789
<ul>
778790
<li id="baseURI">IRI |baseURI|
@@ -821,6 +833,12 @@ <h3>Parser State</h3>
821833
produced in parsing. When undefined, triples are destined
822834
for the <a data-cite="RDF12-CONCEPTS#dfn-default-graph">default graph</a>.
823835
</li>
836+
<li id="curVersion">`xsd:string` |curVersion| –
837+
The RDF version used for parsing the document into <a data-cite="RDF12-CONCEPTS#dfn-rdf-triple">Triples</a>.
838+
If specified as part of a <a href="#sec-mediaReg">Media Type</a>, the default value for |curVersion| is taken from the `version` parameter.
839+
The only defined value is `"1.2"`. Parser behavior for other version values is undefined.
840+
This specification does not define behavior if different versions are provided for |curVersion|.
841+
</li>
824842
</ul>
825843

826844
<p>Term Constructors can create a stack of these values indicated by
@@ -835,14 +853,14 @@ <h3>RDF Term Constructors</h3>
835853

836854
<table id="tab-term-constructors" class="separated">
837855
<thead>
838-
<tr> <th> production </th><th> type </th><th>procedure</th></tr>
856+
<tr> <th> production </th><th> type </th><th>procedure</th></tr>
839857
</thead>
840858
<tbody>
841859
<tr id="handle-IRIREF" ><td style="text-align:left;" ><a class="type IRI" href="#grammar-production-IRIREF" >IRIREF </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri"> IRI </a></td><td>The characters between "&lt;" and "&gt;" are taken, after the <a href="#numeric">numeric escape sequences</a> are processed, to form the Unicode string of the IRI. <a data-cite="RDF12-CONCEPTS#dfn-relative-iri">Relative IRI reference</a> resolution is performed per <a href="#sec-iri-references" class="sectionRef"></a>.</td></tr>
842860
<tr id="handle-PNAME_NS" ><td style="text-align:left;" rowspan="2"><a class="type string" href="#grammar-production-PNAME_NS" >PNAME_NS </a></td><td><a href="#prefix"> prefix </a></td><td>When used in a <a href="#grammar-production-prefixID"><code>prefixID</code></a> or <a href="#grammar-production-sparqlPrefix"><code>sparqlPrefix</code></a> production, the <code>prefix</code> is the potentially empty Unicode string matching the first argument of the rule is a key into the <a href="#namespaces">namespaces map</a>.</td></tr>
843861
<tr id="handle-PNAME-IRI" > <td><a data-cite="RDF12-CONCEPTS#dfn-iri"> IRI </a></td><td>When used in a <a href="#grammar-production-PrefixedName"><code>PrefixedName</code></a> production, the <code>iri</code> is the value in the <a href="#namespaces">namespaces map</a> corresponding to the first argument of the rule.</td></tr>
844862
<tr id="handle-PNAME_LN" ><td style="text-align:left;" ><a class="type IRI" href="#grammar-production-PNAME_LN" >PNAME_LN </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri"> IRI </a></td><td>A potentially empty <a href="#prefix">prefix</a> is identified by the first sequence, <a href="#grammar-production-PNAME_NS"><code>PNAME_NS</code></a>. The <a href="#namespaces">namespaces map</a> <em class="rfc2119">MUST</em> have a corresponding <code>namespace</code>. The Unicode string of the IRI is formed by unescaping the <a href="#reserved">reserved characters</a> in the second argument, <a href="#grammar-production-PN_LOCAL"><code>PN_LOCAL</code></a>, and concatenating this onto the <code>namespace</code>.</td></tr>
845-
<!-- tr id="handle-PrefixedName" ><td style="text-align:left;" ><a class="type IRI" href="#grammar-production-PrefixedName" >PrefixedName </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-iri"> IRI </a></td><td>.</td></tr -->
863+
<tr id="handle-VersionSpecifier" ><td style="text-align:left;" ><a class="type literal" href="#grammar-production-VersionSpecifier" >VersionSpecifier </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-literal"> literal </a></td><td>The |curVersion| is taken from a literal using the matched <a data-cite="RDF12-CONCEPTS#dfn-rdf-string">RDF string</a> lexical form and `xsd:string` datatype.</td></tr>
846864
<tr id="handle-STRING_LITERAL_SINGLE_QUOTE" ><td style="text-align:left;" ><a class="type lexicalForm" href="#grammar-production-STRING_LITERAL_SINGLE_QUOTE" >STRING_LITERAL_SINGLE_QUOTE </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-lexical-form">lexical form</a></td><td>The characters between the outermost <a href="#cp-apostrophe"><code title="apostrophe">'</code></a>s are taken, with <a href="#numeric">numeric</a> and <a href="#string">string</a> escape sequences unescaped, to form the Unicode string of a lexical form.</td></tr>
847865
<tr id="handle-STRING_LITERAL_QUOTE" ><td style="text-align:left;" ><a class="type lexicalForm" href="#grammar-production-STRING_LITERAL_QUOTE" >STRING_LITERAL_QUOTE </a></td><td><a data-cite="RDF12-CONCEPTS#dfn-lexical-form">lexical form</a></td><td>The characters between the outermost <a href="#cp-quotation-mark"><code title="quotation mark">&quot;</code></a>s are taken, with <a href="#numeric">numeric</a> and <a href="#string">string</a> escape sequences unescaped, to form the Unicode string of a lexical form.</td></tr>
848866
<tr id="handle-STRING_LITERAL_LONG_SINGLE_QUOTE"><td style="text-align:left;" ><a class="type lexicalForm" href="#grammar-production-STRING_LITERAL_LONG_SINGLE_QUOTE">STRING_LITERAL_LONG_SINGLE_QUOTE</a></td><td><a data-cite="RDF12-CONCEPTS#dfn-lexical-form">lexical form</a></td><td>The characters between the outermost <a href="#cp-triple-apostrophe"><code>'''</code></a>s are taken, with <a href="#numeric">numeric</a> and <a href="#string">string</a> escape sequences unescaped, to form the unicode string of a lexical form.</td></tr>
@@ -1137,7 +1155,7 @@ <h2>Internet Media Type, File Extension and Macintosh File Type</h2>
11371155
<dt>Required parameters:</dt>
11381156
<dd>None</dd>
11391157
<dt>Optional parameters:</dt>
1140-
<dd>None</dd>
1158+
<dd><code>version</code> — this parameter is required when using RDF 1.2-specific features. If present, the value of <code>version</code> is always <code>"1.2"</code>.</dd>
11411159

11421160
<dt>Encoding considerations:</dt>
11431161
<dd>The syntax of TriG is expressed over code points in Unicode [[!UNICODE]]. The encoding is always UTF-8 [[!UTF-8]].</dd>
@@ -1221,6 +1239,13 @@ <h2>Changes between RDF 1.1 and RDF 1.2</h2>
12211239
<li>Added <a href="#triple-terms" class="sectionRef">Triple Terms</a> for representing
12221240
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> in TriG.</li>
12231241
<li>Removed the `NIL` terminal production from the grammar, which was unused.</li>
1242+
<li>Added <a href="#sec-version"></a> and parser
1243+
state and productions to announce the RDF version
1244+
associated with the input document.
1245+
Note that this also includes a provision that `@version` does not match
1246+
<a href="#grammar-production-LANG_DIR" class="type langDir"><code>LANG_DIR</code></a>;
1247+
the previous version of the grammar would allow such a match,
1248+
but would result in a literal with an ill-formed language tag according to [[BCP47]], and form an invalid literal.</li>
12241249
</ul>
12251250
</section>
12261251

0 commit comments

Comments
 (0)