0
オントロジーのオブジェクトをリストに保存する際に問題があります。私は簡単な例をxml(owlファイルではない)でしたが、今私はどのように単一の学生のためにこれらの値を得ることができるのか分かりません。OWLファイルから解析してリストに保存する
オントロジーフラグメント:
<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>
私は値を取りたい「リテラル」マーカーを形成し、student_3、4のためのリストにそれらを保存し、学生など5など。
学生:
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;
}
}
昨日私は今、私はこのようなものでね、リハーサルではほぼ半日を過ごした:
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("")
}
}
}
を1 sententionで:これらの値を「リテラル」からどのように得ることができますか?あなたがシリアライズ&逆シリアル化を使用する必要があります
このコードはコンパイルされません。 Studentクラスの空のコンストラクタがなく、リストとして宣言された変数にLINQクエリを割り当てることはできません。 –
あなたはhttps://github.com/bpellens/owldotnetapiを見ましたか? –
@Sir Rufo はい、ありましたが私は自分のパーサーをする必要があります、それは大学のための小さなプロジェクトです。さて、私は空のコンストラクタがあり、List(単にvar studenci)として宣言された変数にクエリを割り当てません。 – Kliwer