You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by emri mbiemri <em...@gmail.com> on 2021/04/27 10:55:55 UTC

SPARQL query on a specific RDF format

Dears,

I am trying to query a specific RDF file.  I  need this solution for my studies.

The file I have to work with is:
https://github.com/iliriani/Test/blob/main/Notebook.rdf

I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!

For instance, I want to get all attributes of class "Teacher", it should return me:
- id
- Emri
- Mbiemri
- Lendet
- Evaluations
- User

Re: Re: SPARQL query on a specific RDF format

Posted by emri mbiemri <em...@gmail.com>.
Many thanks Lorenz, I appreciate your support.

Yes, I have seen this solution also on SO.

Evaluation and Users are other classes that are part of the "Teacher" class. The "Teacher" is as below:
|| Teacher |
---------------|
|| id :int ||
|| Emri: String ||
|| Mbiemri: String ||
|| Lendet: Subject: <class> ||
|| Evaluations: collection[Evaluation] : <class>||
|| User: User: <class> ||

Those all are attributes of the class "Teacher" but differ by their types and may have additional nodes to access them through the SPARQL query. 

On 2021/04/29 08:43:31, Lorenz Buehmann <bu...@informatik.uni-leipzig.de> wrote: 
> well, there is some <Class> with <Name> "Teacher":
> 
> |BASE    <http://www.w3.org/TR/html4/>||
> ||PREFIX  : <http://acandonorway.github.com/XmlToRdf/ontology.ttl#>||
> ||
> ||SELECT  ?o||
> ||WHERE||
> ||  { ?x  <Name>  "Teacher" ;||
> ||        a       <Class> .||
> ||    ?x (:hasChild/:hasChild)/<Name> ?o||
> ||  }|
> 
> 
> it does return
> 
> |-------------||
> ||| o         |||
> ||=============||
> ||| "Emri"    |||
> ||| "Lendet"  |||
> ||| "Mbiemri" |||
> ||| "Id"      |||
> ||-------------|
> 
> But I don't see how the other two things ('Evaluations', 'User') would 
> be related to the class ...
> 
> By the way, also asked and answered at SO: 
> https://stackoverflow.com/questions/67298506/sparql-query-on-a-specific-rdf-format
> 
> On 27.04.21 17:49, Andy Seaborne wrote:
> >
> >
> > On 27/04/2021 14:11, emri mbiemri wrote:
> >> The "Teacher" node is within a <class> node and the "Teacher" class 
> >> contains the <attribute> node but I don't know how to get all these 
> >> attributes due to the complex model format.
> >
> > There is no <class>
> >
> > There is
> >
> > <Class2>Teacher</Class2>
> >
> > but it is a property <Class2> and a string "Teacher"
> >
> > As I suggested:
> >
> > riot --pretty Turtle Notebook.rdf
> >
> >     Andy
> >
> >>
> >> On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote:
> >>> There isn't a class Teacher in the file - there is a string 
> >>> "Teacher" in
> >>> a couple of places.
> >>>
> >>> Try writing the file out in a format that is easier to look at:
> >>>
> >>> Command line:
> >>>
> >>> riot --pretty Turtle Notebook.rdf
> >>>
> >>> To query for all classes:
> >>>
> >>> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
> >>>
> >>>       Andy
> >>>
> >>> On 27/04/2021 11:55, emri mbiemri wrote:
> >>>> Dears,
> >>>>
> >>>> I am trying to query a specific RDF file.  I  need this solution 
> >>>> for my studies.
> >>>>
> >>>> The file I have to work with is:
> >>>> https://github.com/iliriani/Test/blob/main/Notebook.rdf
> >>>>
> >>>> I am trying to get somehow all the attributes of a given class 
> >>>> within this model. But cannot find the right query!
> >>>>
> >>>> For instance, I want to get all attributes of class "Teacher", it 
> >>>> should return me:
> >>>> - id
> >>>> - Emri
> >>>> - Mbiemri
> >>>> - Lendet
> >>>> - Evaluations
> >>>> - User
> >>>>
> >>>
> 

Re: Re: SPARQL query on a specific RDF format

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
well, there is some <Class> with <Name> "Teacher":

|BASE    <http://www.w3.org/TR/html4/>||
||PREFIX  : <http://acandonorway.github.com/XmlToRdf/ontology.ttl#>||
||
||SELECT  ?o||
||WHERE||
||  { ?x  <Name>  "Teacher" ;||
||        a       <Class> .||
||    ?x (:hasChild/:hasChild)/<Name> ?o||
||  }|


it does return

|-------------||
||| o         |||
||=============||
||| "Emri"    |||
||| "Lendet"  |||
||| "Mbiemri" |||
||| "Id"      |||
||-------------|

But I don't see how the other two things ('Evaluations', 'User') would 
be related to the class ...

By the way, also asked and answered at SO: 
https://stackoverflow.com/questions/67298506/sparql-query-on-a-specific-rdf-format

