You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by aar thi <rt...@gmail.com> on 2013/04/19 20:21:55 UTC

retrieve property names

hi i'm doing a small project in ontology,  i  need to retrieve all the
property names present in a particular class in the ontology. some one help
me to do that in jena

Re: problem in rewriting query by AlgebraGenerator

Posted by John Liu <jo...@yahoo.com>.
Ok, I file a bug, https://issues.apache.org/jira/browse/JENA-445

 

________________________________
 From: Rob Vesse <rv...@yarcdata.com>
To: "users@jena.apache.org" <us...@jena.apache.org>; John Liu <jo...@yahoo.com> 
Sent: Tuesday, April 23, 2013 5:28:56 PM
Subject: Re: problem in rewriting query by AlgebraGenerator
  

No I did not file a specific defect yet, please feel free to log a JIRA
bug if you wish

Rob



On 4/23/13 1:37 PM, "John Liu" <jo...@yahoo.com> wrote:

>Thanks, Rob for your quick reponse.
> 
>Is there a defect number that I can track this bug?
> 
>Thanks, John
> 
>
>________________________________
> From: Rob Vesse <rv...@yarcdata.com>
>To: "users@jena.apache.org" <us...@jena.apache.org>; John Liu
><jo...@yahoo.com>
>Sent: Tuesday, April 23, 2013 4:13:51 PM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>It's a bug in how OpAsQuery converts sub-queries, watch this space for a
>fix
>
>Rob
>
>
>On 4/23/13 12:35 PM, "John Liu" <jo...@yahoo.com> wrote:
>
>>oh I see, thanks Rob.
>> 
>>I paste the class here, you will see the exception error when you run the
>>code.
>> import
>>com.hp.hpl.jena.query.Query;import
>>com.hp.hpl.jena.query.QueryFactory;import
>>com.hp.hpl.jena.sparql.algebra.AlgebraGenerator;import
>>com.hp.hpl.jena.sparql.algebra.Op;import
>>com.hp.hpl.jena.sparql.algebra.OpAsQuery;public
>>classTestJena {
>>/*** 
>>@paramargs*/
>>publicstaticvoidmain(String[] args) {String queryString =
>>"PREFIX dcterms: <http://purl.org/dc/terms/> \n"+
>>"PREFIX dbpedia: <http://dbpedia.org/resource/> \n"+
>>"SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { \n"+
>>"{"+
>>"SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) \n"+
>>"WHERE {"+
>>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>>"?holiday dcterms:subject ?country_cat \n"+
>>"}GROUP by ?country_cat \n"+
>>"} \n"+
>>"{ \n"+
>>"SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>\n"+
>>"WHERE { \n"+
>>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>>"?holiday dcterms:subject ?country_cat \n"+
>>"FILTER(?holiday=\"http://dbpedia.org/resource/Lunar_New_Year/'s_Day/")
>>\n"+
>>"}GROUP by ?country_cat \n"+
>>"} \n"+ 
>>"}\n";System.
>>out.println("Original query: \n"+ queryString);Query query =
>>QueryFactory.create(queryString);
>>AlgebraGenerator ag =
>>newAlgebraGenerator();Op op = ag.compile(query);
>>Query query2 = OpAsQuery.asQuery(op);
>>String queryString2 = query2.toString();
>>System.
>>out.println("Update query: \n"+ queryString2);Query newQuery2 =
>>QueryFactory.create(queryString2);
>>}
>>}
>> 
>>
>>________________________________
>> From: Rob Vesse <rv...@yarcdata.com>
>>To: "users@jena.apache.org" <us...@jena.apache.org>
>>Sent: Tuesday, April 23, 2013 2:06:34 PM
>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>  
>>
>>John
>>
>>Apache list strips attachments, if you have a code sample please just
>>paste it into the email or provide a link to a pastebin/similar site with
>>your code sample
>>
>>Rob
>>
>>
>>On 4/23/13 11:02 AM, "John Liu" <jo...@yahoo.com> wrote:
>>
>>>Thanks Andy for your quick reply.
>>> 
>>>I tested Jena 2.10.1 and the problem still exists. Could you please run
>>>the attached java code to see if it is a defect?
>>> 
>>>Thanks, John
>>> 
>>>
>>>________________________________
>>> From: Andy Seaborne <an...@apache.org>
>>>To: users@jena.apache.org
>>>Sent: Tuesday, April 23, 2013 10:46:25 AM
>>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>>  
>>>
>>>On 23/04/13 03:10, John Liu wrote:
>>>> Hello,
>>>> I found a problem when rewriting a query by AlgebraGenerator, the
>>>> generated query becomes syntax incorrect query. Can you please advise
>>>>if
>>>> this is a defect? Thanks.
>>>> The version of JENA I tested is 2.7.1
>>>
>>>There have been various improvements and fixes in this area which you'll
>>>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>>>(from the Apache snapshot maven repository)
>>>
>>>    Andy
>>>
>>>> The code I rewrite the query is:
>>>> Query query = QueryFactory./create/(queryString);
>>>> AlgebraGenerator ag =
>>>> *new*AlgebraGenerator();
>>>> Op op = ag.compile(query);
>>>> Query query2 = OpAsQuery./asQuery/(op);
>>>> The original query is:
>>>> PREFIX dcterms: <http://purl.org/dc/terms/>
>>>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>>>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>>>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>>>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>>> ?holiday dcterms:subject ?country_cat
>>>> }GROUP by ?country_cat
>>>> }
>>>> {
>>>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>>> WHERE {
>>>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>>> ?holiday dcterms:subject ?country_cat
>>>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>>>> }GROUP by ?country_cat
>>>> }
>>>> }
>>>> The generated query is:
>>>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>>>> WHERE
>>>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>>> BIND(count(?holiday) AS ?num_of_holidays)
>>>> }
>>>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day"
>>>>)
>>>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>>>> }
>>>> }
>>>> GROUP BY ?country_cat
>>>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>>>> expression not legal at this point".
>>>> Attached is a hava program to demonstrate the problem,

