git.ntnlv.ca
Repositories
Help
Report an Issue
qdmtl-ts.git
Code
Commits
Branches
Tags
Search
Tree:
7b75b7d
Branches
Tags
prod
qdmtl-ts.git
onto.php
handling onto.qdmtl.ca
davvalent
commited
7b75b7d
at 2023-06-08 19:20:14
onto.php
Blame
History
Raw
<?php /** * Négociation de contenu pour onto.qdmtl.ca : .htaccess + PHP */ require 'parse-ini.php'; require 'vendor/autoload.php'; /** * fonction use_path_to_query * Trois arguments : * requête, store, true pour var_dump() si debug nécessaire */ function use_path_to_query($q, $s, $vd = false) { $rs = $s->query($q); if (!$s->getErrors()) { $index_returned_query_type = [ 'construct', 'describe' ]; $result = (in_array($rs['query_type'], $index_returned_query_type)) ? $rs : $rs['result']['rows']; if ($vd) { var_dump($result); exit(); } return $result; } else { var_dump($s->getErrors()); exit(); } } $config = array( 'db_host' => 'localhost', 'db_name' => $infos['db_name'], 'db_user' => $infos['db_user'], 'db_pwd' => $infos['db_pwd'], 'store_name' => $infos['store_name'], 'max_errors' => 1, 'store_write_buffer' => 40000 ); /** namespace prefixes */ $ns = array( 'dcterms' => 'http://purl.org/dc/terms/', 'ecrm' => 'http://erlangen-crm.org/current/', 'geo' => 'http://www.opengis.net/ont/geosparql#', 'owl' => 'http://www.w3.org/2002/07/owl#', 'qdmtl' => 'http://onto.qdmtl.ca/', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'rico' => 'https://www.ica.org/standards/RiC/ontology#', 'schema' => 'https://schema.org/' ); $ns_config = array('ns' => $ns); /** instantiation */ $store = ARC2::getStore($config); $rdf_xml_serializer = ARC2::getRDFXMLSerializer($ns_config); // $store->createDBCon(); if (!$store->isSetUp()) { $store->setUp(); } $q = 'DESCRIBE <http://onto.qdmtl.ca>'; $triples = use_path_to_query($q, $store); if (!$triples['result']) { echo "SPARQL query returned 0 result"; exit(); } /** RDF/XML */ $rdf_xml_serialization = $rdf_xml_serializer->getSerializedIndex($triples['result']); header('Content-type: text/xml'); echo $rdf_xml_serialization; ?>