/usr/share/doc/python-rdflib-doc/html/upgrade3to4.html is in python-rdflib-doc 4.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upgrading from RDFLib version 3.X to 4.X — rdflib 4.2.1 documentation</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<link rel="stylesheet" href="_static/rtd.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '4.2.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/searchtools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="rdflib 4.2.1 documentation" href="index.html" />
<link rel="next" title="Upgrading from RDFLib version 2.X to 3.X" href="upgrade2to3.html" />
<link rel="prev" title="Merging graphs" href="merging.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="upgrade2to3.html" title="Upgrading from RDFLib version 2.X to 3.X"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="merging.html" title="Merging graphs"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">rdflib 4.2.1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="upgrading-from-rdflib-version-3-x-to-4-x">
<h1>Upgrading from RDFLib version 3.X to 4.X<a class="headerlink" href="#upgrading-from-rdflib-version-3-x-to-4-x" title="Permalink to this headline">¶</a></h1>
<p>RDFLib version 4.0 introduced a small number of backwards compatible changes that you should know about when porting code from version 3 or earlier.</p>
<div class="section" id="sparql-and-sparqlstore-are-now-included-in-core">
<h2>SPARQL and SPARQLStore are now included in core<a class="headerlink" href="#sparql-and-sparqlstore-are-now-included-in-core" title="Permalink to this headline">¶</a></h2>
<p>For version 4.0 we’ve merged the SPARQL implementation from <code class="docutils literal"><span class="pre">rdflib-sparql</span></code>, the SPARQL(Update)Store from <code class="docutils literal"><span class="pre">rdflib-sparqlstore</span></code> and miscellaneous utilities from <code class="docutils literal"><span class="pre">rdfextras</span></code>. If you used any of these previously, everything you need should now be included.</p>
</div>
<div class="section" id="datatyped-literals">
<h2>Datatyped literals<a class="headerlink" href="#datatyped-literals" title="Permalink to this headline">¶</a></h2>
<p>We separate lexical and value space operations for datatyped literals.</p>
<p>This mainly affects the way datatyped literals are compared. Lexical space comparisons are done by default for <code class="docutils literal"><span class="pre">==</span></code> and <code class="docutils literal"><span class="pre">!=</span></code>, meaning the exact lexical representation and the exact data-types have to match for literals to be equal. Value space comparisons are also available through the <a class="reference internal" href="apidocs/rdflib.html#rdflib.term.Identifier.eq" title="rdflib.term.Identifier.eq"><code class="xref py py-meth docutils literal"><span class="pre">rdflib.term.Identifier.eq()</span></code></a> and <a class="reference internal" href="apidocs/rdflib.html#rdflib.term.Identifier.neq" title="rdflib.term.Identifier.neq"><code class="xref py py-meth docutils literal"><span class="pre">rdflib.term.Identifier.neq()</span></code></a> methods, <code class="docutils literal"><span class="pre"><</span> <span class="pre">></span> <span class="pre"><=</span> <span class="pre">>=</span></code> are also done in value space.</p>
<p>Most things now work in a fairly sane and sensible way, if you do not have existing stores/intermediate stored sorted lists, or hash-dependent something-or-other, you should be good to go.</p>
<p>Things to watch out for:</p>
<div class="section" id="literals-no-longer-compare-equal-across-data-types-with">
<h3>Literals no longer compare equal across data-types with <code class="docutils literal"><span class="pre">`==`</span></code><a class="headerlink" href="#literals-no-longer-compare-equal-across-data-types-with" title="Permalink to this headline">¶</a></h3>
<p>i.e.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">Literal</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">datatype</span><span class="o">=</span><span class="n">XSD</span><span class="o">.</span><span class="n">int</span><span class="p">)</span> <span class="o">==</span> <span class="n">Literal</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">datatype</span><span class="o">=</span><span class="n">XSD</span><span class="o">.</span><span class="n">float</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
<p>But a new method <a class="reference internal" href="apidocs/rdflib.html#rdflib.term.Identifier.eq" title="rdflib.term.Identifier.eq"><code class="xref py py-meth docutils literal"><span class="pre">rdflib.term.Identifier.eq()</span></code></a> on all Nodes has been introduced, which does semantic equality checking, i.e.:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">Literal</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">datatype</span><span class="o">=</span><span class="n">XSD</span><span class="o">.</span><span class="n">int</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span><span class="n">Literal</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">datatype</span><span class="o">=</span><span class="n">XSD</span><span class="o">.</span><span class="n">float</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<p>The <code class="docutils literal"><span class="pre">eq</span></code> method is still limited to what data-types map to the same <em>value space</em>, i.e. all numeric types map to numbers and will compare, <code class="docutils literal"><span class="pre">xsd:string</span></code> and <code class="docutils literal"><span class="pre">plain</span> <span class="pre">literals</span></code> both map to strings and compare fine, but:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">Literal</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">datatype</span><span class="o">=</span><span class="n">XSD</span><span class="o">.</span><span class="n">int</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span><span class="n">Literal</span><span class="p">(</span><span class="s1">'2'</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
</div>
<div class="section" id="literals-will-be-normalised-according-to-datatype">
<h3>Literals will be normalised according to datatype<a class="headerlink" href="#literals-will-be-normalised-according-to-datatype" title="Permalink to this headline">¶</a></h3>
<p>If you care about the exact lexical representation of a literal, and not just the value. Either set <code class="xref py py-data docutils literal"><span class="pre">rdflib.NORMALIZE_LITERALS</span></code> to <code class="docutils literal"><span class="pre">False</span></code> before creating your literal, or pass <code class="docutils literal"><span class="pre">normalize=False</span></code> to the Literal constructor</p>
</div>
<div class="section" id="ordering-of-literals-and-nodes-has-changed">
<h3>Ordering of literals and nodes has changed<a class="headerlink" href="#ordering-of-literals-and-nodes-has-changed" title="Permalink to this headline">¶</a></h3>
<p>Comparing literals with <code class="docutils literal"><span class="pre"><,</span> <span class="pre">>,</span> <span class="pre"><=,</span> <span class="pre">>=</span></code> now work same as in SPARQL filter expressions.</p>
<p>Greater-than/less-than ordering comparisons are also done in value space, when compatible datatypes are used.
Incompatible datatypes are ordered by data-type, or by lang-tag.
For other nodes the ordering is <code class="docutils literal"><span class="pre">None</span> <span class="pre"><</span> <span class="pre">BNode</span> <span class="pre"><</span> <span class="pre">URIRef</span> <span class="pre"><</span> <span class="pre">Literal</span></code></p>
<p>Any comparison with non-rdflib Node are <code class="docutils literal"><span class="pre">NotImplemented</span></code>
In PY2.X some stable order will be made up by python.
In PY3 this is an error.</p>
</div>
<div class="section" id="custom-mapping-of-datatypes-to-python-objects">
<h3>Custom mapping of datatypes to python objects<a class="headerlink" href="#custom-mapping-of-datatypes-to-python-objects" title="Permalink to this headline">¶</a></h3>
<p>You can add new mappings of datatype URIs to python objects using the <a class="reference internal" href="apidocs/rdflib.html#rdflib.term.bind" title="rdflib.term.bind"><code class="xref py py-func docutils literal"><span class="pre">rdflib.term.bind()</span></code></a> method.
This also allows you to specify a constructor for constructing objects from the lexical string representation, and a serialization method for generating a lexical string representation from an object.</p>
</div>
</div>
<div class="section" id="minor-changes">
<h2>Minor Changes<a class="headerlink" href="#minor-changes" title="Permalink to this headline">¶</a></h2>
<ul>
<li><p class="first"><a class="reference internal" href="apidocs/rdflib.html#rdflib.namespace.Namespace" title="rdflib.namespace.Namespace"><code class="xref py py-class docutils literal"><span class="pre">rdflib.namespace.Namespace</span></code></a> is no longer a sub-class of <a class="reference internal" href="apidocs/rdflib.html#rdflib.term.URIRef" title="rdflib.term.URIRef"><code class="xref py py-class docutils literal"><span class="pre">rdflib.term.URIRef</span></code></a>
this was changed as it makes no sense for a namespace to be a node in a graph, and was causing numerous bug. Unless you do something very special, you should not notice this change.</p>
</li>
<li><p class="first">The identifiers for Graphs are now converted to URIRefs if they are not a <a class="reference internal" href="apidocs/rdflib.html#rdflib.term.Node" title="rdflib.term.Node"><code class="xref py py-class docutils literal"><span class="pre">rdflib.term.Node</span></code></a>, i.e. no more graphs with string identifiers. Again, unless you do something quite unusual, you should not notice.</p>
</li>
<li><p class="first">String concatenation with URIRefs now returns URIRefs, not strings:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">URIRef</span><span class="p">(</span><span class="s2">"http://example.org/people/"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"Bill"</span>
</pre></div>
</div>
<p>rdflib.term.URIRef(u’<a class="reference external" href="http://example.org/people/Bill">http://example.org/people/Bill</a>‘)</p>
<p>This is be convenient, but may cause trouble if you expected a string.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/logo.svg" alt="Logo"/>
</a></p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Upgrading from RDFLib version 3.X to 4.X</a><ul>
<li><a class="reference internal" href="#sparql-and-sparqlstore-are-now-included-in-core">SPARQL and SPARQLStore are now included in core</a></li>
<li><a class="reference internal" href="#datatyped-literals">Datatyped literals</a><ul>
<li><a class="reference internal" href="#literals-no-longer-compare-equal-across-data-types-with">Literals no longer compare equal across data-types with <code class="docutils literal"><span class="pre">`==`</span></code></a></li>
<li><a class="reference internal" href="#literals-will-be-normalised-according-to-datatype">Literals will be normalised according to datatype</a></li>
<li><a class="reference internal" href="#ordering-of-literals-and-nodes-has-changed">Ordering of literals and nodes has changed</a></li>
<li><a class="reference internal" href="#custom-mapping-of-datatypes-to-python-objects">Custom mapping of datatypes to python objects</a></li>
</ul>
</li>
<li><a class="reference internal" href="#minor-changes">Minor Changes</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="merging.html"
title="previous chapter">Merging graphs</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="upgrade2to3.html"
title="next chapter">Upgrading from RDFLib version 2.X to 3.X</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/upgrade3to4.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="upgrade2to3.html" title="Upgrading from RDFLib version 2.X to 3.X"
>next</a> |</li>
<li class="right" >
<a href="merging.html" title="Merging graphs"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">rdflib 4.2.1 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2016 - 2013, RDFLib Team.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.4.9.
<br />Theme based on <a href="http://readthedocs.org/">Read The Docs</a>
</div>
</body>
</html>
|