The fact that one can use Jena's command line tool 'riot' to convert formats is 
perfectly true. A separate question was asked.

---
A. Soroka
The University of Virginia Library

> On Aug 23, 2016, at 3:34 AM, Lorenz Buehmann 
> <[email protected]> wrote:
> 
> That does not solve the issue, the values are still string, not URIs resp. 
> RDF resources. The whole XSLT transformation has to be done again.
> 
> 
> On 22.08.2016 13:36, A. Soroka wrote:
>> You can use Jena's command line tool 'riot' to convert:
>> 
>> https://jena.apache.org/documentation/io/#command-line-tools
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Aug 22, 2016, at 4:54 AM, lookman sanni <[email protected]> wrote:
>>> 
>>> Awesome !
>>> 
>>> The reason why I am using XML/RDF is that I have an input of
>>> thousands/millions of lines in either CSV or XML. I chose XML, and
>>> converted the XML to RDF/XML through XSLT. I can after that read the
>>> RDF/XML either in memory or via TDB. Any chance I could be using TTL ? If
>>> yes, I would be interested in learning how.
>>> 
>>> Thank you.
>>> 
>>> 
>>> 
>>> On Mon, Aug 22, 2016 at 10:20 AM, Dave Reynolds <[email protected]>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> The problem is with your RDF file. You have given the values of the
>>>> aa:processedIn properties as strings instead of resources. To see this
>>>> serialize as ttl. Better still, only use ttl and ignore rdf/xml!
>>>> 
>>>> Using a corrected RDF file:
>>>> 
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
>>>> xmlns:aa="http://www.abcd.org/ofdf#"; xmlns:owl="http://www.w3.org/2
>>>> 002/07/owl#" xmlns:html="http://www.w3.org/1999/xhtml"; xmlns:rdfs="
>>>> http://www.w3.org/2000/01/rdf-schema#";>
>>>>  <owl:Class rdf:about="http://www.abcd.org/ofdf#folder";>
>>>>  </owl:Class>
>>>>  <owl:Class rdf:about="http://www.abcd.org/ofdf#file";>
>>>>  </owl:Class>
>>>>  <rdf:Description rdf:about="http://www.abcd.org/ofdf#folder/001";>
>>>>    <aa:createdBy>MisterX</aa:createdBy>
>>>>    <rdf:type rdf:resource="http://www.abcd.org/ofdf#folder"/>
>>>>   </rdf:Description>
>>>>  <rdf:Description rdf:about="http://www.abcd.org/ofdf#file/AAA";>
>>>>    <aa:processedIn rdf:resource="http://www.abcd.org/ofdf#folder/001"; />
>>>>    <rdf:type rdf:resource="http://www.abcd.org/ofdf#file"/>
>>>>  </rdf:Description>
>>>>  <rdf:Description rdf:about="http://www.abcd.org/ofdf#folder/002";>
>>>>    <aa:createdBy>MisterY</aa:createdBy>
>>>>    <rdf:type rdf:resource="http://www.abcd.org/ofdf#folder"/>
>>>>  </rdf:Description>
>>>>  <rdf:Description rdf:about="http://www.abcd.org/ofdf#file/AAA";>
>>>>    <aa:processedIn rdf:resource="http://www.abcd.org/ofdf#folder/002"; />
>>>>    <rdf:type rdf:resource="http://www.abcd.org/ofdf#file"/>
>>>>  </rdf:Description>
>>>>  <rdf:Description rdf:about="http://www.abcd.org/ofdf#file/BBB";>
>>>>    <aa:processedIn>http://www.abcd.org/ofdf#folder/002</aa:processedIn>
>>>>    <rdf:type rdf:resource="http://www.abcd.org/ofdf#file"/>
>>>>  </rdf:Description>
>>>> </rdf:RDF>
>>>> 
>>>> and using your rule definitions then the ruleX fires fine and the
>>>> resulting InfModel is:
>>>> 
>>>> @prefix aa:    <http://www.abcd.org/ofdf#> .
>>>> @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>>>> @prefix owl:   <http://www.w3.org/2002/07/owl#> .
>>>> @prefix html:  <http://www.w3.org/1999/xhtml> .
>>>> @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
>>>> 
>>>> <http://www.abcd.org/ofdf#file/AAA>
>>>>        a               aa:fileRequiringConflictCheck ,
>>>> aa:fileInManyFolders , aa:file ;
>>>>        aa:processedIn  <http://www.abcd.org/ofdf#folder/002> , <
>>>> http://www.abcd.org/ofdf#folder/001> .
>>>> 
>>>> aa:file  a      owl:Class .
>>>> 
>>>> <http://www.abcd.org/ofdf#file/BBB>
>>>>        a               aa:file ;
>>>>        aa:processedIn  "http://www.abcd.org/ofdf#folder/002"; .
>>>> 
>>>> <http://www.abcd.org/ofdf#folder/002>
>>>>        a             aa:folder ;
>>>>        aa:createdBy  "MisterY" .
>>>> 
>>>> aa:folder  a    owl:Class .
>>>> 
>>>> <http://www.abcd.org/ofdf#folder/001>
>>>>        a             aa:folder ;
>>>>        aa:createdBy  "MisterX" .
>>>> 
>>>> 
>>>> Dave
>>>> 
>>>> 
>>>> On 21/08/16 19:34, lookman sanni wrote:
>>>> 
>>>>> Ok Dave. Here is a minimal example:
>>>>> 
>>>>> 
>>>>> *Java Code*
>>>>>                       String rdfPath = "dataset/rdf/sample.rdf";
>>>>>                 String inRuleBase = "rules/sampleRule.txt";
>>>>>                 Model model = ModelFactory.createDefaultModel();
>>>>> FileInputStream fis = new FileInputStream(rdfPath);
>>>>> model.read(fis,"ticket");
>>>>> Reasoner reasoner = new GenericRuleReasoner(
>>>>> Rule.rulesFromURL(inRuleBase));
>>>>> InfModel infModel = ModelFactory.createInfModel( reasoner, model );
>>>>> StmtIterator si = infModel.listStatements();
>>>>> while ( si.hasNext() )
>>>>> {
>>>>> Statement stmt = si.nextStatement();
>>>>> Resource subject = stmt.getSubject();
>>>>> Property predicate = stmt.getPredicate();
>>>>> RDFNode object = stmt.getObject();
>>>>> System.out.println(subject.toString() + " " + predicate.toString() + " "
>>>>> +
>>>>> object.toString());
>>>>> }
>>>>> 
>>>>> *RDF File** (sample.rdf)*
>>>>> 
>>>>> 
>>>>>         <?xml version="1.0" encoding="UTF-8"?>
>>>>> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
>>>>> xmlns:aa="
>>>>> http://www.abcd.org/ofdf#"; xmlns:owl="http://www.w3.org/2002/07/owl#";
>>>>> xmlns:html="http://www.w3.org/1999/xhtml"; xmlns:rdfs="
>>>>> http://www.w3.org/2000/01/rdf-schema#";>
>>>>> <owl:Class rdf:about="http://www.abcd.org/ofdf#folder";>
>>>>> </owl:Class>
>>>>> <owl:Class rdf:about="http://www.abcd.org/ofdf#file";>
>>>>> </owl:Class>
>>>>> <rdf:Description rdf:about="http://www.abcd.org/ofdf#folder/001";>
>>>>> <aa:createdBy>MisterX</aa:createdBy>
>>>>> <rdf:type rdf:resource="http://www.abcd.org/ofdf#folder"/>
>>>>> </rdf:Description>
>>>>> <rdf:Description rdf:about="http://www.abcd.org/ofdf#file/AAA";>
>>>>> <aa:processedIn>http://www.abcd.org/ofdf#folder/001</aa:processedIn>
>>>>> <rdf:type rdf:resource="http://www.abcd.org/ofdf#file"/>
>>>>> </rdf:Description>
>>>>> <rdf:Description rdf:about="http://www.abcd.org/ofdf#folder/002";>
>>>>> <aa:createdBy>MisterY</aa:createdBy>
>>>>> <rdf:type rdf:resource="http://www.abcd.org/ofdf#folder"/>
>>>>> </rdf:Description>
>>>>> <rdf:Description rdf:about="http://www.abcd.org/ofdf#file/AAA";>
>>>>> <aa:processedIn>http://www.abcd.org/ofdf#folder/002</aa:processedIn>
>>>>> <rdf:type rdf:resource="http://www.abcd.org/ofdf#file"/>
>>>>> </rdf:Description>
>>>>> <rdf:Description rdf:about="http://www.abcd.org/ofdf#file/BBB";>
>>>>> <aa:processedIn>http://www.abcd.org/ofdf#folder/002</aa:processedIn>
>>>>> <rdf:type rdf:resource="http://www.abcd.org/ofdf#file"/>
>>>>> </rdf:Description>
>>>>> </rdf:RDF>
>>>>> 
>>>>> 
>>>>> *Rule** (**sampleRule.txt)*
>>>>> 
>>>>> @prefix aa: <http://www.abcd.org/ofdf#>.
>>>>> 
>>>>> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
>>>>> 
>>>>> @prefix owl: <http://www.w3.org/2002/07/owl#>.
>>>>> 
>>>>> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
>>>>> 
>>>>> @prefix owl: <http://www.w3.org/2002/07/owl#>.
>>>>> 
>>>>> 
>>>>> [ruleX:
>>>>> 
>>>>> (?file1 aa:processedIn ?fld1)
>>>>> 
>>>>> (?file1 aa:processedIn ?fld2)
>>>>> 
>>>>> notEqual(?fld1, ?fld2)
>>>>> 
>>>>> (?fld1 aa:createdBy ?auth1)
>>>>> 
>>>>> (?fld2 aa:createdBy ?auth2)
>>>>> 
>>>>> notEqual(?auth1, ?auth2)
>>>>> 
>>>>> ->
>>>>> 
>>>>> (?file1 rdf:type aa:fileRequiringConflictCheck)
>>>>> 
>>>>> ]
>>>>> 
>>>>> [ruleY:
>>>>> (?file1 aa:processedIn ?fld1)
>>>>> (?file1 aa:processedIn ?fld2)
>>>>> notEqual(?fld1, ?fld2)
>>>>> ->
>>>>> (?file1 rdf:type aa:fileInManyFolders)
>>>>> ]
>>>>> 
>>>>> 
>>>>> RuleY is properly recognized and I can see the following statement added
>>>>> to
>>>>> the Inference model:
>>>>> *http://www.abcd.org/ofdf#file/AAA <http://www.abcd.org/ofdf#file/AAA>
>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type
>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
>>>>> http://www.abcd.org/ofdf#fileInManyFolders
>>>>> <http://www.abcd.org/ofdf#fileInManyFolders>*
>>>>> 
>>>>> 
>>>>> Nothing however for ruleX and this is what I struggle with. Thanks in
>>>>> advance for the help.
>>>>> 
>>>>> On Sun, Aug 21, 2016 at 3:44 PM, Dave Reynolds <[email protected]
>>>>> wrote:
>>>>> 
>>>>> On 21/08/16 12:37, lookman sanni wrote:
>>>>>> Hi all,
>>>>>>> I am struggling with the definition of jena rules. I have an RDF file
>>>>>>> where
>>>>>>> I am defining:
>>>>>>> 
>>>>>>>    - a "folder" class with a property "createdBy"
>>>>>>>    - a "file" class with a property "processedIn" of type "folder"
>>>>>>> 
>>>>>>> My RDF file contains resources from the two classes. I am trying to
>>>>>>> define
>>>>>>> a Jena rule for querying files appearing in more than a folder, having
>>>>>>> different authors.
>>>>>>> 
>>>>>>> To that end, I added to my RDF the specification of a class
>>>>>>> "fileRequiringConflictCheck" a subclass of the class "file" and then
>>>>>>> specified the following jena rule:
>>>>>>> 
>>>>>>> [ruleX:
>>>>>>> (?file1 aa:processedIn ?fld2)
>>>>>>> (?file1 aa:processedIn ?fld1)
>>>>>>> notEqual(?fld1, ?fld2)
>>>>>>> (?fld1 aa:createdBy ?auth1)
>>>>>>> (?fld2 aa:createdBy ?auth2)
>>>>>>> notEqual(?auth1, ?auth2)
>>>>>>> ->
>>>>>>> (?file1 rdf:type aa:fileRequiringConflictCheck)
>>>>>>> ]
>>>>>>> 
>>>>>>> Outcome is that the rule is likely never met whenever expected as per my
>>>>>>> sample dataset. Any idea what I might be missing ?
>>>>>>> 
>>>>>>> 
>>>>>> Looks reasonable, check your namespaces are correct. If you can't get it
>>>>>> working then post a minimal example of the data and someone might be able
>>>>>> to spot the problem.
>>>>>> 
>>>>>> Dave
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>> 
>>> -- 
>>> Best Regards
>>> 
>>> Lookman SANNI
>> 
> 

Reply via email to