Re: problem in rewriting query by AlgebraGenerator

Posted by Rob Vesse <rv...@yarcdata.com>.
No I did not file a specific defect yet, please feel free to log a JIRA
bug if you wish

Rob



On 4/23/13 1:37 PM, "John Liu" <jo...@yahoo.com> wrote:

>Thanks, Rob for your quick reponse.
> 
>Is there a defect number that I can track this bug?
> 
>Thanks, John
> 
>
>________________________________
> From: Rob Vesse <rv...@yarcdata.com>
>To: "users@jena.apache.org" <us...@jena.apache.org>; John Liu
><jo...@yahoo.com>
>Sent: Tuesday, April 23, 2013 4:13:51 PM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>It's a bug in how OpAsQuery converts sub-queries, watch this space for a
>fix
>
>Rob
>
>
>On 4/23/13 12:35 PM, "John Liu" <jo...@yahoo.com> wrote:
>
>>oh I see, thanks Rob.
>> 
>>I paste the class here, you will see the exception error when you run the
>>code.
>> import
>>com.hp.hpl.jena.query.Query;import
>>com.hp.hpl.jena.query.QueryFactory;import
>>com.hp.hpl.jena.sparql.algebra.AlgebraGenerator;import
>>com.hp.hpl.jena.sparql.algebra.Op;import
>>com.hp.hpl.jena.sparql.algebra.OpAsQuery;public
>>classTestJena {
>>/*** 
>>@paramargs*/
>>publicstaticvoidmain(String[] args) {String queryString =
>>"PREFIX dcterms: <http://purl.org/dc/terms/> \n"+
>>"PREFIX dbpedia: <http://dbpedia.org/resource/> \n"+
>>"SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { \n"+
>>"{"+
>>"SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) \n"+
>>"WHERE {"+
>>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>>"?holiday dcterms:subject ?country_cat \n"+
>>"}GROUP by ?country_cat \n"+
>>"} \n"+
>>"{ \n"+
>>"SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>\n"+
>>"WHERE { \n"+
>>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>>"?holiday dcterms:subject ?country_cat \n"+
>>"FILTER(?holiday=\"http://dbpedia.org/resource/Lunar_New_Year/'s_Day/")
>>\n"+
>>"}GROUP by ?country_cat \n"+
>>"} \n"+ 
>>"}\n";System.
>>out.println("Original query: \n"+ queryString);Query query =
>>QueryFactory.create(queryString);
>>AlgebraGenerator ag =
>>newAlgebraGenerator();Op op = ag.compile(query);
>>Query query2 = OpAsQuery.asQuery(op);
>>String queryString2 = query2.toString();
>>System.
>>out.println("Update query: \n"+ queryString2);Query newQuery2 =
>>QueryFactory.create(queryString2);
>>}
>>}
>> 
>>
>>________________________________
>> From: Rob Vesse <rv...@yarcdata.com>
>>To: "users@jena.apache.org" <us...@jena.apache.org>
>>Sent: Tuesday, April 23, 2013 2:06:34 PM
>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>  
>>
>>John
>>
>>Apache list strips attachments, if you have a code sample please just
>>paste it into the email or provide a link to a pastebin/similar site with
>>your code sample
>>
>>Rob
>>
>>
>>On 4/23/13 11:02 AM, "John Liu" <jo...@yahoo.com> wrote:
>>
>>>Thanks Andy for your quick reply.
>>> 
>>>I tested Jena 2.10.1 and the problem still exists. Could you please run
>>>the attached java code to see if it is a defect?
>>> 
>>>Thanks, John
>>> 
>>>
>>>________________________________
>>> From: Andy Seaborne <an...@apache.org>
>>>To: users@jena.apache.org
>>>Sent: Tuesday, April 23, 2013 10:46:25 AM
>>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>>  
>>>
>>>On 23/04/13 03:10, John Liu wrote:
>>>> Hello,
>>>> I found a problem when rewriting a query by AlgebraGenerator, the
>>>> generated query becomes syntax incorrect query. Can you please advise
>>>>if
>>>> this is a defect? Thanks.
>>>> The version of JENA I tested is 2.7.1
>>>
>>>There have been various improvements and fixes in this area which you'll
>>>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>>>(from the Apache snapshot maven repository)
>>>
>>>    Andy
>>>
>>>> The code I rewrite the query is:
>>>> Query query = QueryFactory./create/(queryString);
>>>> AlgebraGenerator ag =
>>>> *new*AlgebraGenerator();
>>>> Op op = ag.compile(query);
>>>> Query query2 = OpAsQuery./asQuery/(op);
>>>> The original query is:
>>>> PREFIX dcterms: <http://purl.org/dc/terms/>
>>>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>>>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>>>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>>>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>>> ?holiday dcterms:subject ?country_cat
>>>> }GROUP by ?country_cat
>>>> }
>>>> {
>>>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>>> WHERE {
>>>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>>> ?holiday dcterms:subject ?country_cat
>>>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>>>> }GROUP by ?country_cat
>>>> }
>>>> }
>>>> The generated query is:
>>>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>>>> WHERE
>>>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>>> BIND(count(?holiday) AS ?num_of_holidays)
>>>> }
>>>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day"
>>>>)
>>>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>>>> }
>>>> }
>>>> GROUP BY ?country_cat
>>>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>>>> expression not legal at this point".
>>>> Attached is a hava program to demonstrate the problem,


