How to create a rule set from an owl schema stored in RDF XML?


I am attempting to enable queries containing rdfs:subClassOf with respect to the following prefix:

PREFIX bp: <>

Note that the above namespace <> is a schema written in RDF XML with terms like:

    <owl:Class rdf:ID="ComplexAssembly">
        <rdfs:subClassOf rdf:resource="#Conversion"/>

Attempted Solution:

Following the documentation on Enabling Inferencing, I created a rule set as follows:

rdfs_rule_set ('bp3','') ;

Sanity check:

SQL> select * from DB.DBA.SYS_RDF_SCHEMA;
RS_NAME                                                                           RS_URI                                                                            RS_G
VARCHAR NOT NULL                                                                  VARCHAR NOT NULL                                                                  VARCHAR

asEquivalent                                                                      urn:activitystreams-owl:map                                                       NULL
bp3                                                                                                       NULL                                                                                              NULL
ldp                                                                                                                              NULL

4 Rows. -- 0 msec.

However, SPARQL queries with the following rule context still fail to perform expected traversals:

DEFINE input:inference "bp3"

PREFIX wp:    <>
PREFIX dcterms: <>
PREFIX xsd: <>
PREFIX rdfs: <>
PREFIX bp: <>

My concern is that the Examples in the Enabling Inference documentation usually specified inference graphs directly like:

ttlp ('
   <>                                 <>  <>.
   <>  <>  <> .
   <> <>  <>.
   <>                            <>                     <> .
   <>  <>                     <>.
   <> <>                     <> .
   ', '', '');

Conversely, my inference rules are buried in a huge schema ( which resolves to an XML that begins like:

<?xml version="1.0" encoding="UTF-8"?>

    <!ENTITY owl "" >
    <!ENTITY swrl "" >
    <!ENTITY swrlb "" >
    <!ENTITY xsd "" >
    <!ENTITY rdfs "" >
    <!ENTITY rdf "" >
    <!ENTITY protege "" >
    <!ENTITY xsp "" >

<rdf:RDF xmlns=""
    <owl:Ontology rdf:about="">
        <rdfs:comment rdf:datatype="&xsd;string"
            >This is version 1.0  of the BioPAX Level 3 ontology.  The goal of the BioPAX group is to develop a common exchange format for biological pathway data.  More information is available at  This ontology is freely available under the LGPL (</rdfs:comment>

Do I need to somehow extract all rdfs:subPropertyOf and rdfs:subClassOf from this in order to create a rule set? If so, how can I do this automatically?

Yes, the inference graph data/rules do need to be loaded into Virtuoso before the inference rule is created. And if you inference graph containing the rules is a HTTP accessible URI in RDF/XML form it can be loaded as per this
Inference Rule example using transitive properties from SKOS vocabulary example, using the call DB.DBA.RDF_LOAD_RDFXML (http_get (''), 'no', ''); function.

1 Like

Thanks @hwilliams

In case I want to load a compressed HTTP accessible RDF/XML file, is there a way to do that using gz_uncompress?

I’m thinking something like the following but I’m not sure how to deal with the output file parameter:

    http_get (
    ), '', '');

Uncompressing via HTTP on the fly would not work, the compressed file would have to be downloaded on the file system and then it can be uncompressed with the gz_file_open function.

1 Like