$concepts = array(); $codeLists = array(); $keyFamilies = array(); $reader = new XMLReader(); $reader->open('xml-schema/KeyFamily.xml'); while ($reader->read()) { set_time_limit(10000); switch ($reader->nodeType) { case XMLREADER::ELEMENT: if ($reader->localName == "Concept") { $node = $reader->expand(); $agencyID = $node->getAttribute('agencyID'); $id = $node->getAttribute('id'); $Name = $node->getELementsByTagName('Name')->item(0)->textContent; $rdf->thing_from_identifier(NS . 'schema/', $id)->a('qb:DimensionProperty')->label($Name, 'en')->has('rdfs:isDefinedBy')->r(NS . 'schema/')->is('ov:defines')->of(NS . 'schema/')->has('dct:creator')->r(NS . 'agency/' . $agencyID); echo $rdf->dump_ntriples(); } else { if ($reader->localName == "Dimension") { // $node = $reader->expand(); // $concepts[$node->getAttribute('conceptAgency')][$node->getAttribute('conceptRef')]['codeLists'][]=$node->getAttribute('codelist'); // $concepts[$node->getAttribute('conceptAgency')][$node->getAttribute('conceptRef')]['codeLists'] = array_unique($concepts[$node->getAttribute('conceptAgency')][$node->getAttribute('conceptRef')]['codeLists']); } else { if ($reader->localName == "CodeList") { $node = $reader->expand(); $id = $node->getAttribute('id'); $Name = $node->getELementsByTagName('Name')->item(0)->textContent; $codeLists[$id]['label'] = $Name; $id = strtolower(str_replace('CL_', '', $node->getAttribute('id'))); $Scheme = $rdf->thing_from_identifier(NS . 'codes/', $id)->a('ecbstats:CodeList')->label($Name, 'en'); $scheme_uri = $Scheme->get_uri(); echo $rdf->dump_ntriples();
$Institution->has('eum:fnkseature')->r($instUri . '/university-hospital')->object()->a('eum:UniversityHospital')->label('University Hospital for ' . $Institution_Name, 'en')->has('dcterms:description')->l($University_Hospital_Comments, 'en'); } foreach ($vars as $var) { if (strpos($var, 'Education_Field_')) { $fieldName = str_replace('_', ' ', substr($var, strlen('Education_Field'))); if ($fieldName == 'Comments') { } else { if (!empty(${$var}) && strtolower(${$var}) != 'no') { $Field = $Rdf->thing_from_label(EUMIDA . 'education-field/', $fieldName, 'en')->a('aiiso:Subject')->is('aiiso:teaches')->of($instUri); } } } } if (!empty($Highest_Degree_Awarded)) { $Rdf->thing_from_label(EUMIDA . 'degree/', $Highest_Degree_Awarded, 'en')->a('eum:EducationDegree')->is('eum:highestDegreeAwarded')->of($instUri); } $dt = empty($Doctorate_Degrees_Awarded) ? false : 'xsd:integer'; $Rdf->thing($instUri . '/doctorates-awarded')->a('qb:Observation')->has('eum:numberOfDoctoratesAwarded')->dt($Doctorate_Degrees_Awarded, $dt)->has('eum:institution')->r($instUri)->has('sdmxdim:refPeriod')->r(YEAR_NS . $Doctorate_Degrees_Awarded_Reference_Year)->is('eum:awardedDoctoratesFigure')->of($instUri)->has('rdfs:comment')->l($Doctorate_Degrees_Comments, 'en')->has('qb:dataSet')->r($doctoratesDatasetUri); $dt = empty($Students_ISCED5) ? false : 'xsd:integer'; $Rdf->thing($instUri . '/ISCED5-Students-enrolled')->a('qb:Observation')->has('eum:numberOfISCED5Students')->dt($Students_ISCED5, $dt)->has('eum:institution')->r($instUri)->has('sdmxdim:refPeriod')->r(YEAR_NS . $Students_ISCED5_Reference_Year)->is('eum:enrolledISCED5StudentsFigure')->of($instUri)->has('rdfs:comment')->l($Students_ISCED5_Comments, 'en')->has('qb:dataSet')->r($studentsISCED5DatasetUri); $dt = empty($International_Students_ISCED5) ? false : 'xsd:integer'; $Rdf->thing($instUri . '/ISCED5-International-Students-enrolled')->a('qb:Observation')->has('eum:numberOfInternationalISCED5Students')->dt($International_Students_ISCED5, $dt)->has('eum:institution')->r($instUri)->has('sdmxdim:refPeriod')->r(YEAR_NS . $International_Students_ISCED5_Reference_Year)->is('eum:enrolledISCED5StudentsFigure')->of($instUri)->has('rdfs:comment')->l($International_Students_ISCED5_Comments, 'en')->has('qb:dataSet')->r($internationStudentsDatasetUri); $dt = empty($Students_ISCED6) ? false : 'xsd:integer'; $Rdf->thing($instUri . '/ISCED6-Students-enrolled')->a('qb:Observation')->has('eum:numberOfISCED6Students')->dt($Students_ISCED6, $dt)->has('eum:institution')->r($instUri)->has('sdmxdim:refPeriod')->r(YEAR_NS . $Students_ISCED6_Reference_Year)->is('eum:enrolledISCED6StudentsFigure')->of($instUri)->has('rdfs:comment')->l($Students_ISCED6_Comments, 'en')->has('qb:dataSet')->r($studentsISCED6DatasetUri); $dt = empty($International_Students_ISCED6) ? false : 'xsd:integer'; $Rdf->thing($instUri . '/ISCED6-International-Students-enrolled')->a('qb:Observation')->has('eum:numberOfInternationalISCED6Students')->dt($International_Students_ISCED6, $dt)->has('eum:institution')->r($instUri)->has('sdmxdim:refPeriod')->r(YEAR_NS . $International_Students_ISCED6_Reference_Year)->is('eum:enrolledInternationalISCED6StudentsFigure')->of($instUri)->has('rdfs:comment')->l($International_Students_ISCED6_Comments, 'en')->has('qb:dataSet')->r($isced6InternationalStudentsDatasetUri); $dt = empty($Total_Staff) ? false : 'xsd:integer'; $Rdf->thing($instUri . '/total-staff')->a('qb:Observation')->has('eum:numberOfStaff')->dt($Total_Staff, $dt)->has('eum:institution')->r($instUri)->has('sdmxdim:refPeriod')->r(YEAR_NS . $Total_Staff_Reference_Year)->is('eum:totalNumberOfStaffFigure')->of($instUri)->has('rdfs:comment')->l($Total_Staff_Comments, 'en')->has('qb:dataSet')->r($totalStaffDatasetUri); echo $Rdf->dump_ntriples(); } $Rdf->write_vocabulary_to_file('eum', 'eumida.vocab.ttl');
$lastTopic = false; $uris = array(); while ($topic = array_shift($topics)) { $label = ucwords(str_replace('-', ' ', $topic)); $topicUri = NS . 'concepts/' . $topic; $uris[] = $topicUri; $Topic = $conceptRdf->thing($topicUri)->a('skos:Concept')->label($label, 'en')->has('skos:inScheme')->r(NS . 'conceptscheme/ecb'); if (!$lastTopic) { $Topic->has('skos:topConceptOf')->r(NS . 'conceptscheme/ecb')->object()->a('skos:ConceptScheme')->label('European Central Bank Concepts', 'en')->has('dct:description')->l("Concepts used by the European Central Bank Statistical Warehouse", 'en')->has('skos:hasTopConcept')->r($topicUri); } else { $Topic->has('skos:broader')->r($lastTopic)->is('skos:narrower')->of($lastTopic); } $lastTopic = $topicUri; } return $uris; } $filename = $argv[1]; $fh = fopen($filename, 'r'); while ($row = fgetcsv($fh)) { set_time_limit(9999999999999); if (count($row) > 2) { csv_row_to_rdf($row); } } echo $conceptRdf->dump_ntriples(); foreach ($datasetUris as $uri => $v) { $rdf->thing($uri)->a('qb:DataSet')->has('dct:creator')->r('http://institutions.publicdata.eu/#ecb'); echo $rdf->dump_ntriples(); } file_put_contents('datasets_with_sample_series.json', json_encode($datasetUris)); echo $dateRdf->dump_ntriples();