On 27.04.21 17:49, Andy Seaborne wrote:
>
>
> On 27/04/2021 14:11, emri mbiemri wrote:
>> The "Teacher" node is within a <class> node and the "Teacher" class 
>> contains the <attribute> node but I don't know how to get all these 
>> attributes due to the complex model format.
>
> There is no <class>
>
> There is
>
> <Class2>Teacher</Class2>
>
> but it is a property <Class2> and a string "Teacher"
>
> As I suggested:
>
> riot --pretty Turtle Notebook.rdf
>
>     Andy
>
>>
>> On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote:
>>> There isn't a class Teacher in the file - there is a string 
>>> "Teacher" in
>>> a couple of places.
>>>
>>> Try writing the file out in a format that is easier to look at:
>>>
>>> Command line:
>>>
>>> riot --pretty Turtle Notebook.rdf
>>>
>>> To query for all classes:
>>>
>>> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
>>>
>>>       Andy
>>>
>>> On 27/04/2021 11:55, emri mbiemri wrote:
>>>> Dears,
>>>>
>>>> I am trying to query a specific RDF file.  I  need this solution 
>>>> for my studies.
>>>>
>>>> The file I have to work with is:
>>>> https://github.com/iliriani/Test/blob/main/Notebook.rdf
>>>>
>>>> I am trying to get somehow all the attributes of a given class 
>>>> within this model. But cannot find the right query!
>>>>
>>>> For instance, I want to get all attributes of class "Teacher", it 
>>>> should return me:
>>>> - id
>>>> - Emri
>>>> - Mbiemri
>>>> - Lendet
>>>> - Evaluations
>>>> - User
>>>>
>>>

Re: SPARQL query on a specific RDF format

Posted by Andy Seaborne <an...@apache.org>.

On 27/04/2021 14:11, emri mbiemri wrote:
> The "Teacher" node is within a <class> node and the "Teacher" class contains the <attribute> node but I don't know how to get all these attributes due to the complex model format.

There is no <class>

There is

<Class2>Teacher</Class2>

but it is a property <Class2> and a string "Teacher"

As I suggested:

riot --pretty Turtle Notebook.rdf

     Andy

> 
> On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote:
>> There isn't a class Teacher in the file - there is a string "Teacher" in
>> a couple of places.
>>
>> Try writing the file out in a format that is easier to look at:
>>
>> Command line:
>>
>> riot --pretty Turtle Notebook.rdf
>>
>> To query for all classes:
>>
>> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
>>
>>       Andy
>>
>> On 27/04/2021 11:55, emri mbiemri wrote:
>>> Dears,
>>>
>>> I am trying to query a specific RDF file.  I  need this solution for my studies.
>>>
>>> The file I have to work with is:
>>> https://github.com/iliriani/Test/blob/main/Notebook.rdf
>>>
>>> I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!
>>>
>>> For instance, I want to get all attributes of class "Teacher", it should return me:
>>> - id
>>> - Emri
>>> - Mbiemri
>>> - Lendet
>>> - Evaluations
>>> - User
>>>
>>

Re: Re: SPARQL query on a specific RDF format

Posted by emri mbiemri <em...@gmail.com>.
Thanks a lot for your reply.

The data model is the same: https://github.com/iliriani/Test/blob/main/Notebook.rdf

The issue is just that how to get belonging <attribute> of a given <class>?

For instance, as I said if I query for the attributes of class "Teacher" I should get the result:
- id
- Emri
 - Mbiemri
- Lendet
 - Evaluations
- User

because the above <attribute> are within the <class> "Teacher".

On 2021/04/27 13:41:31, Lorenz Buehmann <bu...@informatik.uni-leipzig.de> wrote: 
> Maybe I'm mixing up things, but didn't have the same question(s) and 
> data model some time ago?
> 
> On 27.04.21 15:11, emri mbiemri wrote:
> > The "Teacher" node is within a <class> node and the "Teacher" class contains the <attribute> node but I don't know how to get all these attributes due to the complex model format.
> >
> > On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote:
> >> There isn't a class Teacher in the file - there is a string "Teacher" in
> >> a couple of places.
> >>
> >> Try writing the file out in a format that is easier to look at:
> >>
> >> Command line:
> >>
> >> riot --pretty Turtle Notebook.rdf
> >>
> >> To query for all classes:
> >>
> >> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
> >>
> >>       Andy
> >>
> >> On 27/04/2021 11:55, emri mbiemri wrote:
> >>> Dears,
> >>>
> >>> I am trying to query a specific RDF file.  I  need this solution for my studies.
> >>>
> >>> The file I have to work with is:
> >>> https://github.com/iliriani/Test/blob/main/Notebook.rdf
> >>>
> >>> I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!
> >>>
> >>> For instance, I want to get all attributes of class "Teacher", it should return me:
> >>> - id
> >>> - Emri
> >>> - Mbiemri
> >>> - Lendet
> >>> - Evaluations
> >>> - User
> >>>
> 

Re: Re: SPARQL query on a specific RDF format

Posted by emri mbiemri <em...@gmail.com>.
Thanks for your reply.
The data model is the same: https://github.com/iliriani/Test/blob/main/Notebook.rdf

