[redland-dev] Parsing collections in OWL file

Dave Beckett dave.beckett at bristol.ac.uk
Fri May 28 17:14:33 BST 2004


On Wed, 26 May 2004 16:11:51 +0100, Adam Witney <awitney at sghms.ac.uk> wrote:

> 
> Hi, I am fairly new to Redland. I have a perl script which will parse a DAML
> file and generate triples ok. I am trying to convert it to parse the
> equivalent file in OWL format, however I am having a little trouble with the
> collections.


Have you tried the utility program that comes with the Redland RDF
parser, Raptor?  It is built as raptor/rapper and installed into
your usual bin directory if you do a 'make install'.


> This piece of RDF

<snip/>

That was a fragment and not legal XML.  So I added some start and end
tags to try to get it to parse.  The attached file is adam.rdf

(I happen to be using emacs with the nxml mode from James Clark and
it immediately showed me syntax errors - it's great, if you use it)

The error line is:
                        <owl:oneOf parseType="owl:collection">

This is wrong twice.
Firstly, the attribute value should just be 'collection'
Secondly, the attribute name should be 'rdf:parseType' (although most
parsers will accept this).

Correct value:
                        <owl:oneOf rdf:parseType="Collection">

I assume you just did a global replace for 'daml' to 'owl'.  This is
one place where that'll bite you :)


> However I can't seem to get access to the nodes in the collection, all I can
> get is the XML string as above.
> 
> Any pointers how to handle this would be greatly appreciated


With that fix, I get triples:

$ rapper -q -o ntriples adam2.rdf
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:genid1 <http://www.w3.org/2002/07/owl#onProperty> <http://mged.sourceforge.net/ontologies/MGEDOntology.daml#has_measurement_type> .
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://mged.sourceforge.net/ontologies/MGEDOntology.daml#absolute> .
<http://mged.sourceforge.net/ontologies/MGEDOntology.daml#absolute> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://mged.sourceforge.net/ontologies/MGEDOntology.daml#change_biomaterial_characteristics> .
_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:genid4 .
<http://mged.sourceforge.net/ontologies/MGEDOntology.daml#change_biomaterial_characteristics> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://mged.sourceforge.net/ontologies/MGEDOntology.daml#relative> .
_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:genid5 .
<http://mged.sourceforge.net/ontologies/MGEDOntology.daml#relative> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> .
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:genid2 <http://www.w3.org/2002/07/owl#oneOf> _:genid3 .
_:genid1 <http://www.w3.org/2002/07/owl#someValuesFrom> _:genid2 .
<http://example.org//> <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:genid1 .


Which, gives you the nodes you want.

Looks like I should try to validate the values of rdf:parseType when
the parser is in lax mode.  Normally (in strict compliance), any
unknown value is taken to mean the content is an XML Literal such as
a lump of HTML.

Dave



More information about the redland-dev mailing list