Re: problem in rewriting query by AlgebraGenerator

Posted by John Liu <jo...@yahoo.com>.
Thanks, Rob for your quick reponse.
 
Is there a defect number that I can track this bug?
 
Thanks, John
 

________________________________
 From: Rob Vesse <rv...@yarcdata.com>
To: "users@jena.apache.org" <us...@jena.apache.org>; John Liu <jo...@yahoo.com> 
Sent: Tuesday, April 23, 2013 4:13:51 PM
Subject: Re: problem in rewriting query by AlgebraGenerator
  

It's a bug in how OpAsQuery converts sub-queries, watch this space for a
fix

Rob


On 4/23/13 12:35 PM, "John Liu" <jo...@yahoo.com> wrote:

>oh I see, thanks Rob.
> 
>I paste the class here, you will see the exception error when you run the
>code.
> import
>com.hp.hpl.jena.query.Query;import
>com.hp.hpl.jena.query.QueryFactory;import
>com.hp.hpl.jena.sparql.algebra.AlgebraGenerator;import
>com.hp.hpl.jena.sparql.algebra.Op;import
>com.hp.hpl.jena.sparql.algebra.OpAsQuery;public
>classTestJena {
>/*** 
>@paramargs*/
>publicstaticvoidmain(String[] args) {String queryString =
>"PREFIX dcterms: <http://purl.org/dc/terms/> \n"+
>"PREFIX dbpedia: <http://dbpedia.org/resource/> \n"+
>"SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { \n"+
>"{"+
>"SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) \n"+
>"WHERE {"+
>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>"?holiday dcterms:subject ?country_cat \n"+
>"}GROUP by ?country_cat \n"+
>"} \n"+
>"{ \n"+
>"SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year) \n"+
>"WHERE { \n"+
>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>"?holiday dcterms:subject ?country_cat \n"+
>"FILTER(?holiday=\"http://dbpedia.org/resource/Lunar_New_Year/'s_Day/")
>\n"+
>"}GROUP by ?country_cat \n"+
>"} \n"+ 
>"}\n";System.
>out.println("Original query: \n"+ queryString);Query query =
>QueryFactory.create(queryString);
>AlgebraGenerator ag =
>newAlgebraGenerator();Op op = ag.compile(query);
>Query query2 = OpAsQuery.asQuery(op);
>String queryString2 = query2.toString();
>System.
>out.println("Update query: \n"+ queryString2);Query newQuery2 =
>QueryFactory.create(queryString2);
>}
>}
> 
>
>________________________________
> From: Rob Vesse <rv...@yarcdata.com>
>To: "users@jena.apache.org" <us...@jena.apache.org>
>Sent: Tuesday, April 23, 2013 2:06:34 PM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>John
>
>Apache list strips attachments, if you have a code sample please just
>paste it into the email or provide a link to a pastebin/similar site with
>your code sample
>
>Rob
>
>
>On 4/23/13 11:02 AM, "John Liu" <jo...@yahoo.com> wrote:
>
>>Thanks Andy for your quick reply.
>> 
>>I tested Jena 2.10.1 and the problem still exists. Could you please run
>>the attached java code to see if it is a defect?
>> 
>>Thanks, John
>> 
>>
>>________________________________
>> From: Andy Seaborne <an...@apache.org>
>>To: users@jena.apache.org
>>Sent: Tuesday, April 23, 2013 10:46:25 AM
>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>  
>>
>>On 23/04/13 03:10, John Liu wrote:
>>> Hello,
>>> I found a problem when rewriting a query by AlgebraGenerator, the
>>> generated query becomes syntax incorrect query. Can you please advise
>>>if
>>> this is a defect? Thanks.
>>> The version of JENA I tested is 2.7.1
>>
>>There have been various improvements and fixes in this area which you'll
>>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>>(from the Apache snapshot maven repository)
>>
>>    Andy
>>
>>> The code I rewrite the query is:
>>> Query query = QueryFactory./create/(queryString);
>>> AlgebraGenerator ag =
>>> *new*AlgebraGenerator();
>>> Op op = ag.compile(query);
>>> Query query2 = OpAsQuery./asQuery/(op);
>>> The original query is:
>>> PREFIX dcterms: <http://purl.org/dc/terms/>
>>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>> ?holiday dcterms:subject ?country_cat
>>> }GROUP by ?country_cat
>>> }
>>> {
>>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>> WHERE {
>>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>> ?holiday dcterms:subject ?country_cat
>>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>>> }GROUP by ?country_cat
>>> }
>>> }
>>> The generated query is:
>>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>>> WHERE
>>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>> BIND(count(?holiday) AS ?num_of_holidays)
>>> }
>>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day"
>>>)
>>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>>> }
>>> }
>>> GROUP BY ?country_cat
>>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>>> expression not legal at this point".
>>> Attached is a hava program to demonstrate the problem,

