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
Copy file name to clipboardExpand all lines: docs/index.rst
+5-30Lines changed: 5 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,18 +8,19 @@ RDFLib is a pure Python package for working with `RDF <http://www.w3.org/RDF/>`_
8
8
9
9
* **Parsers & Serializers**
10
10
11
-
* for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, JSON-LD, RDFa and Microdata
11
+
* for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, JSON-LD, HexTuples, RDFa and Microdata
12
12
13
13
14
14
* **Store implementations**
15
15
16
-
* for in-memory and persistent RDF storage, including remote SPARQL endpoints
16
+
* memory stores
17
+
* persistent, on-disk stores, using databases such as BerkeleyDB
18
+
* remote SPARQL endpoints
17
19
18
20
* **Graph interface**
19
21
20
22
* to a single graph
21
-
* or a conjunctive graph (multiple Named Graphs)
22
-
* or a dataset of graphs
23
+
* or to multiple Named Graphs within a dataset
23
24
24
25
* **SPARQL 1.1 implementation**
25
26
@@ -108,29 +109,3 @@ the tag ``[rdflib]``. A list of existing ``[rdflib]`` tagged questions is kept t
108
109
You might also like to join rdflib's dev mailing list: `<https://groups.google.com/group/rdflib-dev>`__
109
110
110
111
The chat is available at `gitter <https://gitter.im/RDFLib/rdflib>`_ or via matrix `#RDFLib_rdflib:gitter.im <https://matrix.to/#/#RDFLib_rdflib:gitter.im>`_.
111
-
112
-
113
-
114
-
Glossary
115
-
--------
116
-
117
-
Here are a few RDF and Python terms referred to in this documentation. They are linked to wherever they occur.
118
-
119
-
.. glossary::
120
-
121
-
functional property
122
-
Properties than can only occur once for a resource, i.e. for any relation (triple, in RDF) ``x p y``,
123
-
if ``p`` is functional, for any individual ``x``, there can be at most one individual ``y``.
124
-
125
-
OWL
126
-
The OWL 2 Web Ontology Language, informally OWL 2 or just OWL, is an ontology language for the Semantic Web
127
-
with formally defined meaning. OWL 2 ontologies provide classes, properties, individuals, and data values and
128
-
are stored as Semantic Web documents. OWL 2 ontologies can be used along with information written in RDF, and
129
-
OWL 2 ontologies themselves are primarily exchanged as RDF documents. See the `RDF 1.1 Concepts and Abstract
130
-
Syntax <https://www.w3.org/TR/rdf11-concepts/>`_ for more info.
131
-
132
-
RDF
133
-
The Resource Description Framework (RDF) is a framework for representing information in the Web. RDF data is
134
-
stored in graphs that are sets of subject-predicate-object triples, where the elements may be IRIs, blank nodes,
135
-
or datatyped literals. See the `OWL 2 Web Ontology Language
136
-
Document Overview <http://www.w3.org/TR/owl-overview/>`_ for more info.
# use dict notation for things that are not valid Python identifiers, e.g.:
17
+
n['first%20name'] # as rdflib.term.URIRef("http://example.org/first%20name")
19
18
20
-
Note that if a name string is valid for use in an RDF namespace but not valid as a Python identifier, such as '1234', it must be addressed with the "item" syntax (using the "attribute" syntax will raise a Syntax Error).
19
+
These two styles of namespace creation - object attribute and dict - are equivalent and are made available just to allow for valid
20
+
RDF namespaces and URIs that are not valid Python identifiers. This isn't just for syntactic things like spaces, as per
21
+
the example of ``first%20name`` above, but also for Python reserved words like ``class`` or ``while``, so for the URI
22
+
``http://example.org/class``, create it with ``EX['class']``, not ``EX.class``.
21
23
22
-
The ``namespace`` module also defines many common namespaces such as RDF, RDFS, OWL, FOAF, SKOS, PROF, etc.
24
+
Common Namespaces
25
+
-----------------
23
26
24
-
Namespaces can also be associated with prefixes, in a :class:`rdflib.namespace.NamespaceManager`, i.e. using ``foaf`` for ``http://xmlns.com/foaf/0.1/``. Each RDFLib graph has a :attr:`~rdflib.graph.Graph.namespace_manager` that keeps a list of namespace to prefix mappings. The namespace manager is populated when reading in RDF, and these prefixes are used when serialising RDF, or when parsing SPARQL queries. Additional prefixes can be bound with the :meth:`rdflib.graph.bind` method.
27
+
The ``namespace`` module defines many common namespaces such as RDF, RDFS, OWL, FOAF, SKOS, PROF, etc. The list of the
28
+
namespaces provided grows with user contributions to RDFLib.
25
29
26
-
NamespaceManager
27
-
----------------
30
+
These Namespaces, and any others that users define, can also be associated with prefixes using the :class:`rdflib.namespace.NamespaceManager`, e.g. using ``foaf`` for ``http://xmlns.com/foaf/0.1/``.
28
31
32
+
Each RDFLib graph has a :attr:`~rdflib.graph.Graph.namespace_manager` that keeps a list of namespace to prefix mappings. The namespace manager is populated when reading in RDF, and these prefixes are used when serialising RDF, or when parsing SPARQL queries. Prefixes can be bound with the :meth:`rdflib.graph.bind` method::
29
33
30
-
Each graph comes with a `NamespaceManager`__ instance in the `namespace_manager` field; you can use the `bind` method of this instance to bind a prefix to a namespace URI::
34
+
from rdflib import Graph, Namespace
35
+
from rdflib.namespace import FOAF
36
+
37
+
EX = Namespace("http://example.org/")
38
+
39
+
g = Graph()
40
+
g.bind("foaf", FOAF) # bind an RDFLib-provided namespace to a prefix
41
+
g.bind("ex", EX) # bind a user-declared namespace to a prefix
The :meth:`rdflib.graph.bind` method is actually supplied by the :class:`rdflib.namespace.NamespaceManager` class - see next.
34
45
35
-
It has a method to normalize a given url :
46
+
NamespaceManager
47
+
----------------
36
48
37
-
myGraph.namespace_manager.normalizeUri(t)
49
+
Each RDFLib graph comes with a :class:`rdflib.namespace.NamespaceManager` instance in the `namespace_manager` field; you can use the `bind` method of this instance to bind a prefix to a namespace URI,
50
+
as above, however note that the `NamespaceManager` automatically performs some bindings according to a selected strategy.
51
+
52
+
Namespace binding strategies are indicated with the `bind_namespaces` input parameter to `NamespaceManager` instances
53
+
and may be set via ``Graph`` also::
54
+
55
+
from rdflib import Graph
56
+
from rdflib.namespace import NamespaceManager
57
+
58
+
g = Graph(bind_namespaces="rdflib") # bind via Graph
59
+
60
+
g2 = Graph()
61
+
nm = NamespaceManager(g2, bind_namespaces="rdflib") # bind via NamespaceManager
62
+
63
+
64
+
Valid strategies are:
65
+
66
+
* core:
67
+
* binds several core RDF prefixes only
68
+
* owl, rdf, rdfs, xsd, xml from the NAMESPACE_PREFIXES_CORE object
69
+
* this is default
70
+
* rdflib:
71
+
* binds all the namespaces shipped with RDFLib as DefinedNamespace instances
72
+
* all the core namespaces and all the following: brick, csvw, dc, dcat
0 commit comments