filename as namespace?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

filename as namespace?

mskx4
Hello, I'm using the tool as a component of a web app, where the user has to upload an ontology file. Classes and properties are extracted with owlready and mapped to Java classes and attributes using an annotation tool.

1) I would like to place in my java source code also the pairs "xlmns:prefix = uri" that occur at the beginning of the ontology file. Is there a way to extract them in some sort of way? onto._namespaces containes only the base URI

2) Most importantly, I noticed that owlready2 stores some properties lying on the base namespace with a qualified name like this : "filename.propertyName" but I don't want to deal with filenames. An example:

FILENAME: it.owl

ORIGINAL ONTOLOGY FILE:

<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.it2rail.eu/ontology/"
     xml:base="http://www.it2rail.eu/ontology/"
     xmlns:TT="http://www.it2rail.eu/ontology/TT#"
     xmlns:mob="http://www.it2rail.eu/ontology/mobility#"
     xmlns:booking="http://www.it2rail.eu/ontology/booking#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:interop="http://www.it2rail.eu/ontology/InteroperabilityFramework#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:swrlb="http://www.w3.org/2003/11/swrlb#"
     xmlns:skos="http://www.w3.org/2004/02/skos/core#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:topo="http://www.it2rail.eu/ontology/topology#"
     xmlns:BADataPKG="http://www.it2rail.eu/ontology/BADataPKG#"
     xmlns:unknown="http://www.it2rail.eu/ontology/unknown#"
     xmlns:swrla="http://swrl.stanford.edu/ontologies/3.3/swrla.owl#"
     xmlns:ticketing="http://www.it2rail.eu/ontology/ticketing#"
     xmlns:common="http://www.it2rail.eu/ontology/common#"
     xmlns:terms="http://purl.org/dc/terms/"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:id="http://www.it2rail.eu/ontology/identifiers#"
     </>xmlns:ontology="http://www.it2rail.eu/ontology/"
     xmlns:shopping="http://www.it2rail.eu/ontology/shopping#"
     xmlns:product="http://www.it2rail.eu/ontology/product#"
     xmlns:swrl="http://www.w3.org/2003/11/swrl#"
     xmlns:pay="http://www.it2rail.eu/ontology/payment#"
     xmlns:transport="http://www.it2rail.eu/ontology/transport#"
     xmlns:an="http://www.it2rail.eu/ontology/annotation#"
     xmlns:TCDataPKG="http://www.it2rail.eu/ontology/TCDataPKG#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:travel="http://www.it2rail.eu/ontology/travel#"
     xmlns:customer="http://www.it2rail.eu/ontology/customer#"
     xmlns:dc="http://purl.org/dc/elements/1.1/">
    <owl:Ontology rdf:about="http://www.it2rail.eu/ontology/">
        <dc:language rdf:datatype="http://www.w3.org/2001/XMLSchema#string">english</dc:language>

    ... blablabla...

   

    <owl:ObjectProperty rdf:about="http://www.it2rail.eu/ontology/hasID">
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/>
    </owl:ObjectProperty>

ONTO.PROPERTIES() OUTPUT:


   
Is there a way to sistematically get rid of filenames used as prefix by substituting them with a "dummy" prefix that points to the base URI? Thank you


Reply | Threaded
Open this post in threaded view
|

Re: filename as namespace?

mskx4
To clarify:
What I'm trying to obtain is something like this:


The matching of the ontology term against the Java element is something I already take care of, now I have to annotate the Java elements in a consistent fashion...without "surprises" let's say
Reply | Threaded
Open this post in threaded view
|

Re: filename as namespace?

Jiba
Administrator
In reply to this post by mskx4
Hello,

1) XML prefixes are used when parsing the OWL files, but they are not stored in the quadstore since they are not RDF triples. Thus, it is currently not possible to obtain them.

2) By default, Owlready display entity as "filename_without_extension.name". You can change this default behaviour with set_render_func(). See doc here:

https://owlready2.readthedocs.io/en/latest/annotations.html?highlight=set_render_func#custom-rendering-of-entities

Jiba