Re: problem in rewriting query by AlgebraGenerator

Posted by Rob Vesse <rv...@yarcdata.com>.
It's a bug in how OpAsQuery converts sub-queries, watch this space for a
fix

Rob


On 4/23/13 12:35 PM, "John Liu" <jo...@yahoo.com> wrote:

>oh I see, thanks Rob.
> 
>I paste the class here, you will see the exception error when you run the
>code.
> import
>com.hp.hpl.jena.query.Query;import
>com.hp.hpl.jena.query.QueryFactory;import
>com.hp.hpl.jena.sparql.algebra.AlgebraGenerator;import
>com.hp.hpl.jena.sparql.algebra.Op;import
>com.hp.hpl.jena.sparql.algebra.OpAsQuery;public
>classTestJena {
>/*** 
>@paramargs*/
>publicstaticvoidmain(String[] args) {String queryString =
>"PREFIX dcterms: <http://purl.org/dc/terms/> \n"+
>"PREFIX dbpedia: <http://dbpedia.org/resource/> \n"+
>"SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { \n"+
>"{"+
>"SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) \n"+
>"WHERE {"+
>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>"?holiday dcterms:subject ?country_cat \n"+
>"}GROUP by ?country_cat \n"+
>"} \n"+
>"{ \n"+
>"SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year) \n"+
>"WHERE { \n"+
>"?country_cat <http://www.w3.org/2004/02/skos/core#broader>
><http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
>"?holiday dcterms:subject ?country_cat \n"+
>"FILTER(?holiday=\"http://dbpedia.org/resource/Lunar_New_Year\'s_Day\")
>\n"+
>"}GROUP by ?country_cat \n"+
>"} \n"+ 
>"}\n";System.
>out.println("Original query: \n"+ queryString);Query query =
>QueryFactory.create(queryString);
>AlgebraGenerator ag =
>newAlgebraGenerator();Op op = ag.compile(query);
>Query query2 = OpAsQuery.asQuery(op);
>String queryString2 = query2.toString();
>System.
>out.println("Update query: \n"+ queryString2);Query newQuery2 =
>QueryFactory.create(queryString2);
>}
>}
> 
>
>________________________________
> From: Rob Vesse <rv...@yarcdata.com>
>To: "users@jena.apache.org" <us...@jena.apache.org>
>Sent: Tuesday, April 23, 2013 2:06:34 PM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>John
>
>Apache list strips attachments, if you have a code sample please just
>paste it into the email or provide a link to a pastebin/similar site with
>your code sample
>
>Rob
>
>
>On 4/23/13 11:02 AM, "John Liu" <jo...@yahoo.com> wrote:
>
>>Thanks Andy for your quick reply.
>> 
>>I tested Jena 2.10.1 and the problem still exists. Could you please run
>>the attached java code to see if it is a defect?
>> 
>>Thanks, John
>> 
>>
>>________________________________
>> From: Andy Seaborne <an...@apache.org>
>>To: users@jena.apache.org
>>Sent: Tuesday, April 23, 2013 10:46:25 AM
>>Subject: Re: problem in rewriting query by AlgebraGenerator
>>  
>>
>>On 23/04/13 03:10, John Liu wrote:
>>> Hello,
>>> I found a problem when rewriting a query by AlgebraGenerator, the
>>> generated query becomes syntax incorrect query. Can you please advise
>>>if
>>> this is a defect? Thanks.
>>> The version of JENA I tested is 2.7.1
>>
>>There have been various improvements and fixes in this area which you'll
>>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>>(from the Apache snapshot maven repository)
>>
>>    Andy
>>
>>> The code I rewrite the query is:
>>> Query query = QueryFactory./create/(queryString);
>>> AlgebraGenerator ag =
>>> *new*AlgebraGenerator();
>>> Op op = ag.compile(query);
>>> Query query2 = OpAsQuery./asQuery/(op);
>>> The original query is:
>>> PREFIX dcterms: <http://purl.org/dc/terms/>
>>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>> ?holiday dcterms:subject ?country_cat
>>> }GROUP by ?country_cat
>>> }
>>> {
>>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>>> WHERE {
>>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>>> ?holiday dcterms:subject ?country_cat
>>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>>> }GROUP by ?country_cat
>>> }
>>> }
>>> The generated query is:
>>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>>> WHERE
>>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>> BIND(count(?holiday) AS ?num_of_holidays)
>>> }
>>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day"
>>>)
>>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>>> }
>>> }
>>> GROUP BY ?country_cat
>>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>>> expression not legal at this point".
>>> Attached is a hava program to demonstrate the problem,


