I need to convert my RDF graph document into OWL (1 or 2) recognized by Protege 3.x. There is a W3C Recommendation for mapping OWL 2 Web Ontology Language Mapping to RDF Graphs which says that to declare Object Properties from RDF graphs one should add the rdf:type owl:ObjectProperty element. I have found problems for expressing OWL object properties with RDF graph formalisms in the following code:
<rdf:Property rdf:about="&uni;isTaughtBy">
<rdf:type rdf:resource="&owl;ObjectProperty"/>
<rdfs:domain rdf:resource="&uni;Course"/>
<rdfs:range rdf:resource="&uni;Proffessor"/>
</rdf:Property>
With the following specified namespaces:
xmlns:uni="http://www.mydomain.org/uni-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
Unfortunately, the upper mentioned code is not recognized and thus shown in the Protege 3.x IDE.
The following code is readable by Protege 4 (recommended version). Copy paste the block and save it in a new file, you should then be able to read it with Protege:
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY uni-ns "http://www.mydomain.org/uni-ns#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.mydomain.org/uni-ns#"
xml:base="http://www.mydomain.org/uni-ns"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:uni-ns="http://www.mydomain.org/uni-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.mydomain.org/uni-ns#"/>
<owl:ObjectProperty rdf:about="&uni-ns;isTaughtBy">
<rdfs:domain rdf:resource="&uni-ns;Course"/>
<rdfs:range rdf:resource="&uni-ns;Professor"/>
</owl:ObjectProperty>
<owl:Class rdf:about="&uni-ns;Course"/>
<owl:Class rdf:about="&uni-ns;Professor">
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
</owl:Class>
</rdf:RDF>
Related
My goal is to add #Entity annotations to the classes that are generated from a wsdl. I'm using cxf-codegen-plugin's wsdl2java goal, and pointing at a local wsdl file. I can generate all the sources without any problem, but when I try to add a binding file, I'm running into problems.
Here's a segment of the wsdl (the file is CAAudit.wsdl and is in my resources directory):
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audw="http://www.ocse.gov/quick/wsdl/CAAudit.wsdl"
xmlns:audx="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:qikrsp="urn:us:gov:hhs:acf:qikrsp"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
name="CAAudit"
>
<wsdl:types>
<xsd:schema targetNamespace="http://www.ocse.gov/quick/wsdl/CAAudit.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xsd:import namespace="urn:us:gov:hhs:acf:qikrsp"
schemaLocation="QuickResponse.xsd" />
<xsd:complexType name="NotifyCAAuditRequest" >
<xsd:sequence>
<xsd:element ref="qikrsp:QuickResponse" />
</xsd:sequence>
</xsd:complexType>
....
My first question is I'm really not certain what should go in the binding file. First, I'm pretty sure that I need jaxws bindings to work with the wsdl (the jaxb binding only has the schemaLocation attribute), although I don't need to generate web service classes.
Next, I'm not sure I'm not sure if the introduction of a new xmlns in the schema element will cause problems for an xpath search. I did have problems running it with notepad++'s xpath evaluation.
Also, I'm not sure if the fact that the QuickResponse element (which is the class I want to annotate) is defined by a reference is hindering my efforts. I'm not sure if or how (or where) I would include the referenced xsd file.
Here is one possible binding file (I was just trying to get an #Generated on the class to start with):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionBindingPrefixes="annox"
jaxb:version="2.1"
>
<jaxws:bindings wsdlLocation="CAAudit.wsdl"
node="/wsdl:definitions/wsdl:types">
<jaxb:bindings node=".//xsd:schema">
<annox:annotate>#javax.annotation.Generated({"JAXWS"})</annox:annotate>
</jaxb:bindings>
</jaxws:bindings>
</jaxb:bindings>
I did not manage to customize schema embedded in WSDL. This are my latest efforts:
https://github.com/highsource/jaxb2-annotate-plugin/blob/master/tests/jaxws/src/main/resources/wsdl-bindings.xjb
What works with WSDLs is attaching customizations via SCD. But SCD does not allow proprietary customization elements (like annotate:*). So that won't help with jaxb2-annotate-plugin.
So the only thing which would probably work is to extract schema from the WSDL into an own file.
This is my first post to stack overflow so I request for an encouraging reply :) (bonus reputations)
I am trying to use SWRL to do some calculations for me. To imitate the problem, I have created a small ontology using protege 4.3. It has only two classes Parent and Son. Instances include 1 parent (John) and three sons (son1, son2, son3). John is linked with 3 sons using "hasSon" object property. Age of each son is mentioned using "hasAge" data-type property (integers).
Question-1: I need to first check that how many instances are linked with a given Parent(John) using hasSon property. How this can be achieved in SWRL?
Question-2: After knowing the number of Sons then I have to add their ages to get the total age of all the Sons again using SWRL?
For me, this require a loop like addition (a=a+b) but I dont know how this will work in SWRL. I have attached the OWL code for you.
(Please note that in actual ontology the linked instances are not 3 but are varying and counting them is part of the problem)
Thanks in advance
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY parenttrial "http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#"
xml:base="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:parenttrial="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#hasSon -->
<owl:ObjectProperty rdf:about="&parenttrial;hasSon">
<rdfs:domain rdf:resource="&parenttrial;Parent"/>
<rdfs:range rdf:resource="&parenttrial;Son"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#hasAge -->
<owl:DatatypeProperty rdf:about="&parenttrial;hasAge"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Parent -->
<owl:Class rdf:about="&parenttrial;Parent"/>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son -->
<owl:Class rdf:about="&parenttrial;Son"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#JohnF -->
<owl:NamedIndividual rdf:about="&parenttrial;JohnF">
<rdf:type rdf:resource="&parenttrial;Parent"/>
<hasSon rdf:resource="&parenttrial;Son1"/>
<hasSon rdf:resource="&parenttrial;Son2"/>
<hasSon rdf:resource="&parenttrial;Son3"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son1 -->
<owl:NamedIndividual rdf:about="&parenttrial;Son1">
<rdf:type rdf:resource="&parenttrial;Son"/>
<hasAge rdf:datatype="&xsd;integer">3</hasAge>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son2 -->
<owl:NamedIndividual rdf:about="&parenttrial;Son2">
<rdf:type rdf:resource="&parenttrial;Son"/>
<hasAge rdf:datatype="&xsd;integer">4</hasAge>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/admin/ontologies/2015/7/parenttrial#Son3 -->
<owl:NamedIndividual rdf:about="&parenttrial;Son3">
<rdf:type rdf:resource="&parenttrial;Son"/>
<hasAge rdf:datatype="&xsd;integer">5</hasAge>
</owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net -->
Answer 1: There is no way through SWRL to check how many instances are connected to a certain property through SWRL. You are better off writing a sparql query with COUNT for this. Alternatively you can use an ontology framework and use an Iteratorto figure out the counts.
Answer 2: There is no way to loop a SWRL rule, perform an operation and return a value. SWRL rules are meant to add extra information about relations and not act as a programming language.
Solution: You are far better off using a ontology framework like Apache Jena or Owl api and writing a program to handle this instead of relying on SWRL. SWRL supports monotonic inferences only and thus cannot be used to loop over data in an ontology. Trying to do so will cause the rule to get executed infinitely.
Instead write a bit of code to do this. Refer to owl api or Jena ontology api and sparql in order to learn more on how to use these technologies.
I have an owl file that import some other ontologies from other owl files. I tried to follow JENA API Documentation to deal with it, but could not succeed. What am I missing?
The codes I used are above:
e-GovSecAOnto.owl imports:
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://www.ida.liu.se/~iislab/projects/secont/Security.owl"/>
<owl:imports rdf:resource="http://www.unifiedcloud.org/2009/2/26/uci.owl"/>
<owl:imports rdf:resource="http://wwwsemanticweb.org/ontologies/Portaria141.owl"/>
</owl:Ontology>
ont-policy.rdf:
<?xml version='1.0'?>
<!DOCTYPE rdf:RDF [
<!ENTITY jena 'http://jena.hpl.hp.com/schemas/'>
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
<!ENTITY base '&jena;2003/03/ont-manager'>
<!ENTITY ont '&base;#'>
]>
<rdf:RDF
xmlns:rdf ="&rdf;"
xmlns:rdfs="&rdfs;"
xmlns ="&ont;"
xml:base ="&base;"
>
<DocumentManagerPolicy>
<processImports rdf:datatype="&xsd;boolean">true</processImports>
<cacheModels rdf:datatype="&xsd;boolean">true</cacheModels>
</DocumentManagerPolicy>
<OntologySpec>
<altURL rdf:resource="file:///C:/Users/usuario/Documents/Visual Studio 2013/WebSites/FrameworkBeta/Repository/Ontologies/Portaria141/Portaria141_V1.owl"/>
<language rdf:resource="http://www.w3.org/2002/07/owl"/>
<publicURI rdf:resource="http://wwwsemanticweb.org/ontologies/Portaria141.owl"/>
</OntologySpec>
<OntologySpec>
<altURL rdf:resource="file:///C:/Users/usuario/Documents/Visual Studio 2013/WebSites/FrameworkBeta/Repository/Ontologies/CloudComputing/uci.owl"/>
<language rdf:resource="http://www.w3.org/2002/07/owl"/>
<publicURI rdf:resource="http://www.unifiedcloud.org/2009/2/26/uci.owl"/>
</OntologySpec>
</rdf:RDF>
ReadOntology():
OntDocumentManager dm = new OntDocumentManager(dmFileName);
OntModelSpec modelSpec = new OntModelSpec( OntModelSpec.RDFS_MEM );
modelSpec.setDocumentManager(dm);
OntModel m = ModelFactory.createOntologyModel(modelSpec);
m.read(FileManager.get().open(#"C:\Users\usuario\Documents\Visual Studio 2013\WebSites\FrameworkBeta\Repository\Ontologies\e-GovSecAOnto\e-GovSecAOnto.owl"), NS);
Using OmniXML and Delphi, I would like to locate an element and change another element in the node. For example, in the xml listing below, I would like to locate /first-name = 'Joe1' and then locate and change the /price from 1200 to 10.
I've tried using XPathSelect but I can not seem to specify the /first-name.
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myfile.xsl" ?>
<bookstore specialty="novel">
<book style="autobiography">
<author>
<first-name>Joe1</first-name>
<last-name>Bob</last-name>
<award>Trenton Literary Review Honorable Mention</award>
</author>
<price>1200</price>
</book>
<book style="textbook">
<author>
<first-name>Mary</first-name>
<last-name>Bob</last-name>
<publication>Selected Short Stories of
<first-name>Mary</first-name>
<last-name>Bob</last-name>
</publication>
</author>
<editor>
<first-name>Britney</first-name>
<last-name>Bob</last-name>
</editor>
<price>55</price>
</book>
</bookstore>
Use //book[author/first-name = "Joe1" ] as your XPathSelect query to get the node, and then access the subnode Price from that node to change it.
I have a Java web service to which I've linked from a Delphi 2007 app using the WSDL Importer. Setting it up has been a rocky road but I'm almost there!
I now have the situation where my arrays aren't being serialized in a way that my Java web service can consume. I've written the same app in .Net to test it out (it works fine) and the XML I'm looking to generate looks like this: -
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS2="http://path.to.service">
<NS1:addActivities xmlns:NS1="http://path.to.service/">
<login href="#1"/>
<project xsi:type="xsd:string">PROJ001</project>
<activities>
<id xsi:type="xsd:string">DELPHITEST</id>
<name xsi:type="xsd:string">This is a test</name>
</activities>
<activities>
<id xsi:type="xsd:string">DELPHITEST2</id>
<name xsi:type="xsd:string">This is another test</name>
</activities>
</NS1:addActivities>
<NS2:login id="1" xsi:type="NS2:login">
<database xsi:type="xsd:string">My_database</database>
<password xsi:type="xsd:string">neverUmind</password>
<username xsi:type="xsd:string">bob</username>
</NS2:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
However, the XML that Delphi generates is as follows: -
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns:NS2="http://path.to.service/">
<NS1:addActivities xmlns:NS1="http://path.to.service/">
<login href="#1"/>
<project xsi:type="xsd:string">PROJ001</project>
<activities xsi:type="SOAP-ENC:Array"
SOAP-ENC:arrayType="NS2:activity[2]">
<item href="#2"/>
<item href="#3"/>
</activities>
</NS1:addActivities>
<NS2:login id="1" xsi:type="NS2:login">
<database xsi:type="xsd:string">My_database</database>
<password xsi:type="xsd:string">neverUmind</password>
<username xsi:type="xsd:string">bob</username>
</NS2:login>
<NS2:activity id="2" xsi:type="NS2:activity">
<id xsi:type="xsd:string">DELPHITEST</id>
<name xsi:type="xsd:string">This is a test</name>
</NS2:activity>
<NS2:activity id="3" xsi:type="NS2:activity">
<id xsi:type="xsd:string">DELPHITEST2</id>
<name xsi:type="xsd:string">This is another test</name>
</NS2:activity>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Basically, I need Delphi to stop creating activity elements within the activities element and instead just put each ID and Name inside the an activities element (as .Net does and Java seems to expect).
I've buggered about with the InvRegistry.RegisterInvokeOptions and the RemClassRegistry.RegisterSerializeOptions but none of the combinations seem to work. To be honest I'm on the verge of writting my own XML parser for this as it's taking way to long to figure out. However, if anyone has any suggestions on how this should work I'd be very grateful.
Surely somebody out there must have consumed a Java-WS web service via Delphi 2007 before :)
TIA
It seems the XMLDocument component in Delphi 2007 is broken. I've installed the Alcinoe component instead and that works a charm. That was only a week wasted ... grrrr