You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2>Interoperability between RDF [=Basic=] and RDF [=Full=]</h2>
1723
-
1724
-
<pclass=issue>Should we make this section normative?</p>
1725
-
1726
-
<p>This section provides transformations between [=Full=] [=RDF graphs=] (respectively, [=RDF datasets=]) and [=Basic=] [=RDF graphs=] (respectively, [=RDF datasets=]),
1727
-
to provide some level of interoperability between the different classes of <ahref="#conformance">Conformance</a>.
1728
-
1729
-
<pclass=issue>Should we go even further and aim to provide interoperability between <em>RDF 1.1</em> and RDF 1.2 [=Full=]?</p>
1730
-
1731
-
<pclass=issue>Find a better name than "classicize" for the algorithm</p>
1732
-
1733
-
<pclass=issue>AT RISK: The Working Group may decide to replace the terms `rdf:TripleTerm`, `rdf:ttSubject`, `rdf:ttPredicate`, and `rdf:ttObject` used in this section with other terms, possibly in a different namespace.</p>
1734
-
1735
-
<p>These transformation are designed to be:</p>
1736
-
1737
-
<dl>
1738
-
<dt>Information preserving</dt>
1739
-
<dd>It must be possible to reconstruct the input graph (respectively, dataset) from the output graph (respectively, dataset).
1740
-
Note, however, that these transformations are not designed to preserve semantics:
1741
-
the output graph is not semantically [=equivalent=] to the input graph,
1742
-
at least not in the entailment regimes defined in [[RDF12-SEMANTICS]].
1743
-
</dd>
1744
-
<dt>Idempotent</dt>
1745
-
<dd>Applying a transformation several times to a graph (respectively, dataset) should have the same effect as applying it once.
1746
-
Moreover, [=classicizing=] a graph (respectively, dataset) that is already complying with RDF [=Basic=] (i.e., containing no [=triple term=]) must result in the same graph (respectively, dataset).
1747
-
</dd>
1748
-
<dt>Universal</dt>
1749
-
<dd>It should be possible to transform any [=Full=] graph (respectively, dataset) to a [=Basic=] graph (respectively, dataset) using this method.
1750
-
There is actually <ahref="#section-classicize-caveat">a minor caveat</a> to this property.
1751
-
</dd>
1752
-
</dl>
1753
-
1754
-
<sectionid="section-classicize-definition">
1755
-
<h2>From [=Full=] to [=Basic=]</h2>
1756
-
1757
-
<p>
1758
-
Encoding an [=RDF graph=] to ensure that it is consumable by an RDF [=Basic=] implementation is called <dfndata-lt="classicize|classicized">classicizing</dfn> it.
1759
-
[=Classicizing=] consists of repeating the following steps until no [=triple term=] [=appears=] in the graph, and the graph is therefore compliant with RDF [=Basic=]: picking a [=triple term=] <var>tt</var> that [=appears=] in the graph; minting a fresh [=blank node=] <var>b</var>
1760
-
(i.e., a blank node not yet in use in the graph); replacing all occurrences of <var>tt</var> [=appearing=] in the graph with <var>b</var>;
1761
-
and then adding the following triples to the graph (where <var>s</var>, <var>p</var>, and <var>o</var> are respectively the [=subject=], [=predicate=] and [=object=] of <var>tt</var>):
<p>Note that this transformation is <em>information preserving</em> only when the input graph either has no [=triple term=] [=appearing=] in it,
1771
-
or contains no [=asserted=] triple (<var>b</var>, `rdf:type`, `rdf:TripleTerm`) where <var>b</var> is a [=blank node=].
1772
-
Implementations encountering this situation MUST report an error.
1773
-
This limitation is discussed in Section <ahref="#section-classicize-caveat"></a>.
1774
-
</p>
1775
-
1776
-
<pclass=note>The blank nodes generated to replace [=triple terms=] should not be confused with the [=reifiers=] that are typically associated with these [=triple terms=].</p>
1777
-
1778
-
<p>
1779
-
[=Classicizing=] an [=RDF dataset=] consists of [=classicizing=] its [=default graph=] and each of its [=named graph=].
1780
-
In this case, the fresh [=blank node=] assigned to each [=triple term=] must not be used in any graph of the dataset.
1781
-
</p>
1782
-
1783
-
<p>
1784
-
A detailed algorithm of the transformation is found in Section <ahref="#section-classicize-algo"></a>.
1785
-
</p>
1786
-
1787
-
<sectionid="section-classicize-example">
1788
-
<h2>Example</h2>
1789
-
1790
-
<p>The examples in this section are expressed in the Turtle concrete syntax [[RDF12-TURTLE]].</p>
1791
-
1792
-
<preid="ex-classicize-input"
1793
-
class="example nohighlight"
1794
-
title="An input Full RDF graph"
1795
-
data-include="./ex-classicize-input.ttl"
1796
-
data-include-format="text"
1797
-
></pre>
1798
-
1799
-
<preid="ex-classicize-input2"
1800
-
class="example nohighlight"
1801
-
title="The same graph as above, with reifiers made explicit"
1802
-
data-include="./ex-classicize-input2.ttl"
1803
-
data-include-format="text"
1804
-
></pre>
1805
-
1806
-
<preid="ex-classicize-output"
1807
-
class="example nohighlight"
1808
-
title="The result of classicizing the dataset above"
1809
-
data-include="./ex-classicize-output.ttl"
1810
-
data-include-format="text"
1811
-
></pre>
1812
-
1813
-
</section>
1814
-
1815
-
</section>
1816
-
1817
-
<sectionid="section-unclassicize-definition">
1818
-
<h2>From [=Basic=] to [=Full=]</h2>
1819
-
1820
-
<p>Reverting a [=classicized=] graph to its original form consists of locating
1821
-
each [=asserted=] triple (<var>b</var>, `rdf:type`, `rdf:TripleTerm`)
1822
-
that has a [=blank node=] <var>b</var> as its subject,
1823
-
along with the three associated [=asserted=] triples
1824
-
that have the same [=blank node=] <var>b</var> as their subjects, i.e.,
1825
-
(<var>b</var>, `rdf:ttSubject`, <var>s</var>),
1826
-
(<var>b</var>, `rdf:ttPredicate`, <var>p</var>),
1827
-
and (<var>b</var>, `rdf:ttObject`, <var>o</var>);
1828
-
removing these four triples from the graph;
1829
-
and replacing all remaining occurrences of <var>b</var> [=appearing=] in the graph
1830
-
with the triple term (<var>s</var>, <var>p</var>, <var>o</var>).
1831
-
</p>
1832
-
1833
-
<p>An implementation MUST report an error if, for a given <var>b</var>,
1834
-
it can not unambiguously determine <var>s</var>, <var>p</var>, or <var>o</var>
1835
-
(i.e., if one of the properties of <var>b</var>
1836
-
— `rdf:ttSubject`, `rdf:ttPredicate`, or `rdf:ttObject` —
1837
-
is missing or duplicated).
1838
-
An implementation MUST also report an error if the input graph contains
1839
-
at the same time a [=triple term=] and an [=asserted triple=]
1840
-
(<var>b</var>, `rdf:type`, `rdf:TripleTerm`)
1841
-
where <var>b</var> is the same [=blank node=].
1842
-
Note that none of these situations can occur if the input graph was produced by the [=classicize=] transformation.
1843
-
</p>
1844
-
1845
-
<p>To revert a [=classicized=] [=RDF dataset=] to its original form, the transformation above is applied to its [=default graph=] and to each of its [=named graphs=].
1846
-
</p>
1847
-
1848
-
<p>Note that this transformation has no effect on any [=RDF graph=] or [=RDF dataset=] that does not use the `rdf:TripleTerm` type,
1849
-
including [=Full=] graphs or datasets containing [=triple terms=].
1850
-
This makes this transformation <em>idempotent</em> as intended.
1851
-
</p>
1852
-
</section>
1853
-
1854
-
<sectionid="section-classicize-caveat">
1855
-
<h2>Limitations</h2>
1856
-
1857
-
<p>The two transformations above explicitly do not support graphs or datasets containing at the same time a [=triple term=] and an [=asserted triple=]
1858
-
(<var>b</var>, `rdf:type`, `rdf:TripleTerm`)
1859
-
where <var>b</var> is a [=blank node=].
1860
-
This means that the [=classicize=] transformation is not <em>strictly</em> universal.
1861
-
</p>
1862
-
1863
-
<p>This limitation should not be an issue in practice.
1864
-
The `rdf:TripleTerm` type is unlikely to be in used in any published graph or dataset,
1865
-
as it was not defined prior to this specification.
1866
-
For this reason, using it would actually have been bad practice.
1867
-
For future graphs and datasets, this type should be considered to be reserved for use within the [=classicize=] transformation, and not used otherwise.
1868
-
</p>
1869
-
1870
-
<pclass=note>
1871
-
This is one reason why this transformation introduces new vocabulary terms
Unlike `rdf:TripleTerm`, `rdf:Statement` is known to be found in
1876
-
widely used datasets (e.g., <ahref="https://www.uniprot.org/">Uniprot</a>),
1877
-
so reserving its use for the [=classicize=] transformation was not an option.
1878
-
</p>
1879
-
1880
-
<p>Another consequence of this restriction is that implementers will need to be aware and careful when merging graphs in an application that [=classicizes=] graphs or datasets.
1881
-
The concern is that merging a [=Full=] [=RDF graph=] containing at least one [=triple term=]
1882
-
with a [=classicized=] [=RDF graph=] (which might contain [=blank node=] instances of `rdf:TripleTerm`)
1883
-
could result in a "hybrid" graph that cannot be transformed to a consistent [=Full=] nor [=Basic=] [=RDF graph=].
1884
-
Therefore, such applications should [=classicize=] every graph prior to merging them.
1885
-
Conversely, applications supporting RDF [=Full=] should make sure to apply the reverse transformation
1886
-
to any graph that is known or likely to have been [=classicized=],
1887
-
to avoid creating such "hybrid" graphs.
1888
-
Since these transformations are designed to be <em>idempotent</em>, there is no harm in applying them more than necessary.
<p>The algorithm expects one input variable <var>Gᵢ</var> which is an [=RDF graph=]. It returns a [=Basic=] [=RDF graph=].
1899
-
</p>
1900
-
1901
-
<ol>
1902
-
<li>Let <var>Gₒ</var> be an empty [=RDF graph=].</li>
1903
-
<li>Let <var>M</var> be an empty map from [=triple terms=] to [=blank nodes=].</li>
1904
-
<li>Let <var>inputKind</var> be `null`.</li>
1905
-
<li>For each triple (<var>s</var>, <var>p</var>, <var>o</var>) in <var>Gᵢ</var>:<ol>
1906
-
<li>If <var>s</var> is a [=blank node=], <var>p</var> is `rdf:type` and <var>o</var> is `rdf:TripleTerm`, then:<ol>
1907
-
<liid="classicize-error1">If <var>inputKind</var> is `"full"` then exit with an error.</li>
1908
-
<li>Otherwise, set <var>inputKind</var> to `"basic"`.</li>
1909
-
</ol></li>
1910
-
<li>If <var>o</var> is a [=triple term=], then:<ol>
1911
-
<liid="classicize-error2">If <var>inputKind</var> is `"basic"` then exit with an error.</li>
1912
-
<li>Otherwise, set <var>inputKind</var> to `"full"`.</li>
1913
-
<li>Let <var>b</var>, <var>M'</var> and <var>G'</var> be the result of invoking <ahref="#section-ctt-algo">`classicize-triple-term`</a> passing <var>o</var> as <var>t</var> and <var>M</var> as <var>Mi</var>.</li>
1914
-
<li>Merge <var>M'</var> into <var>M</var>.
1915
-
<li>Merge <var>G'</var> into <var>Gₒ</var>.
1916
-
<li>Set <var>o</var> to <var>b</var>.
1917
-
</ol></li>
1918
-
<li>Add the triple (<var>s</var>, <var>p</var>, <var>o</var>) to <var>Gₒ</var>.</li>
1919
-
</ol></li>
1920
-
<li>Return <var>Gₒ</var>.</li>
1921
-
</ol>
1922
-
</section>
1923
-
1924
-
<sectionid="section-ctt-algo" class="algorithm">
1925
-
<h2>The `classicize-triple-term` algorithm</h2>
1926
-
1927
-
<p>This algorithm is responsible for incrementally populating the mapping <var>M</var> and the graph <var>G</var> used internally by the <ahref="#section-classicize-algo">`classicize`</a> algorithm. It receives a [=triple term=] as input and processes it recursively (in case its object is itself a [=triple term=]). It returns, among other things, the [=blank node=] minted to replace the [=triple term=] in the transformed [=Basic=] [=RDF graph=].</p>
1928
-
1929
-
<p>This algorithm expects two input variables:
1930
-
a [=triple term=] <var>t</var>,
1931
-
and a map <var>Mᵢ</var> from [=triple terms=] to [=blank nodes=].
1932
-
It returns a [=blank node=] <var>b</var>,
1933
-
a map <var>Mₒ</var> from [=triple terms=] to [=blank nodes=],
1934
-
and a [=Basic=] [=RDF graph=] <var>G</var>.
1935
-
</p>
1936
-
1937
-
<ol>
1938
-
<li>Let <var>Mₒ</var> be an empty map.</li>
1939
-
<li>Let <var>G</var> be an empty [=RDF graph=].</li>
1940
-
<li>Let <var>b</var> be the [=blank node=] associated with <var>t</var> in <var>Mᵢ</var>, if any.
1941
-
<li>Otherwise:<ol>
1942
-
<li>Let <var>s</var>, <var>p</var> and <var>o</var> be the subject, predicate and object of <var>t</var>, respectively.</li>
1943
-
<li>If <var>o</var> is a [=triple term=], then:<ol>
1944
-
<li>Let <var>b'</var>, <var>M'</var> and <var>G'</var> be the result of invoking <ahref="#section-ctt-algo">`classicize-triple-term`</a> passing <var>o</var> as <var>t</var> and <var>Mᵢ</var>.</li>
1945
-
<li>Set <var>o</var> to <var>b'</var>.
1946
-
<li>Merge <var>M'</var> into <var>Mₒ</var>.
1947
-
<li>Merge <var>G'</var> into <var>G</var>.
1948
-
</ol></li>
1949
-
<liid="qtt-fresh-bnode">Let <var>b</var> be a fresh blank node.</li>
1950
-
<li>Add the association (<var>t</var>, <var>b</var>) to <var>Mₒ</var>.</li>
1951
-
<li>Add the triples (<var>b</var>, `rdf:type`, `rdf:TripleTerm`), (<var>b</var>, `rdf:ttSubject`, <var>s</var>), (<var>b</var>, `rdf:ttPredicate`, <var>p</var>), and (<var>b</var>, `rdf:ttObject`, <var>o</var>) in <var>G</var>.</li>
1952
-
</ol></li>
1953
-
<li>Return <var>b</var>, <var>Mₒ</var> and <var>G</var>.</li>
0 commit comments