Re: problem in rewriting query by AlgebraGenerator

Posted by John Liu <jo...@yahoo.com>.
oh I see, thanks Rob.
 
I paste the class here, you will see the exception error when you run the code.
 import
com.hp.hpl.jena.query.Query;import
com.hp.hpl.jena.query.QueryFactory;import
com.hp.hpl.jena.sparql.algebra.AlgebraGenerator;import
com.hp.hpl.jena.sparql.algebra.Op;import
com.hp.hpl.jena.sparql.algebra.OpAsQuery;public
classTestJena {
/*** 
@paramargs*/
publicstaticvoidmain(String[] args) {String queryString = 
"PREFIX dcterms: <http://purl.org/dc/terms/> \n"+
"PREFIX dbpedia: <http://dbpedia.org/resource/> \n"+
"SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { \n"+
"{"+
"SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) \n"+
"WHERE {"+
"?country_cat <http://www.w3.org/2004/02/skos/core#broader> <http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
"?holiday dcterms:subject ?country_cat \n"+
"}GROUP by ?country_cat \n"+
"} \n"+
"{ \n"+
"SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year) \n"+
"WHERE { \n"+
"?country_cat <http://www.w3.org/2004/02/skos/core#broader> <http://dbpedia.org/resource/Category:Public_holidays_by_country>. \n"+
"?holiday dcterms:subject ?country_cat \n"+
"FILTER(?holiday=\"http://dbpedia.org/resource/Lunar_New_Year\'s_Day\") \n"+
"}GROUP by ?country_cat \n"+
"} \n"+ 
"}\n";System.
out.println("Original query: \n"+ queryString);Query query = QueryFactory.create(queryString);
AlgebraGenerator ag = 
newAlgebraGenerator();Op op = ag.compile(query);
Query query2 = OpAsQuery.asQuery(op);
String queryString2 = query2.toString();
System.
out.println("Update query: \n"+ queryString2);Query newQuery2 = QueryFactory.create(queryString2);
}
}
 

________________________________
 From: Rob Vesse <rv...@yarcdata.com>
To: "users@jena.apache.org" <us...@jena.apache.org> 
Sent: Tuesday, April 23, 2013 2:06:34 PM
Subject: Re: problem in rewriting query by AlgebraGenerator
  

John

Apache list strips attachments, if you have a code sample please just
paste it into the email or provide a link to a pastebin/similar site with
your code sample

Rob


On 4/23/13 11:02 AM, "John Liu" <jo...@yahoo.com> wrote:

>Thanks Andy for your quick reply.
> 
>I tested Jena 2.10.1 and the problem still exists. Could you please run
>the attached java code to see if it is a defect?
> 
>Thanks, John
> 
>
>________________________________
> From: Andy Seaborne <an...@apache.org>
>To: users@jena.apache.org
>Sent: Tuesday, April 23, 2013 10:46:25 AM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>On 23/04/13 03:10, John Liu wrote:
>> Hello,
>> I found a problem when rewriting a query by AlgebraGenerator, the
>> generated query becomes syntax incorrect query. Can you please advise if
>> this is a defect? Thanks.
>> The version of JENA I tested is 2.7.1
>
>There have been various improvements and fixes in this area which you'll
>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>(from the Apache snapshot maven repository)
>
>    Andy
>
>> The code I rewrite the query is:
>> Query query = QueryFactory./create/(queryString);
>> AlgebraGenerator ag =
>> *new*AlgebraGenerator();
>> Op op = ag.compile(query);
>> Query query2 = OpAsQuery./asQuery/(op);
>> The original query is:
>> PREFIX dcterms: <http://purl.org/dc/terms/>
>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>> ?holiday dcterms:subject ?country_cat
>> }GROUP by ?country_cat
>> }
>> {
>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>> WHERE {
>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>> ?holiday dcterms:subject ?country_cat
>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>> }GROUP by ?country_cat
>> }
>> }
>> The generated query is:
>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>> WHERE
>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>> BIND(count(?holiday) AS ?num_of_holidays)
>> }
>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day" )
>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>> }
>> }
>> GROUP BY ?country_cat
>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>> expression not legal at this point".
>> Attached is a hava program to demonstrate the problem,
>>

Re: problem in rewriting query by AlgebraGenerator

