forked from linkeddata/swap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdflib2rdf.html
226 lines (181 loc) · 14.5 KB
/
rdflib2rdf.html
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
216
217
218
219
220
221
222
223
224
225
226
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module rdflib2rdf</title>
<style type="text/css"><!--
TT { font-family: lucidatypewriter, lucida console, courier }
--></style></head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>rdflib2rdf</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/devel/WWW/2000/10/swap/rdflib2rdf.py">/devel/WWW/2000/10/swap/rdflib2rdf.py</a></font></td></tr></table>
<p><tt>This rdflib2rdf module provides code for glueing rdflib's rdf/xml<br>
parser to cwm.<br>
<br>
STATUS:<br>
<br>
First pass, partially working, some questions.<br>
<br>
<br>
QUESTIONS:<br>
<br>
Does the context need to change per bag? I have assumed for the moment<br>
not, as it breaks (or complicates) the interface between the parser<br>
and the store.<br>
<br>
Is there already or is there any interest in a <a href="#ContextSink">ContextSink</a> interface<br>
to simplify the interface between the parser and the store? If<br>
desired, I would be happy to help with any refactors that would be<br>
needed. To better describe what I am thinking, I have implemented a<br>
<a href="#ContextSink">ContextSink</a> enough to serve the purpose needed for this module.<br>
<br>
Is urlparse.urljoin from the Python standard library buggy? RDFLib<br>
uses urlparse.urljoin and I noticed that the differences between it<br>
and uriparse.join are causing the test cases to fail (export<br>
PYTHONPATH=..;python2.3 retest.py -n -f regression.n3). For example:<br>
file:/devel/WWW/2000/10/swap/test/animal.rdf#<br>
vs.<br>
file:///devel/WWW/2000/10/swap/test/animal.rdf#<br>
<br>
Not really a question but... RDFLib's RDF/XML parser at the moment<br>
does not make it easy to get to the namespace binding information. And<br>
the way sax2rdf currently calls bind it looks like there will be<br>
issues if a prefix gets redefined. Here is a question re:<br>
this... should passing the namespace information to the store be a<br>
[mandatory] part of the interface? or does it cause to much grief in<br>
practice not too?<br>
<br>
<br>
TO RUN: (cwm with rdflib's rdf/xml parser)<br>
<br>
Double check that you have rdflib-1.2.x installed :)<br>
* Download from <a href="http://rdflib.net/stable/">http://rdflib.net/stable/</a><br>
* extract<br>
* cd root of distribution<br>
* python2.2 setup.py install<br>
<br>
Change the following line in cwm.py from:<br>
return sax2rdf.<a href="#RDFXMLParser">RDFXMLParser</a>(...<br>
to:<br>
return rdflib2rdf.<a href="#RDFXMLParser">RDFXMLParser</a>(...<br>
<br>
--eikeon, <a href="http://eikeon.com/">http://eikeon.com/</a></tt></p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="diag.html">diag</a><br>
</td><td width="25%" valign=top><a href="uripath.html">uripath</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="rdflib.syntax.parser.html#Parser">rdflib.syntax.parser.Parser</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="rdflib2rdf.html#RDFXMLParser">RDFXMLParser</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="rdflib2rdf.html#ContextSink">ContextSink</a>
</font></dt></dl>
</dd>
</dl>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ContextSink">class <strong>ContextSink</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2> </td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="ContextSink-__init__"><strong>__init__</strong></a>(self, sink, thisURI, formulaURI<font color="#909090">=None</font>, flags<font color="#909090">=''</font>, why<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="ContextSink-makeStatement"><strong>makeStatement</strong></a>(self, (predicate, subject, object))</dt></dl>
<dl><dt><a name="ContextSink-newBlankNode"><strong>newBlankNode</strong></a>(self)</dt></dl>
<dl><dt><a name="ContextSink-newLiteral"><strong>newLiteral</strong></a>(self, s)</dt></dl>
<dl><dt><a name="ContextSink-newSymbol"><strong>newSymbol</strong></a>(self, uri)</dt></dl>
<hr>
Data and non-method functions defined here:<br>
<dl><dt><strong>__dict__</strong> = <dict-proxy object></dl>
<dl><dt><strong>__doc__</strong> = None</dl>
<dl><dt><strong>__module__</strong> = 'rdflib2rdf'<dd><tt>str(<a href="__builtin__.html#object">object</a>) -> string<br>
<br>
Return a nice string representation of the <a href="__builtin__.html#object">object</a>.<br>
If the argument is a string, the return value is the same <a href="__builtin__.html#object">object</a>.</tt></dl>
<dl><dt><strong>__weakref__</strong> = <member '__weakref__' of 'ContextSink' objects></dl>
<hr>
Methods inherited from <a href="__builtin__.html#object">__builtin__.object</a>:<br>
<dl><dt><a name="ContextSink-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#ContextSink-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl>
<dl><dt><a name="ContextSink-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#ContextSink-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
<dl><dt><a name="ContextSink-__hash__"><strong>__hash__</strong></a>(...)</dt><dd><tt>x.<a href="#ContextSink-__hash__">__hash__</a>() <==> hash(x)</tt></dd></dl>
<dl><dt><a name="ContextSink-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
<dl><dt><a name="ContextSink-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#ContextSink-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
<dl><dt><a name="ContextSink-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#ContextSink-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl>
<dl><dt><a name="ContextSink-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#ContextSink-__str__">__str__</a>() <==> str(x)</tt></dd></dl>
<hr>
Data and non-method functions inherited from <a href="__builtin__.html#object">__builtin__.object</a>:<br>
<dl><dt><strong>__class__</strong> = <type 'type'><dd><tt>the <a href="__builtin__.html#object">object</a>'s class</tt></dl>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object at 0xbf74c><dd><tt>T.<a href="#ContextSink-__new__">__new__</a>(S, ...) -> a new <a href="__builtin__.html#object">object</a> with type S, a subtype of T</tt></dl>
</td></tr></table>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="RDFXMLParser">class <strong>RDFXMLParser</strong></a>(<a href="rdflib.syntax.parser.html#Parser">rdflib.syntax.parser.Parser</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2> </td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="rdflib2rdf.html#RDFXMLParser">RDFXMLParser</a></dd>
<dd><a href="rdflib.syntax.parser.html#Parser">rdflib.syntax.parser.Parser</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="RDFXMLParser-_RDFXMLParser__convert"><strong>_RDFXMLParser__convert</strong></a> = __convert(self, t)</dt><dd><tt>Convert from rdflib to cwm style term.</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__init__"><strong>__init__</strong></a>(self, sink, thisURI, formulaURI<font color="#909090">=None</font>, flags<font color="#909090">=''</font>, why<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="RDFXMLParser-add"><strong>add</strong></a>(self, (s, p, o))</dt><dd><tt>Add triple to the sink (rdflib.syntax.parser.<a href="rdflib.syntax.parser.html#Parser">Parser</a> calls<br>
this method).</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-load"><strong>load</strong></a>(self, uri, baseURI<font color="#909090">=''</font>)</dt></dl>
<hr>
Data and non-method functions defined here:<br>
<dl><dt><strong>__doc__</strong> = None</dl>
<dl><dt><strong>__module__</strong> = 'rdflib2rdf'<dd><tt>str(<a href="__builtin__.html#object">object</a>) -> string<br>
<br>
Return a nice string representation of the <a href="__builtin__.html#object">object</a>.<br>
If the argument is a string, the return value is the same <a href="__builtin__.html#object">object</a>.</tt></dl>
<hr>
Methods inherited from <a href="rdflib.syntax.parser.html#Parser">rdflib.syntax.parser.Parser</a>:<br>
<dl><dt><a name="RDFXMLParser-parse"><strong>parse</strong></a>(self, source)</dt></dl>
<hr>
Data and non-method functions inherited from <a href="rdflib.syntax.parser.html#Parser">rdflib.syntax.parser.Parser</a>:<br>
<dl><dt><strong>__dict__</strong> = <dict-proxy object></dl>
<dl><dt><strong>__weakref__</strong> = <member '__weakref__' of 'Parser' objects></dl>
<hr>
Methods inherited from <a href="__builtin__.html#object">__builtin__.object</a>:<br>
<dl><dt><a name="RDFXMLParser-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#RDFXMLParser-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#RDFXMLParser-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__hash__"><strong>__hash__</strong></a>(...)</dt><dd><tt>x.<a href="#RDFXMLParser-__hash__">__hash__</a>() <==> hash(x)</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#RDFXMLParser-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#RDFXMLParser-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl>
<dl><dt><a name="RDFXMLParser-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#RDFXMLParser-__str__">__str__</a>() <==> str(x)</tt></dd></dl>
<hr>
Data and non-method functions inherited from <a href="__builtin__.html#object">__builtin__.object</a>:<br>
<dl><dt><strong>__class__</strong> = <type 'type'><dd><tt>the <a href="__builtin__.html#object">object</a>'s class</tt></dl>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object at 0xbf74c><dd><tt>T.<a href="#RDFXMLParser-__new__">__new__</a>(S, ...) -> a new <a href="__builtin__.html#object">object</a> with type S, a subtype of T</tt></dl>
</td></tr></table></td></tr></table>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>FORMULA</strong> = 1<br>
<strong>__file__</strong> = './rdflib2rdf.pyc'<br>
<strong>__name__</strong> = 'rdflib2rdf'</td></tr></table>
</body></html>