diff options
author | Graham Higgins <gjh@bel-epa.com> | 2012-01-12 03:32:08 +0000 |
---|---|---|
committer | Graham Higgins <gjh@bel-epa.com> | 2012-01-12 03:32:08 +0000 |
commit | 5b142d0d00acdc4cba091ac4422a85f498b06cae (patch) | |
tree | 62b99e3a3bf4b5a0c5d1c6e16d9ad099a49c2dc5 /rdflib/namespace.py | |
parent | 2e26748374d3b859d4bbe0d914985ab6042c2e04 (diff) | |
download | rdflib-5b142d0d00acdc4cba091ac4422a85f498b06cae.tar.gz |
Docs augmenting
Diffstat (limited to 'rdflib/namespace.py')
-rw-r--r-- | rdflib/namespace.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/rdflib/namespace.py b/rdflib/namespace.py index 0ce4dc1c..60c679fa 100644 --- a/rdflib/namespace.py +++ b/rdflib/namespace.py @@ -1,4 +1,66 @@ from __future__ import generators +from rdflib.py3compat import format_doctest_out + +__doc__ = format_doctest_out(""" +=================== +Namespace Utilities +=================== + +RDFLib provides mechanisms for managing Namespaces. + +In particular, there is a :class:`~rdflib.namespace.Namespace` class that takes as its argument the base URI of the namespace. + +.. code-block:: pycon + + >>> from rdflib.namespace import Namespace + >>> fuxi = Namespace('http://metacognition.info/ontologies/FuXi.n3#') + +Fully qualified URIs in the namespace can be constructed either by attribute or by dictionary access on Namespace instances: + +.. code-block:: pycon + + >>> fuxi.ruleBase + rdflib.term.URIRef('http://metacognition.info/ontologies/FuXi.n3#ruleBase') + >>> fuxi['ruleBase'] + rdflib.term.URIRef('http://metacognition.info/ontologies/FuXi.n3#ruleBase') + +Automatic handling of unknown predicates +----------------------------------------- + +As a programming convenience, a namespace binding is automatically created when :class:`rdflib.term.URIRef` predicates are added to the graph: + +.. code-block:: pycon + + >>> from rdflib import Graph, URIRef + >>> g = Graph() + >>> g.add((URIRef("http://example0.com/foo"), + ... URIRef("http://example1.com/bar"), + ... URIRef("http://example2.com/baz"))) + >>> print(g.serialize(format="n3")) + @prefix ns1: <http://example1.com/> . + <BLANKLINE> + <http://example0.com/foo> ns1:bar <http://example2.com/baz> . + <BLANKLINE> + <BLANKLINE> + >>> + +Importable namespaces +----------------------- + +The following namespaces are available by directly importing from rdflib: + +* RDF +* RDFS +* OWL +* XSD + +.. code-block:: pycon + + >>> from rdflib import OWL + >>> OWL.seeAlso + rdflib.term.URIRef('http://www.w3.org/2002/07/owl#seeAlso') + +""") import logging |