Posted by Rob Vesse <rv...@yarcdata.com>.
John

Apache list strips attachments, if you have a code sample please just
paste it into the email or provide a link to a pastebin/similar site with
your code sample

Rob


On 4/23/13 11:02 AM, "John Liu" <jo...@yahoo.com> wrote:

>Thanks Andy for your quick reply.
> 
>I tested Jena 2.10.1 and the problem still exists. Could you please run
>the attached java code to see if it is a defect?
> 
>Thanks, John
> 
>
>________________________________
> From: Andy Seaborne <an...@apache.org>
>To: users@jena.apache.org
>Sent: Tuesday, April 23, 2013 10:46:25 AM
>Subject: Re: problem in rewriting query by AlgebraGenerator
>  
>
>On 23/04/13 03:10, John Liu wrote:
>> Hello,
>> I found a problem when rewriting a query by AlgebraGenerator, the
>> generated query becomes syntax incorrect query. Can you please advise if
>> this is a defect? Thanks.
>> The version of JENA I tested is 2.7.1
>
>There have been various improvements and fixes in this area which you'll
>find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT
>(from the Apache snapshot maven repository)
>
>    Andy
>
>> The code I rewrite the query is:
>> Query query = QueryFactory./create/(queryString);
>> AlgebraGenerator ag =
>> *new*AlgebraGenerator();
>> Op op = ag.compile(query);
>> Query query2 = OpAsQuery./asQuery/(op);
>> The original query is:
>> PREFIX dcterms: <http://purl.org/dc/terms/>
>> PREFIX dbpedia: <http://dbpedia.org/resource/>
>> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
>> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
>> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>> ?holiday dcterms:subject ?country_cat
>> }GROUP by ?country_cat
>> }
>> {
>> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
>> WHERE {
>> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
>> ?holiday dcterms:subject ?country_cat
>> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
>> }GROUP by ?country_cat
>> }
>> }
>> The generated query is:
>> SELECT ?country_cat ?celebrate_Chinese_New_Year
>> WHERE
>> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>> BIND(count(?holiday) AS ?num_of_holidays)
>> }
>> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
>> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
>> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
>> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day" )
>> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
>> }
>> }
>> GROUP BY ?country_cat
>> The generated query has a syntax error: "Line 5, column 12: Aggregate
>> expression not legal at this point".
>> Attached is a hava program to demonstrate the problem,
>>


Re: problem in rewriting query by AlgebraGenerator

Posted by John Liu <jo...@yahoo.com>.
Thanks Andy for your quick reply.
 
I tested Jena 2.10.1 and the problem still exists. Could you please run the attached java code to see if it is a defect?
 
Thanks, John
 

________________________________
 From: Andy Seaborne <an...@apache.org>
To: users@jena.apache.org 
Sent: Tuesday, April 23, 2013 10:46:25 AM
Subject: Re: problem in rewriting query by AlgebraGenerator
  

On 23/04/13 03:10, John Liu wrote:
> Hello,
> I found a problem when rewriting a query by AlgebraGenerator, the
> generated query becomes syntax incorrect query. Can you please advise if
> this is a defect? Thanks.
> The version of JENA I tested is 2.7.1

There have been various improvements and fixes in this area which you'll 
find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT 
(from the Apache snapshot maven repository)

    Andy

> The code I rewrite the query is:
> Query query = QueryFactory./create/(queryString);
> AlgebraGenerator ag =
> *new*AlgebraGenerator();
> Op op = ag.compile(query);
> Query query2 = OpAsQuery./asQuery/(op);
> The original query is:
> PREFIX dcterms: <http://purl.org/dc/terms/>
> PREFIX dbpedia: <http://dbpedia.org/resource/>
> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
> ?holiday dcterms:subject ?country_cat
> }GROUP by ?country_cat
> }
> {
> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
> WHERE {
> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
> ?holiday dcterms:subject ?country_cat
> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
> }GROUP by ?country_cat
> }
> }
> The generated query is:
> SELECT ?country_cat ?celebrate_Chinese_New_Year
> WHERE
> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
> BIND(count(?holiday) AS ?num_of_holidays)
> }
> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day" )
> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
> }
> }
> GROUP BY ?country_cat
> The generated query has a syntax error: "Line 5, column 12: Aggregate
> expression not legal at this point".
> Attached is a hava program to demonstrate the problem,
>
>

Re: problem in rewriting query by AlgebraGenerator

Posted by Andy Seaborne <an...@apache.org>.
On 23/04/13 03:10, John Liu wrote:
> Hello,
> I found a problem when rewriting a query by AlgebraGenerator, the
> generated query becomes syntax incorrect query. Can you please advise if
> this is a defect? Thanks.
> The version of JENA I tested is 2.7.1

There have been various improvements and fixes in this area which you'll 
find in Jena 2.10.0 and in the active development system 2.10.1-SNAPSHOT 
(from the Apache snapshot maven repository)

	Andy

