d6a06fe092
as possible.
178 lines
5.8 KiB
HTML
178 lines
5.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Online SWI-Prolog RDF parser demo</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h1 align=center>Online SWI-Prolog RDF parser demo</h1>
|
|
|
|
<p>
|
|
This page provides an online demonstration of an RDF parser written in <a
|
|
href="http://www.swi-prolog.org">SWI-Prolog</a> and distributed as part of the
|
|
normal SWI-Prolog distribution. This RDF parser has a couple of attractive
|
|
properties:
|
|
|
|
<dl>
|
|
<dt><b>Small</b><dd>
|
|
Both in terms of source-code (< 1200 lines) and executable.
|
|
|
|
<dt><b>Fast</b><dd>
|
|
Parses about 1.2 Mbytes/sec on an AMD 1600+ running SWI-Prolog 5.1.6 and
|
|
SuSE Linux 8.1 (tested on a 9MB RDFS file containing 179403 triples).
|
|
|
|
<dt><b>Conforming</b><dd>
|
|
This parser conforms to http://www.w3.org/TR/rdf-syntax-grammar/,
|
|
W3C Working Draft 8 November 2002. It includes the revised bag
|
|
syntax, <code>xml:base</code>, <code>parseType="Collection"</code>
|
|
and <code>nodeID</code> features.
|
|
|
|
<dt><b>Prolog based</b><dd>
|
|
Many people regard the Prolog programming language a good vehicle to
|
|
reason about RDF statements. Having a simple and fast Prolog-based RDF
|
|
parser makes life easier.
|
|
|
|
<dt><b>Portability</b><dd>
|
|
The RDF parser itself is written in ISO Prolog. The XML parser is
|
|
written in ANSI-C. There is no standard for interfacing Prolog and C,
|
|
but the interface is relatively small.
|
|
|
|
<dt><b>Discussion Page</b><dd>
|
|
There is a
|
|
<a href="http://gollem.science.uva.nl/twiki/pl/bin/view/Library/RdfParse">
|
|
discussion page</a> on this parser on the SWI-Prolog collaborative
|
|
(<em>twiki</em> web) </dl>
|
|
|
|
A more detailed description of this packages is available in <a
|
|
href="http://www.swi-prolog.org/packages/rdf2pl.html">in this
|
|
document</a>. The sources of the parser are included in the full
|
|
source for SWI-Prolog. The individual source files can also be
|
|
examined through the <a
|
|
href="http://gollem.science.uva.nl/cgi-bin/pl-cvsweb/pl/packages/sgml/RDF">
|
|
cvsweb service</a>.
|
|
|
|
<p>
|
|
<hr>
|
|
Please write your RDF description into the text-area below or select a
|
|
local file using the <b>File:</b> item and submit it. If anything goes
|
|
wrong, please mail <a href="mailto:wielemak@science.uva.nl">Jan
|
|
Wielemaker</a>.
|
|
|
|
<p>
|
|
<em>The RDF-data submitted is kept <b>anonymously</b> on our server and
|
|
might be used by us to examine problems with our RDF parser. We do not
|
|
publish this material.</em> The result-page provides a form for
|
|
attaching a comment to the stored RDF statement.
|
|
|
|
<p>
|
|
<form
|
|
name=rdf
|
|
method=post
|
|
enctype="multipart/form-data"
|
|
action="@ACTION@">
|
|
<table align=center>
|
|
<tr><td colspan=2>
|
|
<textarea name=rdf rows=15 cols=72 wrap=off></textarea>
|
|
<tr><td>File: <input name=attachment type=file>
|
|
<td align=right>
|
|
<input type=button value='Example 1' onClick="ex1()">
|
|
<input type=button value='Example 2' onClick="ex2()">
|
|
<input type=button value='Example 3' onClick="ex3()">
|
|
<input type=button value='Example 19' onClick="ex19()">
|
|
<tr><td align=left><input type=reset value="Clear Text">
|
|
<td align=right><input type=submit value="Parse RDF">
|
|
</table>
|
|
</form>
|
|
|
|
<h4><hr>Notes<hr></h4
|
|
|
|
<dl>
|
|
<dt><b><em>rdf:</em>resource, etc.</b><dd>
|
|
The specification and discussion on the rdf interest group yielded no
|
|
satisfactory solution how to deal with RDF attributes that are not in
|
|
the RDF namespace such as <b>ID</b>, <b>resource</b>, etc. This parser
|
|
interprets such attributes in the namespace of the element, so the
|
|
statement below is not interpreted as a <b>propertyElt</b> with value
|
|
<code>me</code> but as a <b>typedNode</b> with predicate
|
|
<code>resource</code> and value <b>literal(</b>me<b>)</b>.
|
|
|
|
<pre>
|
|
<s:Creator resource="#me">
|
|
</pre>
|
|
</dl>
|
|
|
|
<!---------------------------------------------------------------->
|
|
<!-- EXAMPLES -->
|
|
<!---------------------------------------------------------------->
|
|
|
|
<script language="JavaScript">
|
|
|
|
function ex1()
|
|
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
|
\n\
|
|
<!-- Example from REC-rdf-syntax -->\n\
|
|
\n\
|
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
|
xmlns:s="http://description.org/schema/">\n\
|
|
<rdf:Description about="http://www.w3.org/Home/Lassila">\n\
|
|
<s:Creator>Ora Lassila</s:Creator>\n\
|
|
</rdf:Description>\n\
|
|
</rdf:RDF>';
|
|
}
|
|
|
|
function ex2()
|
|
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
|
\n\
|
|
<!-- Example from REC-rdf-syntax, demonstrating reification -->\n\
|
|
\n\
|
|
<rdf:RDF\n\
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
|
xmlns:s="http://description.org/schema/">\n\
|
|
<rdf:Description about="http://www.w3.org/Home/Lassila" bagID="D_001">\n\
|
|
<s:Creator>Ora Lassila</s:Creator>\n\
|
|
<s:Title>Ora\'s Home Page</s:Title>\n\
|
|
</rdf:Description>\n\
|
|
</rdf:RDF>';
|
|
}
|
|
|
|
function ex3()
|
|
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
|
\n\
|
|
<!-- Example from REC-rdf-syntax, non-binary relations -->\n\
|
|
\n\
|
|
<rdf:RDF\n\
|
|
xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
|
xmlns:n="http://www.nist.gov/units/">\n\
|
|
<Description about="John_Smith">\n\
|
|
<n:weight rdf:parseType="Resource">\n\
|
|
<rdf:value>200</rdf:value>\n\
|
|
<n:units rdf:resource="http://www.nist.gov/units/Pounds"/>\n\
|
|
</n:weight>\n\
|
|
</Description>\n\
|
|
</rdf:RDF>';
|
|
}
|
|
|
|
function ex19()
|
|
{ document.rdf.rdf.value='<?xml version="1.0"?>\n\
|
|
\n\
|
|
<!-- Example 19: Complete example of a RDF collection of nodes\n\
|
|
using rdf:parseType="Collection" -->\n\
|
|
\n\
|
|
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n\
|
|
xmlns:ex="http://example.org/stuff/1.0/">\n\
|
|
<rdf:Description rdf:about="http://example.org/basket">\n\
|
|
<ex:hasFruit rdf:parseType="Collection">\n\
|
|
<rdf:Description rdf:about="http://example.org/banana"/>\n\
|
|
<rdf:Description rdf:about="http://example.org/apple"/>\n\
|
|
<rdf:Description rdf:about="http://example.org/pear"/>\n\
|
|
</ex:hasFruit>\n\
|
|
</rdf:Description>\n\
|
|
</rdf:RDF>';
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|