forked from cgutteridge/Graphite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphite-docs.html
401 lines (290 loc) · 25.2 KB
/
graphite-docs.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<h2><a name='documentation'></a>Documentation</h2>
<h3><a name='graphiteclass'></a>Graphite Class</h3>
<div class='class'>
<p>This object represents a set of zero or more bits of RDF data and gives you some functions to start poking them.</p>
<dl class="function_list">
<dt>$graph = new Graphite();</dt>
<dt>$graph = new Graphite( $namespace_map );</dt>
<dd>Create a new instance of Graphite. See the <a href='#namespaces'>Namespaces</a> example above for how to specify a namespace map and a list of pre-declared namespaces. </dd>
<dt>$resource = $graph->resource( $uri );</dt>
<dd>Get the resource with given URI. $uri may be abbreviated to "namespace:value".</dd>
<dt>$graph->ns( $alias, $namespace );</dt>
<dd>Add an additional namespace alias to the Graphite instance.</dd>
<dt>$count = $graph->load( $uri_to_load );</dt>
<dd>Load the RDF from the given URI or URL. Return the number of triples loaded.</dd>
<dt>$count = $graph->addTurtle( $base, $data );</dt>
<dd>Take a base URI and a string of turtle RDF and load the new triples into the graph. Return the number of triples loaded.</dd>
<dt>$count = $graph->addRDFXML( $base, $data );</dt>
<dd>As for addTurtle but load a string of RDF XML.</dd>
<dt>$count = $graph->addTriples( $triples );</dt>
<dd>Add triples to the graph from an ARC2 datastrcture. This is the inverse of toArcTriples.</dd>
<dt>$graph->addTriple( $subject,$predicate,$object, [$datatype], [$language] );</dt>
<dt>$graph->addCompressedTriple( $subject,$predicate,$object, [$datatype], [$language] );</dt>
<dt>$graph->t( $subject,$predicate,$object, [$datatype], [$language] );</dt>
<dd>Add a single triple directly to the graph. Only addCompressedTriple accepts shortended URIs, eg foaf:name. t() is an alias for addCompressedTriple as we've found it more readable in big blocks of code.</dd>
<dt>$count = $graph->loadSPARQL( $endpoint, $query );</dt>
<dd>Calls the SPARQL query on the endpoint and loads the results into the graph. $query should be a SPARQL "CONSTRUCT" query which returns RDF, rather than a table of resutls. The return value is the number of triples added.</dd>
<dt>$graph->cacheDir( $dir, [$age] );</dt>
<dd>$dir should be a directory the webserver has permission to read and write to. Any RDF/XML documents which graphite downloads will be saved here. If a cache exists and is newer than $age seconds then load() will use the document in the cache directory in preference to doing an HTTP request. $age defaults to 24*60*60 - 24 hours. This including this function can seriously improve graphite performance! If you want to always load certain documents, load them before setting the cache.</dd>
<dt>print $graph->dump( [$options] );</dt>
<dt>print $graph->dumpText( [$options] );</dt>
<dd>Returns the entire RDF in memory in nicely formatted HTML so you can see what's going on. Options is an optional array, same parameters as $options on a dump() of an individual resource. dumpText() does the same thing but with ASCII indents rather than HTML markup.</dd>
<dt>print_r( $graph->toArcTriples() );</dt>
<dd>Returns the entire RDF in memory in Arc2's internal triples format.</dd>
<dt>print $graph->serialize( [$serializer="RDFXML"] );</dt>
<dd>Returns the serialization of the entire RDF graph in memory using one of Arc2's serializers. By default the RDF/XML serializer is used, but others (try passing "Turtle" or "NTriples") can be used - see the Arc2 documentation.</dd>
<dt>$resource = $graph->primaryTopic();</dt>
<dd>Utility method (shamelessly ripped off from EasyRDF). Returns the primary topic of the first URL that was loaded. Handy when working with FOAF.</dd>
<dt>$resources = $graph->allOfType( $type_uri );</dt>
<dd>Return a list of all resources loaded, with the rdf:type given. eg. $graph->allOfType( "foaf:Person" )</dd>
<dt>$resources = $graph->allSubjects();</dt>
<dd>Return a list of all resources in the graph which are the subject of at least one triple.</dd>
<dt>$resources = $graph->allObjects();</dt>
<dd>Return a list of all resources in the graph which are the object of at least one triple.</dd>
<dt>$label_relations_list = $graph->labelRelations();</dt>
<dt>$graph->labelRelations( $new_list );</dt>
<dt>$graph->addLabelRelation();</dt>
<dd>Return a list of the relations currently used for $resource->label(), if called with a parameter then this should be an array to <strong>replace</strong> the current list. To just add additonal relation types to use as labels, use addLabelRelation($relation).</dd>
<dt>$icon_url = $graph>mailtoURL();</dt>
<dt>$graph>mailtoURL( $new_icon_url );</dt>
<dt>$icon_url = $graph>telURL();</dt>
<dt>$graph>telURL( $new_icon_url );</dt>
<dd>Get or set the URL of the icon used for mailto: and tel: links in prettyLink(). If set to an empty string then no icon will be shown.</dd>
<dt>$graph->freeze( $filename );</dt>
<dt>$graph = Graphite::thaw( $filename );</dt>
<dd>Graphite uses ARC2 to parse RDF, which isn't as fast as using a compiled library. I may add support for <a href='http://www4.wiwiss.fu-berlin.de/bizer/rdfapi/'>RAP</a> or something similar. When Graphite loads a triple it indexes it by both subject & object, which also takes a little time. To address this issue, freeze and thaw go some way to help speed things up. freeze takes a graph object, including all the namespaces set with ns() and saves it to disk as a serialised PHP object, which is much faster to load then a large RDF file. It's ideal in a situation where you want to build a site from a single RDF document which is updated occasionally. <a href='https://github.com/cgutteridge/Graphite/blob/master/examples/freeze.php'>This example</a> is a command line script you can modify to load and freeze a graph.</dd>
</dl>
</dl>
</div>
<h3><a name='resourceclass'></a>Resource Class</h3>
<div class='class'>
<p>This represents a single RDF thing, with a URI, or a literal value. If you treat it as a string it will return the URI or the literal, but there's some useful functions you can call on it, too.</p>
<dl class="function_list">
<dt>$new_resource = $resource->get( $property );</dt>
<dt>$new_resource = $resource->get( <a href='#resources'>*resource list*</a> );</dt>
<dd>Get a single resource, related to the current resource by the given property. The property may be a URI or "namespace:value". It may be a literal or a normal resource. If there's no value, it returns a null resource object (not a null value), so your code will muddle through. If you specify multiple properties, then this returns the first resource it finds. To get a value from the inverse of a relationship, prefix the property string with "-". For example, to get the mayor of a city you may need to do $city->get( "-somens:isMayorOf" );</dd>
<dt>$string = $resource->toString();</dt>
<dd>Returns the value of a literal, or the URI of a resource as a PHP string.</dd>
<dt>$datatype = $resource->datatype();</dt>
<dd>Returns the datatype of a literal, if it has one, otherwise null.</dd>
<dt>$language = $resource->language();</dt>
<dd>Returns the language of a literal, if it has one, otherwise null.</dd>
<dt>$string = $resource->getString( $property );</dt>
<dt>$string = $resource->getString( <a href='#resources'>*resource list*</a> );</dt>
<dd>As for get() but return the result's string value. Shortened version of $resource->get( $property )->toString();</dd>
<dt>$boolean = $resource->has( $property );</dt>
<dt>$boolean = $resource->has( <a href='#resources'>*resource list*</a> );</dt>
<dd>Returns true if there this resource has at least one relationship with the given properties (or with any of the given properties)</dd>
<dt>$resource_list = $resource->all( $property );</dt>
<dt>$resource_list = $resource->all( <a href='#resources'>*resource list*</a> );</dt>
<dd>As for get(), but returns a resource list of zero or more matching resources. Resource lists may be treated as arrays, but see below for additional properties.</dd>
<dt>$resource_list = $resource->allString( $property );</dt>
<dt>$resource_list = $resource->allString( <a href='#resources'>*resource list*</a> );</dt>
<dd>As for all(), but returns a resource list the string values of each result.</dd>
<dt>$relation_list = $resource->relations();</dt>
<dd>Returns a resource list of the properties relating to this resource, including inverse ones.</dd>
<dt>$count = $resource->load();</dt>
<dd>Try and resolve this resource via the web and load the RDF found there into the current Graphite object. Returns the number of triples loaded (zero probably indicates failure).</dd>
<dt>$count = $resource->loadSameAs( [$prefix] );</dt>
<dd>Iterate over any owl:sameAs properties this resource has and load them from the web. Any loaded triples with the URI of the resource being loaded will be created with both that URI and the URI of the current resource, causing the linked data to be immediately available via the current resource. A single Graphite instance won't load the same URI more than once, so you can call this function twice to follow first, then second generation sameAs relations, if you want. The 2nd call will return the number of triples it loaded the first time, so don't try looping until it returns zero, rather loop until the number of triples returned does not increase. If $prefix is set then only follow sameAs links to URIs with that prefix.</dd>
<dt>$resource = $resource->type()</dt>
<dt>$resources_list = $resource->types()</dt>
<dd>Handy methods for getting the rdf:type or types of the resource. Use for code readability.</dd>
<dt>$boolean = $resource->isType( $type );</dt>
<dt>$boolean = $resource->isType( <a href='#resources'>*resource list*</a> );</dt>
<dd>Return true if the resource is of the given type, or any of the given list of types.</dd>
<dt>$boolean = $resource->isNull();</dt>
<dd>Return true if the resource is a null node, e.g. as the result of $resource->get("something:nonexistent").</dd>
<dt>$resource = $resource->add( $relation,$object, [$datatype], [$language] );</dt>
<dt>$resource = $resource->add( $inverse_relation, $subject );</dt>
<dd>Creates a new triple linked to this resource, and returns a handle on the same resource to allow chaining. This allows for some elegant code to add several triples in very readable way:
<pre>
$graph->resource( "http://example.org/person/23" )
->add( "foaf:name", "Marvin Fenderson", "literal" )
->add( "foaf:phone", "tel:+44123456789" )
->add( "-foaf:member" "http://dbpedia.org/resource/University_of_Southampton" );
</pre>
This syntax aims to keep the cut-and-pasted code to a minimum.
</dd>
<dt>$label = $resource->label()</dt>
<dd>Get a valid label for this resource, tries all of skos:prefLabel, rdfs:label, foaf:name, dct:title, dc:title, sioc:name. Returns "[NULL]" if no label is available. To alter or add to the list of relationships considered to be labels, see $graph->labelRelations($list) and $graph->addLabelRelation($list)</dd>
<dt>$boolean = $resource->hasLabel()</dt>
<dd>Returns true if label() would return a valid lable, use it to avoid ugly [NULL]'s appearing.
<dt>$htmllink = $resource->link()</dt>
<dd>Returns <a href='THIS'>THIS</a> - saves time when wanting to link homepages, etc.</dd>
<dt>$htmllink = $resource->prettyLink()</dt>
<dd>Similar to link() but is a bit more clever. If the resource has a valid label (according to hasLabel(), above) then it uses that as the link text. If it's a tel: or mailto: URI then it shows the phone number or email address without the prefix, and shows a little email/phone icon. You can alter these icons or prevent them appearing using $graph->telIcon($url) and $graph->mailtoIcon($url)</dd>
<dt>$dump = $resource->dump( [$options] );<dt>
<dt>$dump = $resource->dumpText( [$options] );<dt>
<dd>Create a pretty HTML dump of the current resource. Handy for debugging halfway through hacking something. $options is an optional array of flags to modify how dump() renders HTML. dumpText() does the same think with ASCII indention instead of HTML markup, and is intended for debugging command-line scripts.
<div><strong>"label"=>1</strong> - add a label for the URI, and the rdf:type, to the top of each resource box, if the information is in the current graph.</div>
<div><strong>"labeluris"=>1</strong> - when listing the resources to which this URI relates, show them as a label, if possible, rather than a URI. Hovering the mouse will still show the URI.</div>
<div><strong>"internallinks"=>1</strong> - instead of linking directly to the URI, link to that resource's dump on the current page (which may or may not be present). This can, for example, make bnode nests easier to figure out.</div>
</dd>
<dt>print_r( $resource->toArcTriples() );</dt>
<dd>Returns all triples of which this resource is the subject in Arc2's internal triples format.</dd>
<dt>print $graph->serialize( [$serializer="RDFXML"] );</dt>
<dd>Returns the serialization of the resource including any bnodes it points to (and any those point to). See the serialize method of the Graphite class above.</dd>
</dl>
<hr />
<h4>Experimental Resource Class methods</h4>
<p>These do some funky stuff relating to our research at Southampton. They may be modified or removed in later versions of Graphite.</p>
<dl class="function_list">
<dt>$count = $resource->loadSameAsOrg( $prefix );</dt>
<dd>Look up this URI in <a href="http://sameas.org/">http://sameas.org</a> and follow any sameAs URIs from there which match the prefix. $prefix is enforced as sameAs.org may return hundreds of URIs.</dd>
https://github.com/cgutteridge/Graphite/blob/master/examples/freeze.php
<dt>$count = $resource->loadDataGovUKBackLinks()</dt>
<dd>Takes the current resource and attempts to find backlinks via <a href='http://backlinks.psi.enakting.org/'>The EnAKTing project</a>. This works rather nicely with dbpedia URIs of British regions, cities etc.</dd>
</dl>
</div>
<h3><a name='resourcelistclass'></a>ResourceList Class</h3>
<div class='class'>
<p>This represents a list of RDF things, URIs or literal values. You can just treat it like an array, or you can call methods on it.</p>
<dl class="function_list">
<dt>$new_resourcelist = $resourcelist->get( $property );</dt>
<dt>$new_resourcelist = $resourcelist->get( <a href='#resources'>*resource list*</a> );</dt>
<dd>Call $resource->get(...) on every item in this list and return a resourcelist of the results.</dd>
<dt>$string = $resource->getString( $property );</dt>
<dt>$string = $resource->getString( <a href='#resources'>*resource list*</a> );</dt>
<dd>Call $resource->getString(...) on every item in this list and return a resourcelist of the results.</dd>
<dt>$new_resourcelist = $resourcelist->all( $property );</dt>
<dt>$new_resourcelist = $resourcelist->all( <a href='#resources'>*resource list*</a> );</dt>
<dd>Call $resource->all(...) on every item in this list and return a resourcelist of all the results. Duplicate resources are eliminated.</dd>
<dt>$resource_list = $resource->allString( $property );</dt>
<dt>$resource_list = $resource->allString( <a href='#resources'>*resource list*</a> );</dt>
<dd>Call $resource->allString(...) on every item in this list and return a resourcelist of all the results. As with all(), duplicate resources and eliminated.</dd>
<dt>$resource_list = $resource->allOfType( $type_uri );</dt>
<dd>Create a new resource list containing all resources in the current list of the given type.</dd>
<dt>$new_resourcelist = $resourcelist->label();</dt>
<dd>Call $resource->label() on every item in this list and return a resourcelist of the results.</dd>
<dt>$n = $resourcelist->load();</dt>
<dd>Call $resource->load() on every item in this list and return the total triples from these resources. Careful, this could cause a large number of requests at one go!</dd>
<dt>$str = $resourcelist->join( $joinstr );</dt>
<dd>Returns a string of all the items in the resource list, joined with the given string.</dd>
<dt>$new_resourcelist = $resourcelist->sort( $property );</dt>
<dt>$new_resourcelist = $resourcelist->sort( <a href='#resources'>*resource list*</a> );</dt>
<dd>Return a copy of this resource list sorted by the given property or properties. If a resource has multiple values for a property then one will be used, as with $resource->get().</dd>
<dt>$new_resourcelist = $resourcelist->distinct();</dt>
<dd>Return a list with any duplicates removed, otherwise preserving current order.</dd>
<dt>$new_resourcelist = $resourcelist->append( $resource );</dt>
<dt>$new_resourcelist = $resourcelist->append( <a href='#resources'>*resource list*</a> );</dt>
<dd>Create a new resource list with the given resource or list of resources appended on the end of the current resource list.</dd>
<dt>$new_resourcelist = $resourcelist->union( $resource );</dt>
<dt>$new_resourcelist = $resourcelist->union( <a href='#resources'>*resource list*</a> );</dt>
<dd>Create a new resource list with the given resource or list of resources merged with the current list. Functionally the same as calling $resourcelist->append( ... )->distinct()</dd>
<dt>$new_resourcelist = $resourcelist->intersection( $resource );</dt>
<dt>$new_resourcelist = $resourcelist->intersection( <a href='#resources'>*resource list*</a> );</dt>
<dd>Create a new resource list with containing only the resources which are in both lists. Only returns one instance of each resource no matter how many duplicates were in either list.</dd>
<dt>$new_resourcelist = $resourcelist->except( $resource );</dt>
<dt>$new_resourcelist = $resourcelist->except( <a href='#resources'>*resource list*</a> );</dt>
<dd>Create a new resource list with containing only the resources which are in $resourcelist but <i>not</i> in the list being passed in. Only returns one instance of each resource no matter how many duplicates were in either list.</dd>
<dt>$array = $resourcelist->link();</dt>
<dt>$array = $resourcelist->prettyLink();</dt>
<dd>Calls link() or prettyLink() on each item in the resource list and returns it as an array. The array is an object which you can call join() on, so you can use:
<pre>
print $list->sort( "foaf:name" )->prettyLink()->join( ", ").".";
</pre>
To print a nicely formatted list of names, linking to the URIs.</dd>
<dt>$dump = $resourcelist->dump( [$options] );</dt>
<dt>$dump = $resourcelist->dumpText( [$options] );</dt>
<dd>Returns a string containing a dump of all the resources in the list. Options is an optional array, same parameters as $options on a dump() of an individual resource. dumpText() does the same thing but with ASCII indents rather than HTML markup.</dd>
</dl>
</div>
<h3><a name='resources'></a>* Note about Graphite methods which can take a list of resources</h3>
<div class='class'>
<p>These methods work in a pretty cool way. To make life easier for you they can take a list of resources in any of the following ways.</p>
<p>$resource->get() is used as an example, it applies to many other methods.</p>
<dl class="function_list">
<dt>$resource->get( $uri_string )</dt>
<dd>Such as "http://xmlns.com/foaf/0.1/name".</dd>
<dt>$resource->get( $short_uri_string )</dt>
<dd>using any namespace defined with $graph->ns() or just built in. eg. "foaf:name".</dd>
<dt>$resource->get( $resource ) </dt>
<dd>An instance of Graphite_resource.</dd>
<dt>$resource->get( $thing, $thing, $thing, ... )</dt>
<dt>$resource->get( array( $thing, $thing, $thing, ... ) )</dt>
<dd>Where each thing is any of $uri_string, $short_uri_string or $resource.</dd>
<dt>$resource->get( $resourcelist ) </dt>
<dd>An instance of Graphite_resourceList.</dd>
</dl>
<p>This should make it quick and easy to write readable code!</p>
</div>
<h3><a name='resourcedescriptionclass'></a>Resource Description</h3>
<div class='class'>
<p>Resource descriptions are a powerful new feature added in Graphite v1.5. These let you specify what relationships are needed to describe a resource and then create a new graph from an existing graph, or load the required data from a SPARQL endpoint. No knowledge of SPARQL is required.</p>
<p>It also allows you to output the resulting graph in a number of common formats, including JSON. The JSON is treated as a tree, based on the routes you specify from the starting resource. It is absolutely not JSON LD, although I would be happy to add JSON LD support as an additional output format if there's a demand for it.</p>
<p>A Graphite Resource Description is a quick and easy way to make a linked-data website. You just describe the data you need about a resource, eg. a person, and look at the format suffix of the current page. If it's anything other than HTML you let the resource description object handle it for you, if it's HTML you use normal graphite functions to produce a page.</p>
<p>The following example assumes that the PHP script is aliased to /building and everything after that in the path is a parameter to the script, eg. 59.html or 32.json</p>
<pre>
list( $id, $format ) = preg_split( "/\./", substr( $_SERVER["PATH_INFO"], 1 ), 2 );
$uri = 'http://id.southampton.ac.uk/building/'.$id;
$graph = new Graphite();
$graph->ns( "sr", "http://data.ordnancesurvey.co.uk/ontology/spatialrelations/" );
$rd = $graph->resource( "http://id.southampton.ac.uk/building/32" )->prepareDescription();
$rd->addRoute( '*' );
$rd->addRoute( '*/rdfs:label' );
$rd->addRoute( '*/rdf:type' );
$rd->addRoute( '-sr:within/rdf:type' );
$rd->addRoute( '-sr:within/rdfs:label' );
$n = $rd->loadSPARQL( "http://sparql.data.southampton.ac.uk/" );
if( $format != "html" ) {
# Unless this is HTML just let Graphite serve the document.
if( !$rdesc->handleFormat( $format ) ) {
header('HTTP/1.0 404 Not Found');
print "404 Not Found\n";
}
exit;
}
// output normal HTML page base on $graph...
</pre>
<dl class="function_list">
<dt>$rd = $resource->prepareDescription()</dt>
<dd>Create a fresh resource-description object using the given resource as a "root".</dd>
<dt>$rd->addRoute($route)</dt>
<dd>Add a route to the description. The format is a slash-separated list of "hops" from the root resource. Each "hop" is either a short-form predicate, like foaf:name or a "*" indicating all predicates should be followed, prefixing the predicate (or *) with a minus sign "-" indicates that this relation should be followed backwards rather than forward.
<p>So if we wanted all the members of a club:
<pre>
$rd = $graph->resource( "http://id.example.org/club/awesome-soc" )->prepareDescription();
$rd->addRoute( "foaf:member" );
</pre>
but this only gets their URIs so we probably want their names too:
<pre>
$rd->addRoute( "foaf:member/foaf:name" );
</pre>
to add all the people they know (and their names):
<pre>
$rd->addRoute( "foaf:member/foaf:knows/foaf:name" );
</pre>
and to add all the people who know members of this club:
<pre>
$rd->addRoute( "foaf:member/-foaf:knows/foaf:name" );
</pre>
note that "foaf:member/-foaf:knows/foaf:name" will add "foaf:member/-foaf:knows" and "foaf:member/" automatically.
</p>
<p>The most common routes you will want are:
<pre>
$rd->addRoute( "*" );
$rd->addRoute( "*/rdf:type" );
$rd->addRoute( "*/rdfs:label" );
</pre>
</p>
<p>A richer syntax may be added in a future version, ideally I'd like something which allowed "*/(rdf:type|rdfs:label)".</p>
<dt>$formats = $rd->getFormats()</dt>
<dd>Return an array of the formats handleFormat currently supports, with the format code as keys, and the values are a human-readable name.</dd>
<dt>$handled = $rd->handleFormat($format)</dt>
<dd>Send a document based on the resource description, in the format requested. Return true if Graphite understands that format.
<ul>
<li>"json" : JSON structured tree data. Not a formal JSON-LD format as I believe it's too complicated for the requirements of most coders wishing to consume JSON. If ?callback=funcname is specified then the output will be in the form of a JSONP script.</li>
<li>"nt" : N-Triples - a list of uncompressed triples. Verbose but easy to parse.</li>
<li>"rdf" : RDF+XML - the ubiquitous but heinous XML serialisation of RDF.</li>
<li>"ttl" : Turtle - the much nicer Turtle serialisation.</li>
<li>"rdf.html" : An HTML description of the data. The results of running $graph->dump(). Really handy for debugging.</li>
</ul>
<p>I am considering adding some additional formats, including RDFa (as a bunch of <span> elements), KML (find things that have a lat/long etc. basically nicking the code from <a hre='http://graphite.ecs.soton.ac.uk/geo2kml/'>geo2kml</a>), JSON-LD - which is a lossless way to describe RDF in JSON, .dot - a format used to produce images of graphs. Please <a href='mailto:cjg@ecs.soton.ac.uk'>drop me a line</a> if any of these, or others, are useful to you.</p>
</dd>
<dt>$count = $rd->loadSPARQL($endpoint)</dt>
<dd>This uses one or more SPARQL queries to the given endpoint to get all the triples required for the description. The return value is the total number of triples added to the graph.</dd>
<dt>$new_graph = $rd->toGraph()</dt>
<dd>In addition to loadSPARQL you can use $rd->toGraph() which creates a new Graphite graph object from the triples in the current graph, using the resource description as the pattern of what to copy. Preferences such as namespaces are not currently copied to the new graph, but may be in a later version of Graphite.</dd>
</dl>
</div>