-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.docbook
executable file
·64 lines (47 loc) · 4.67 KB
/
index.docbook
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
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0"><title>Hello World App</title>
<section><title>Introduction</title>
<para>This is a simple introductory application demonstrating how view templates are associated with RDF resources.</para>
<orderedlist>
<listitem><simpara>Access the Home Folder my clicking the main menu in the upper right and selecting "Home folder"</simpara></listitem>
<listitem><simpara>From there, select the red "Create" dropdown and choose "Folder".</simpara></listitem>
<listitem><simpara>Name your folder and click "Create".</simpara></listitem>
<listitem><simpara>Click the main menu and select "Import folder contents"</simpara></listitem>
<listitem><simpara>Click "Choose files" and select the Hello World Callimachus ARchive (CAR) - <link xl:href="http://callimachus.googlecode.com/files/helloworld.car">helloworld.car</link>.</simpara></listitem>
</orderedlist>
</section><section><title>Details</title>
<para><emphasis>helloworld.html</emphasis> is a simple HTML file. HTML files are served with no pre-processing on the part of Callimachus. This means that no additional HTML, CSS, or JavaScript is added. One can see the contents of <link xl:href="helloworld.html"><emphasis>helloworld.html</emphasis></link> immediately by clicking on it from the folder view. An HTTP request for <emphasis>helloworld.html</emphasis> (to the full URL, e.g. http://localhost:8080/helloworld/helloworld.html) will result in Callimachus serving the file verbatim. <emphasis>helloworld.html</emphasis> contains:</para>
<programlisting>
<html>
<body>
<p>Hello, World from HTML!</p>
</body>
</html></programlisting>
<para>That's useful, but not so interesting. Now let's see how Callimachus processes requests for other resources. The <link xl:href="HelloClass">HelloClass</link> is a Callimachus Class with an associated view template of <link xl:href="helloworld.xhtml"><emphasis>helloworld.xhtml</emphasis></link>. Note the extension here is Xhtml, not plain html.</para>
<para><link xl:href="helloworld.ttl"><emphasis>helloworld.ttl</emphasis></link> is an RDF file in Turtle syntax. See the following URL for information about the Turtle format:</para>
<para><link xl:href="http://www.w3.org/TeamSubmission/turtle/">http://www.w3.org/TeamSubmission/turtle/</link></para>
<para><emphasis>helloworld.ttl</emphasis> tells Callimachus that the resource <emphasis role="strong">hello+resource</emphasis> is an instance of HelloClass. The <emphasis>helloworld.ttl</emphasis> file contains the following statements.</para>
<programlisting>
@prefix calli:<http://callimachusproject.org/rdf/2009/framework#>.
@prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>.
# Create a resource with a label
<hello+resource> a <HelloClass>
; rdfs:label "hello, resource"
.</programlisting>
<para><emphasis>helloworld.xhtml</emphasis> is nearly identical in content to <emphasis>helloworld.html</emphasis>. The difference is that <emphasis>helloworld.xhtml</emphasis> is serialized as XHTML, associated with a class and passes through the Callimachus evaluation process prior to being served - because it is being used as a view template to another resource (in this case, the HelloWorld class). helloworld.xhtml contains:</para>
<programlisting>
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello, World!</title>
</head>
<body resource="?this">
<div class="container">
<p>{rdfs:label} from XHTML Template!</p>
</div>
</body>
</html>
</programlisting>
<para>An HTTP request for <link xl:href="hello+resource">hello+resource</link> (to the full URL, e.g. http://localhost:8080/helloworld/hello+resource) will result in Callimachus looking at its RDF to determine if that resource is associated with a class that uses a view template. Seeing that it is, Callimachus will serve the file using the template <emphasis>helloworld.xhtml</emphasis> and you should see "Hello, resource from XHTML Template!" in your Web client.</para>
<para>Notice here how by viewing this data via the HelloClass view template (<emphasis>helloworld.xhtml</emphasis>), Callimachus replaced the string "{rdfs:label}" with the actual value of the {rdfs:label} property from the data! In this way we can use one template to display information about many diferent resources. </para>
<para>Try creating own class and view template and associate your own resources to your class. Remember that you can make your HTML look pretty simply by adding a CSS stylesheet reference to it.</para>
</section></article>