> The code I rewrite the query is:
> Query query = QueryFactory./create/(queryString);
> AlgebraGenerator ag =
> *new*AlgebraGenerator();
> Op op = ag.compile(query);
> Query query2 = OpAsQuery./asQuery/(op);
> The original query is:
> PREFIX dcterms: <http://purl.org/dc/terms/>
> PREFIX dbpedia: <http://dbpedia.org/resource/>
> SELECT ?num_of_holidays ?celebrate_Chinese_New_Year WHERE {
> {SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays)
> WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
> ?holiday dcterms:subject ?country_cat
> }GROUP by ?country_cat
> }
> {
> SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year)
> WHERE {
> ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country>.
> ?holiday dcterms:subject ?country_cat
> FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day")
> }GROUP by ?country_cat
> }
> }
> The generated query is:
> SELECT ?country_cat ?celebrate_Chinese_New_Year
> WHERE
> { { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
> BIND(count(?holiday) AS ?num_of_holidays)
> }
> { ?country_cat <http://www.w3.org/2004/02/skos/core#broader>
> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
> ?holiday <http://purl.org/dc/terms/subject> ?country_cat
> FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day" )
> BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
> }
> }
> GROUP BY ?country_cat
> The generated query has a syntax error: "Line 5, column 12: Aggregate
> expression not legal at this point".
> Attached is a hava program to demonstrate the problem,
>
>


problem in rewriting query by AlgebraGenerator

Posted by John Liu <jo...@yahoo.com>.
Hello,
 
I found a problem when rewriting a query by AlgebraGenerator, the generated query becomes syntax incorrect query. Can you please advise if this is a defect? Thanks.
 
The version of JENA I tested is 2.7.1
 
 
The code I rewrite the query is:
     Query query = QueryFactory.create(queryString);
    AlgebraGenerator ag =
            newAlgebraGenerator();    Op op = ag.compile(query);
    Query query2 = OpAsQuery.asQuery(op);

The original query is:

    PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX dbpedia: <http://dbpedia.org/resource/> 
SELECT ?num_of_holidays ?celebrate_Chinese_New_Year  WHERE { 
{SELECT ?country_cat (COUNT(?holiday) as ?num_of_holidays) 
WHERE {?country_cat <http://www.w3.org/2004/02/skos/core#broader> <http://dbpedia.org/resource/Category:Public_holidays_by_country>. 
?holiday dcterms:subject ?country_cat 
}GROUP by ?country_cat 
} 
{ 
SELECT ?country_cat (COUNT(?holiday) as ?celebrate_Chinese_New_Year) 
WHERE { 
?country_cat <http://www.w3.org/2004/02/skos/core#broader> <http://dbpedia.org/resource/Category:Public_holidays_by_country>. 
?holiday dcterms:subject ?country_cat 
FILTER(?holiday="http://dbpedia.org/resource/Lunar_New_Year's_Day") 
}GROUP by ?country_cat 
} 
}


The generated query is:
SELECT  ?country_cat ?celebrate_Chinese_New_Year
WHERE
{ { ?country_cat <http://www.w3.org/2004/02/skos/core#broader> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
?holiday <http://purl.org/dc/terms/subject> ?country_cat
BIND(count(?holiday) AS ?num_of_holidays)
}
{ ?country_cat <http://www.w3.org/2004/02/skos/core#broader> <http://dbpedia.org/resource/Category:Public_holidays_by_country> .
?holiday <http://purl.org/dc/terms/subject> ?country_cat
FILTER ( ?holiday = "http://dbpedia.org/resource/Lunar_New_Year's_Day" )
BIND(count(?holiday) AS ?celebrate_Chinese_New_Year)
}
}
GROUP BY ?country_cat


The generated query has a syntax error: "Line 5, column 12: Aggregate expression not legal at this point".
 
Attached is a hava program to demonstrate the problem,  
     
 

________________________________

Re: retrieve property names

Posted by Luis Eufrasio Teixeira Neto <lu...@gmail.com>.
Dear Mr Taiden,

the code below I used to create an ontology tree into my application. Maybe
this can hep you:

