blob: 2c37a530bf70a3838628aaa3fb01e48b87050162 (
plain)
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
|
(define-module (ldp resource load)
#:use-module (ldp resource)
#:use-module (ldp path)
#:use-module (ldp resource xml)
#:use-module (rnrs bytevectors)
#:use-module (web uri))
(define-public (load uri)
(cond
((string? uri)
(load (string->path uri)))
((uri? uri)
(load (uri->path uri)))
((or (resource? uri) (container? uri))
(load (resource-path uri)))
(else
(let* ((dirname (path->filename uri))
(filename (string-append dirname
"/representation/manifest.xml"))
(port
(catch #t
(lambda ()
(open-input-file filename))
(lambda error
(throw 'not-found))))
(resource (xml->resource port))
(container-def
(if (container? resource)
(format #f "
<~a> a <http://www.w3.org/ns/ldp#Container>,
<http://www.w3.org/ns/ldp#BasicContainer> .
"
(path->string (resource-path resource)))
""))
(containment-triples
(if (and (container? resource)
(not (null? (resource-contained resource))))
(format #f "
<~a> a <http://www.w3.org/ns/ldp#contains> ~a .
"
(path->string (resource-path resource))
(string-join
(map (lambda (p)
(format #f "<~a>"
(path->string p)))
(resource-contained resource))
", "))
""))
(content-filename
(string-append dirname
"/representation/content")))
(values
resource
(open-input-file content-filename #:binary #t)
(and (container? resource)
(string->utf8
(string-append container-def containment-triples))))))))
|