-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdf
183 lines (153 loc) · 5.98 KB
/
rdf
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
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdfe="http://redfoot.net/3.0/rdf#"
xmlns:server="http://redfoot.net/3.0/server#"
xmlns:code="http://redfoot.net/3.0/code#"
xmlns:template="http://redfoot.net/3.0/template#"
xmlns:kid="http://redfoot.net/3.0/kid#"
>
<rdfe:Namespace rdf:about="#">
<rdfs:label>RDF (extension)</rdfs:label>
<rdfs:comment>The RDF extension namespace.</rdfs:comment>
</rdfe:Namespace>
<rdfs:Class rdf:ID="Namespace">
<rdfs:label>Namespace</rdfs:label>
</rdfs:Class>
<rdfs:Class rdf:ID="Context">
<rdfs:label>Context</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:subClassOf rdf:resource="http://redfoot.net/3.0/redfoot#Resource"/>
</rdfs:Class>
<rdf:Property rdf:ID="context">
<rdfs:label>context</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:domain rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
<rdfs:range rdf:resource="#Context"/>
</rdf:Property>
<rdf:Property rdf:ID="source">
<rdfs:label>source</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:domain rdf:resource="#Context"/>
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
</rdf:Property>
<rdf:Property rdf:ID="publicID">
<rdfs:label>publicID</rdfs:label>
<rdfs:comment>used by load; see load method on kernel for more info</rdfs:comment>
<rdfs:domain rdf:resource="#Context"/>
</rdf:Property>
<rdfs:Class rdf:ID="RDFXMLDocument">
<rdfs:label>RDFXMLDocument</rdfs:label>
<server:page_handler>
<server:PageHandler rdf:ID="RDFXMLDocumentPageHandler">
<rdfs:label>RDFXMLDocument PageHandler</rdfs:label>
<server:content_type>application/rdf+xml</server:content_type>
<code:python rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
<![CDATA[
document = request.uri
from rdflib.Graph import Graph
g = Graph(namespace_manager=redfoot.namespace_manager)
prefix = "%s#" % document
for s, p, o in redfoot:
if s==document or (isinstance(s, unicode) and s.startswith(prefix)):
g.add((s, p, o))
##
# This was nice for somethings, but in the case of trying to round
# trip an Ontology via HTTP PUT / GET from an editor... we end up
# with instances from other contexts. Trying without for now.
#if o==document or (isinstance(o, unicode) and o.startswith(prefix)):
# g.add((s, p, o))
response.setHeader('Content-Type', 'application/rdf+xml')
g.serialize(destination=response)#, base=document)
]]>
</code:python>
</server:PageHandler>
</server:page_handler>
</rdfs:Class>
<rdfs:Class rdf:about="http://www.w3.org/2000/01/rdf-schema#Class">
<template:content>
<kid:PagePartHandler rdf:ID="class_content">
<rdfs:label>Display of Class</rdfs:label>
<kid:template rdf:datatype="http://redfoot.net/3.0/server#Kid">
<![CDATA[
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:kid="http://purl.org/kid/ns#"
kid:strip=""
>
<?python
if (request.uri.abstract(), None, None) in redfoot:
uri = request.uri.abstract()
elif (request.uri, None, None) in redfoot:
uri = request.uri
else:
uri = request.uri.abstract()
format = redfoot.module(URIRef("simple_format#module", base=redfoot.uri)).format
format_uri = redfoot.module(URIRef("simple_format#module", base=redfoot.uri)).format_uri
seeAlsoList = list(redfoot.objects(uri, RDFS.seeAlso))
miscList = [t for t in redfoot.predicate_objects(uri) if t[0] not in [RDFS.label, RDFS.comment, RDF.type, RDFS.subClassOf, RDFS.seeAlso]]
instances = []
seen = set()
for instance in redfoot.instances(uri):
if instance not in seen and isinstance(instance, URIRef):
seen.add(instance)
label = redfoot.value(instance, RDFS.label, any=True)
label = label or instance
instances.append((label, instance))
instances.sort()
subclasses = list(redfoot.subclasses(uri))
superclasses = list(redfoot.objects(uri, RDFS.subClassOf)) # TODO:
?>
<h2 kid:if="(uri, None, None) not in redfoot">Not Found</h2>
<p>${XML(format_uri(redfoot.comment(uri)))}</p>
<div kid:if="superclasses">superclasses: <span kid:strip="" kid:for="superclass in superclasses"><a href="${request.relative(superclass.concrete())}">${redfoot.label(superclass, superclass)}</a> </span></div>
<div kid:if="subclasses">subclasses: <span kid:strip="" kid:for="subclass in subclasses"><a href="${request.relative(subclass.concrete())}">${redfoot.label(subclass, subclass)}</a> </span></div>
<ul kid:if="miscList">
<li kid:for="p, o in miscList">${redfoot.label(p) or p},
<span kid:strip="" kid:if="isinstance(o, Literal)">
<pre>${o}</pre>
</span>
<span kid:strip="" kid:if="isinstance(o, URIRef)">
<a href="${request.relative(o.concrete())}">
${", ".join(redfoot.objects(o, RDFS.label)) or o}
</a>
</span>
<span kid:strip="" kid:if="isinstance(o, BNode)">
${", ".join(redfoot.objects(o, RDFS.label))}
</span>
</li>
</ul>
<div kid:if="seeAlsoList">
<h2>See Also</h2>
<ul>
<li kid:for="seeAlso in seeAlsoList">${XML(format_uri(seeAlso))}</li>
</ul>
</div>
<div kid:if="instances">
<ul>
<span kid:strip=""
kid:for="label, instance in instances">
<li kid:if="isinstance(instance, URIRef)">
<a href="${request.relative(instance.concrete())}">
${label}
</a>
</li>
<li kid:if="isinstance(instance, BNode)">
${label}
</li>
</span>
</ul>
</div>
<p kid:if="allow(URIRef('%s/create/' % request.host))">
<form name="create_form" action="/create/" method="POST">
<input name="type" type="hidden" value="${request.uri.abstract()}"/>
<input type="submit" value="Create Instance"/>
</form>
</p>
</div>
]]>
</kid:template>
</kid:PagePartHandler>
</template:content>
</rdfs:Class>
</rdf:RDF>