The issue is just how to get all the nested <attribute> that belongs to a specific <class> e.g. "Teacher" in this data model?

For instance, as I said the end result should give me for class "Teacher" this results: 
 - id
- Emri
- Mbiemri
- Lendet
- Evaluations
- User
 


On 2021/04/27 13:41:31, Lorenz Buehmann <bu...@informatik.uni-leipzig.de> wrote: 
> Maybe I'm mixing up things, but didn't have the same question(s) and 
> data model some time ago?
> 
> On 27.04.21 15:11, emri mbiemri wrote:
> > The "Teacher" node is within a <class> node and the "Teacher" class contains the <attribute> node but I don't know how to get all these attributes due to the complex model format.
> >
> > On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote:
> >> There isn't a class Teacher in the file - there is a string "Teacher" in
> >> a couple of places.
> >>
> >> Try writing the file out in a format that is easier to look at:
> >>
> >> Command line:
> >>
> >> riot --pretty Turtle Notebook.rdf
> >>
> >> To query for all classes:
> >>
> >> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
> >>
> >>       Andy
> >>
> >> On 27/04/2021 11:55, emri mbiemri wrote:
> >>> Dears,
> >>>
> >>> I am trying to query a specific RDF file.  I  need this solution for my studies.
> >>>
> >>> The file I have to work with is:
> >>> https://github.com/iliriani/Test/blob/main/Notebook.rdf
> >>>
> >>> I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!
> >>>
> >>> For instance, I want to get all attributes of class "Teacher", it should return me:
> >>> - id
> >>> - Emri
> >>> - Mbiemri
> >>> - Lendet
> >>> - Evaluations
> >>> - User
> >>>
> 

Re: Re: SPARQL query on a specific RDF format

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Maybe I'm mixing up things, but didn't have the same question(s) and 
data model some time ago?

On 27.04.21 15:11, emri mbiemri wrote:
> The "Teacher" node is within a <class> node and the "Teacher" class contains the <attribute> node but I don't know how to get all these attributes due to the complex model format.
>
> On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote:
>> There isn't a class Teacher in the file - there is a string "Teacher" in
>> a couple of places.
>>
>> Try writing the file out in a format that is easier to look at:
>>
>> Command line:
>>
>> riot --pretty Turtle Notebook.rdf
>>
>> To query for all classes:
>>
>> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
>>
>>       Andy
>>
>> On 27/04/2021 11:55, emri mbiemri wrote:
>>> Dears,
>>>
>>> I am trying to query a specific RDF file.  I  need this solution for my studies.
>>>
>>> The file I have to work with is:
>>> https://github.com/iliriani/Test/blob/main/Notebook.rdf
>>>
>>> I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!
>>>
>>> For instance, I want to get all attributes of class "Teacher", it should return me:
>>> - id
>>> - Emri
>>> - Mbiemri
>>> - Lendet
>>> - Evaluations
>>> - User
>>>

Re: SPARQL query on a specific RDF format

Posted by emri mbiemri <em...@gmail.com>.
The "Teacher" node is within a <class> node and the "Teacher" class contains the <attribute> node but I don't know how to get all these attributes due to the complex model format.

On 2021/04/27 13:00:38, Andy Seaborne <an...@apache.org> wrote: 
> There isn't a class Teacher in the file - there is a string "Teacher" in 
> a couple of places.
> 
> Try writing the file out in a format that is easier to look at:
> 
> Command line:
> 
> riot --pretty Turtle Notebook.rdf
> 
> To query for all classes:
> 
> sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'
> 
>      Andy
> 
> On 27/04/2021 11:55, emri mbiemri wrote:
> > Dears,
> > 
> > I am trying to query a specific RDF file.  I  need this solution for my studies.
> > 
> > The file I have to work with is:
> > https://github.com/iliriani/Test/blob/main/Notebook.rdf
> > 
> > I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!
> > 
> > For instance, I want to get all attributes of class "Teacher", it should return me:
> > - id
> > - Emri
> > - Mbiemri
> > - Lendet
> > - Evaluations
> > - User
> > 
> 

Re: SPARQL query on a specific RDF format

Posted by Andy Seaborne <an...@apache.org>.
There isn't a class Teacher in the file - there is a string "Teacher" in 
a couple of places.

Try writing the file out in a format that is easier to look at:

Command line:

riot --pretty Turtle Notebook.rdf

To query for all classes:

sparql --data ~/Desktop/Notebook.rdf 'SELECT DISTINCT ?T { ?x a ?T }'

     Andy

On 27/04/2021 11:55, emri mbiemri wrote:
> Dears,
> 
> I am trying to query a specific RDF file.  I  need this solution for my studies.
> 
> The file I have to work with is:
> https://github.com/iliriani/Test/blob/main/Notebook.rdf
> 
> I am trying to get somehow all the attributes of a given class within this model. But cannot find the right query!
> 
> For instance, I want to get all attributes of class "Teacher", it should return me:
> - id
> - Emri
> - Mbiemri
> - Lendet
> - Evaluations
> - User
>