In RDF graph model, a node is represented by either resource nodes or literals. A resource node is either a named node, which has a globally unique URI, or a blank node, which has no URI. A literal is a kind of string or number, or an instance of XMLLiteral. Figure 4.1, which is taken from RDF/XML Syntax Specification, shows an example of RDF graph. In the figure, a rectangle represents a literal and an ellipse represents an anonymous blank node or a resource node that contains a URI inside. In SWCLOS, Figure 4.1 is expressed as follows in S-expression.
Figure 4.1 RDF Graph Example (from RDF/XML Syntax Specification)
(rdf:Description
(rdf:about "http://www.w3.org/TR/rdf-syntax-grammar")
(ex:editor
(rdf:Description
(ex:homePage
(rdf:Description (rdf:about "http://purl.org/net/dajobe/")))
(ex:fullName "Dave
Beckett")))
(dc:title "RDF/XML Syntax Specification (Revised)"))
Whereas rdf:about in SWCLOS looks like a property in RDF, it is not a property in RDF but an XML attribute that takes a place in RDF/XML format resource definition. The ex:editor, ex:homePage, ex:fullName, and dc:title are RDF properties in QName representation for the corresponding URIs on the edges in the figure. The terminology ‘rdf:Description’ that appears in S-expression for RDF graph representation just denotes a sequence for RDF description. With addForm function, this statement turns out a resource object. See the syntax in BNF described below. Precisely, the assertion above produces three CLOS objects, that is, two named resource objects and one anonymous resource object, in addition to two lisp strings.
SWCLOS allows users to add such a form as mentioned in the previous section, that is, nested object-centered representation of RDF graph into the lisp environment. However, if a resource name is not supplied, the created object is anonymous. See the following example. If you type the lines as the demonstration, a dialogue window will pop up twice at the line 5 for package name of uri “http://purl.org/net/” and “http://www.w3.org/TR/”. Please note to push ‘cancel’ button in this case. If you gave some package name for the query, SWCLOS would create the package and make a symbol, e.g., package-name-you-input:dajobe. Then, you would obtain a different look at line 6, where the symbol name package-name-you-input:dajobe would appear instead of ‘(rdf:Description (rdf:about "http://purl.org/net/dajobe/"))’ for the anonymous object.
gx-user(3): (defpackage
ex)
#<The ex package>
gx-user(4): (defpackage dc)
#<The dc
package>
gx-user(5): (addForm '(rdf:Description
(rdf:about
"http://www.w3.org/TR/rdf-syntax-grammar")
(ex::editor
(rdf:Description
(ex::homePage
(rdf:Description
(rdf:about
"http://purl.org/net/dajobe/")))
(ex::fullName
"Dave Beckett")))
(dc::title "RDF/XML Syntax Specification
(Revised)")))
Warning: Entail by rdf1: ex::editor rdf:type
rdf:Property.
Warning: Entail by rdf1: dc::title rdf:type
rdf:Property.
Warning: Entail by rdf1: ex::homePage rdf:type
rdf:Property.
Warning: Entail by rdf1: ex::fullName rdf:type
rdf:Property.
#<|rdfs:Resource| common-lisp:nil>
gx-user(6): (pprint
(get-form
<<http://www.w3.org/TR/rdf-syntax-grammar>>))
(rdf:Description
(rdf:about
"http://www.w3.org/TR/rdf-syntax-grammar")
(ex:editor
(rdf:Description
(ex:homePage
(rdf:Description (rdf:about
"http://purl.org/net/dajobe/")))
(ex:fullName
"Dave Beckett")))
(dc:title "RDF/XML Syntax Specification
(Revised)"))
Do not care about those warnings at line 5 at this time. It will be explained at Section 5.5. In this example, an RDF graph shown in Figure 4.1 is inputted through a form in S-expression in SWCLOS, and three objects are created in the environment. You can backwardly generate the form in RDF graph from the subjective resource object using get-form in the lisp top level.
The value of property ‘ex:editor’ is anonymous. The value of ‘ex:homePage’ is also anonymous, because SWCLOS did not obtain the name by your cancellation for its package name. Note that SWCLOS cannot identify anonymous objects by name, even if they have the URI in rdf:about attribute. (However, you can get anonymous objects through corresponding URIs with function iri-value.)
Function addForm interprets a form according to the following BNF syntax, where {A--Z} means any character from A to Z, and {SomeNode - element} means the possibility of SomeNode minus element. Also note ‘xyz’ means a sequence of character x, y, and z. #\x means a character x.
form ::= number | string | uri | qname | langedString | datatypeString |