ExtendedIterator<OntClass> i = ontModel.listClasses();
        while (i.hasNext()) {
            OntClass ontClass = (OntClass) i.next();
            String prefix =
ontModel.getNsURIPrefix(ontClass.getNameSpace());
            String name = ontClass.getLocalName();

            if (classes.get(name + prefix) == null) {
                Class_ c = new Class_(prefix, name);
                classes.put(prefix + name, c);
                mapPrefixes.put(prefix, ontClass.getNameSpace());

                OntClass superClass = ontClass.getSuperClass();
                if (superClass != null) {
                    String superName = superClass.getLocalName();
                    String superPrefix =
ontModel.getNsURIPrefix(superClass.getNameSpace());
                    Class_ superC = classes.get(superPrefix + superName);

                    if (superC == null) {
                        superC = new Class_(superPrefix, superName);
                        classes.put(superPrefix + superName, superC);
                        mapPrefixes.put(superPrefix,
superClass.getNameSpace());
                    }

                    c.setSuperClass(superC);
                }
            }
        }

        ExtendedIterator<DatatypeProperty> i2 = ontModel
                .listDatatypeProperties();
        while (i2.hasNext()) {
            DatatypeProperty datatypeProperty = (DatatypeProperty)
i2.next();

            if (datatypeProperty.getDomain() != null &&
datatypeProperty.getRange() != null) {
                String dClassPrefix =
ontModel.getNsURIPrefix(datatypeProperty.getDomain().getNameSpace());
                String dClassName =
datatypeProperty.getDomain().getLocalName();
                Class_ dClass = classes.get(dClassPrefix + dClassName);
                String dpName = datatypeProperty.getLocalName();
                String dpPrefix =
ontModel.getNsURIPrefix(datatypeProperty.getNameSpace());
                String rangeName =
datatypeProperty.getRange().getLocalName();

                DataProperty dp = new DataProperty(dpPrefix, dpName,
dClass, rangeName);
                if (dClass != null) {
                    dClass.getdProperties().add(dp);
                    mapPrefixes.put(dpPrefix,
datatypeProperty.getNameSpace());
                }
            }
        }

        ExtendedIterator<com.hp.hpl.jena.ontology.ObjectProperty> i3 =
ontModel.listObjectProperties();
        while (i3.hasNext()) {
            ObjectProperty objectProperty = (ObjectProperty) i3.next();

            if (objectProperty.getDomain() != null &&
objectProperty.getRange() != null) {
                String dClassPrefix =
ontModel.getNsURIPrefix(objectProperty.getDomain().getNameSpace());
                String dClassName =
objectProperty.getDomain().getLocalName();
                String rClassPrefix =
ontModel.getNsURIPrefix(objectProperty.getDomain().getNameSpace());
                String rClassName =
objectProperty.getRange().getLocalName();
                String opName = objectProperty.getLocalName();
                String opPrefix =
ontModel.getNsURIPrefix(objectProperty.getNameSpace());

                Class_ dClass = classes.get(dClassPrefix + dClassName);
                Class_ rClass = classes.get(rClassPrefix + rClassName);

                ObjProperty op = new ObjProperty(opPrefix, opName, dClass,
rClass);
                if (dClass != null) {
                    dClass.getoProperties().add(op);
                    mapPrefixes.put(opPrefix,
objectProperty.getNameSpace());
                }
            }
        }



2013/4/20 aar thi <rt...@gmail.com>

>   Set<String> prop = new HashSet<String>();
>            ExtendedIterator rootIterator =
> classname.listDeclaredProperties();
>         int i=0;
>         while (rootIterator.hasNext()){
>             OntProperty ontRoot = (OntProperty) rootIterator.next();
>             String properties = ontRoot.toString();
>             int propertyLength = properties.length();
>                 int propertyIndex = properties.lastIndexOf("#");
>             if (propertyIndex != -1){
>                 String property = properties.substring(propertyIndex+1,
>  propertyLength);
>                 prop.add(property);
>             }
>         }
>
>          but this code display a property again and again.... i used to get
> a single property multiple times.. how to avoid that?
>
>
> On Fri, Apr 19, 2013 at 2:48 PM, Andy Seaborne <an...@apache.org> wrote:
>
> > On 19/04/13 19:21, aar thi wrote:
> >
> >> hi i'm doing a small project in ontology,  i  need to retrieve all the
> >> property names present in a particular class in the ontology. some one
> >> help
> >> me to do that in jena
> >>
> >>
> > What have you tried?
> >
> >
> >
>



-- 
Um abraço,
Luís Eufrasio T. Neto
MSN: luis_eufrasio@hotmail.com

"Ser LIVRE é ser capaz de AMAR sem exigir nada em troca."

Re: retrieve property names

Posted by aar thi <rt...@gmail.com>.
  Set<String> prop = new HashSet<String>();
           ExtendedIterator rootIterator =
classname.listDeclaredProperties();
        int i=0;
        while (rootIterator.hasNext()){
            OntProperty ontRoot = (OntProperty) rootIterator.next();
            String properties = ontRoot.toString();
            int propertyLength = properties.length();
                int propertyIndex = properties.lastIndexOf("#");
            if (propertyIndex != -1){
                String property = properties.substring(propertyIndex+1,
 propertyLength);
                prop.add(property);
            }
        }

         but this code display a property again and again.... i used to get
a single property multiple times.. how to avoid that?


On Fri, Apr 19, 2013 at 2:48 PM, Andy Seaborne <an...@apache.org> wrote:

> On 19/04/13 19:21, aar thi wrote:
>
>> hi i'm doing a small project in ontology,  i  need to retrieve all the
>> property names present in a particular class in the ontology. some one
>> help
>> me to do that in jena
>>
>>
> What have you tried?
>
>
>

Re: retrieve property names

Posted by Andy Seaborne <an...@apache.org>.
On 19/04/13 19:21, aar thi wrote:
> hi i'm doing a small project in ontology,  i  need to retrieve all the
> property names present in a particular class in the ontology. some one help
> me to do that in jena
>

What have you tried?