I have a problem with save object from my ontology into List. I did easy example on easy xml (not owl file), but now I have no idea how can I get these values for single student.
Ontology fragment:
<Ontology />
.
. //here are 250 lines of declarations etc
.
<ClassAssertion>
<Class IRI="#Stacjonarny" />
<NamedIndividual IRI="#Student_3" />
</ClassAssertion>
<DataPropertyAssertion>
<DataProperty IRI="#student_id" />
<NamedIndividual IRI="#Student_3" />
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#integer">3</Literal>
</DataPropertyAssertion>
<DataPropertyAssertion>
<DataProperty IRI="#imie" />
<NamedIndividual IRI="#Student_3" />
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#string">Grzegorz</Literal>
</DataPropertyAssertion>
<DataPropertyAssertion>
<DataProperty IRI="#nazwisko" />
<NamedIndividual IRI="#Student_3" />
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#string">Brzęczyszczykiewicz</Literal>
</DataPropertyAssertion>
<DataPropertyAssertion>
<DataProperty IRI="#wydział" />
<NamedIndividual IRI="#Student_3" />
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#string">Matematyczno-przyrodniczy</Literal>
</DataPropertyAssertion>
</Ontology>
I want take values form "Literal" marker and save them into list for student_3, 4, 5 etc as Student.
Student:
class Student
{
public int student_id { get; set; }
public string imie { get; set; }
public string nazwisko { get; set; }
public string wydzial { get; set; }
public Student(string imie, string nazwisko, string wydzial, int student_id)
{
this.student_id = student_id;
this.imie = imie;
this.nazwisko = nazwisko;
this.wydzial = wydzial;
}
}
Yesterday I spent almost half a day on rehearsals, now I'm with something like this:
class Pobierz
{
List<classes.Student> studenci = new List<classes.Student>();
public void studentow()
{
XDocument xml = XDocument.Load("moja_ontologia.owl");
studenci = from student in xml.Root.Descendants("DataPropertyAssertion")
where student.Attribute("NamedIndividual").Value.Equals("Student")
select new classes.Student
{
imie = student.Element("")
}
}
}
In one sentention: How can I get these values from "Literal" marker?