Accessing data with SPARQL
1
Part 4: Access and Usage
To retrieve who-is-who data
2
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve who-is-who data for a person
3
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX euvoc: <http://publications.europa.eu/ontology/euvoc#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
PREFIX person: <http://publications.europa.eu/resource/person>
SELECT distinct ?person ?hasMembership ?org ?prefLabel ?familyName ?givenName ?citizenship ?img ?hasHonorificPrefix ?role
?prefLabelRole ?positionComplement ?homepage ?hasEmail ?tel
WHERE{
?person rdf:type foaf:Person.
?person org:hasMembership ?hasMembership.
FILTER(str(?familyName)= 'VON DER LEYEN').
optional{?hasMembership org:organization ?org
optional{?org skos:prefLabel ?prefLabel.FILTER(LANGMATCHES(LANG(?prefLabel),"en"))}
?person foaf:familyName ?familyName.
OPTIONAL{?person foaf:givenName ?givenName.}
OPTIONAL{?person person:citizenship ?citizenship.}
OPTIONAL{?person foaf:img ?img}
OPTIONAL{?person vcard:hasHonorificPrefix ?hasHonorificPrefix.}
optional{?hasMembership org:role ?role. ?role skos:prefLabel ?prefLabelRole. FILTER(LANGMATCHES(LANG(?prefLabelRole),"en"))}
optional{?hasMembership euvoc:positionComplement ?positionComplement. FILTER(LANGMATCHES(LANG(?positionComplement),"en"))}
OPTIONAL{?hasMembership euvoc:contactPoint ?contactPoint.
optional{?contactPoint vcard:hasAddress ?hasAddress optional{?contactPoint foaf:homepage ?homepage}
OPTIONAL{?contactPoint vcard:hasEmail ?hasEmail} OPTIONAL{?contactPoint vcard:hasTelephone ?hasTelephone.?hasTelephone vcard:hasValue ?tel.}
}} } }
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve metadata of a publication
4
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve URI of “Values and identities of EU citizens” publication by ISBN property
5
Part 4: Access and Usage
Accessing data with SPARQL
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select ?work
where {
?expression cdm:expression_belongs_to_work ?work .
?manifestation cdm:manifestation_manifests_expression ?expression .
?manifestation cdm:manifestation_isbn ?isbn. filter (str(?isbn) = "978-92-76-43232-6")
}
To retrieve what “Values and identities of EU citizens” publication is about
6
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select ?work ?label
where {
values(?work){(<http://publications.europa.eu/resource/cellar/1da26cfe-475c-11ec-91ac-01aa75ed71a1>)}
?work cdm:work_is_about_concept_eurovoc ?eurovoc .
?eurovoc skos:prefLabel ?label .
filter (lang(?label)='en')
}
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve expressions and manifestations of “Values and identities of EU citizens”
7
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select ?work ?expression ?expressionProperty ?expressionPropertyValue
?manifestation ?manifestationProperty ?manifestationPropertyValue
where
{
values(?work){(<http://publications.europa.eu/resource/cellar/1da26cfe-475c-11ec-91ac-01aa75ed71a1>)}
{
?expression cdm:expression_belongs_to_work ?work .
?manifestation cdm:manifestation_manifests_expression ?expression .
?manifestation ?manifestationProperty ?manifestationPropertyValue .
}
union
{
?expression cdm:expression_belongs_to_work ?work .
?expression ?expressionProperty ?expressionPropertyValue .
}
}
order by ?work desc(?expressionProperty)
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve the official journals for a specific period
8
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?uri ?ojclass ?ojnumber ?ojcollection ?ojyear ?workdatedoc
WHERE {
?uri cdm:official-journal_class ?ojclass .
?uri cdm:official-journal_number ?ojnumber .
?uri cdm:official-journal_part_of_collection_document ?ojcollection .
?uri cdm:official-journal_year "2022"^^xsd:gYear .
?uri cdm:official-journal_year ?ojyear .
?uri cdm:work_date_document ?workdatedoc .
?uri rdf:type cdm:official-journal .
FILTER( ?workdatedoc >= "2022-01-01"^^xsd:date
&& ?workdatedoc < "2022-04-01"^^xsd:date)}
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve the most recent date of all OJ in a specific year and sort it by date
9
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?workdatedoc
WHERE {
?uri rdf:type cdm:official-journal .
?uri cdm:work_date_document ?workdatedoc .
?uri cdm:official-journal_year "2022"^^xsd:gYear
}
ORDER BY DESC(?workdatedoc) LIMIT 1
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve multilingual titles and subtitles of a publication
10
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select ?expressionId
substr(str(?expressionLanguageUri), 59) AS ?expressionLanguage
str(?subtitle) AS ?subtitle
lang(?title) AS ?language
str(?title) AS ?title
where {
?expressionId cdm:expression_belongs_to_work ?workId.
?expressionId cdm:expression_title ?title.
?expressionId cdm:expression_uses_language ?expressionLanguageUri.
OPTIONAL{
?expressionId cdm:expression_subtitle ?subtitle.
}
values(?workId) {(<http://publications.europa.eu/resource/cellar/1c4905ef-02c2-467a-ba3c-2a340d23bd15>)}
}
Part 4: Access and Usage
Accessing data with SPARQL
To retrieve all EU treaties
11
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct ?work ?doc_id
where
{
?work a cdm:treaty;
cdm:work_id_document ?doc_id.
FILTER not exists{?work a cdm:fragment_resource_legal}.
}
Accessing data with SPARQL
Part 4: Access and Usage
To retrieve EU legislation in force about the EuroVoc concept ‘cambiamento climatico’
12
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct ?work
where
{
?work cdm:resource_legal_in-force "true"^^<http://www.w3.org/2001/XMLSchema#boolean> ;
a cdm:legislation_secondary;
cdm:work_is_about_concept_eurovoc <http://eurovoc.europa.eu/5482> .
}
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
prefix skos-core: <http://www.w3.org/2004/02/skos/core#>
select distinct ?work
where
{
?work cdm:resource_legal_in-force "true"^^<http://www.w3.org/2001/XMLSchema#boolean> ;
a cdm:legislation_secondary;
cdm:work_is_about_concept_eurovoc ?eurovoc .
{select ?eurovoc where
{?eurovoc skos-core:inScheme <http://eurovoc.europa.eu/100141>;
skos-core:prefLabel ?label . filter (str(?label)="cambiamento climatico") }}
}
or,
Accessing data with SPARQL
Part 4: Access and Usage
To retrieve all concepts of corporate-body list and to sort them by URI
13
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
select distinct ?concept ?label
{?concept skos:inScheme ?scheme .
values(?scheme){(<http://publications.europa.eu/resource/authority/corporate-body>)}
?concept skos:prefLabel ?label .
FILTER (lang(?label ) = 'en')}
order by ?concept
Accessing data with SPARQL
Part 4: Access and Usage
To describe ‘European Space Agency‘ concept of corporate-body NAL
14
DESCRIBE
<http://publications.europa.eu/resource/authority/corporate-body/ESA>
FROM <http://publications.europa.eu/resource/authority/corporate-body>
Accessing data with SPARQL
Part 4: Access and Usage
REST API
15
HTTPS operations to exploit WEMI objects
HTTPS operations to exploit ontologies and vocabularies
Part 4: Access and Usage
REST API: Use cases
16
Part 4: Access and Usage
REST API
Access by REST API
Retrieve the XML Tree notice
17
curl -H 'Accept:application/xml;notice=tree'
http://publications.europa.eu/resource/oj/JOL_2014_001_R_0001_01?language=eng
Part 4: Access and Usage
REST API
Access by REST API
Retrieve Content stream
18
GET http://publications.europa.eu/resource/{ps-name}/{psid}
HTTP headers must be set on the request:
curl example on the next slide
Part 4: Access and Usage
REST API
Access by REST API
Retrieve Content stream: example
19
curl --location --request GET 'http://publications.europa.eu/resource/oj/JOL_2014_001_R_0001_0' \
--header 'Accept: application/xhtml+xml' \
--header 'Accept-Language: fra'
Part 4: Access and Usage
REST API
Access by REST API
RSS and Atom feeds
20
Part 4: Access and Usage
RSS Feeds
Ingestion feed
21
− startDate: Defines the date (inclusive) since which the ingestion notifications shall be retrieved.
- endDate: Defines the date (inclusive) until which the ingestion notifications shall be retrieved
− type: A string value, either CREATE, UPDATE or DELETE. It defines the type of ingestion to be retrieved
− wemiClasses: A comma-separated list of WEMI classes: work, expression, manifestation, item, dossier, event or agent
− page: The number of the page on the feed to display. This parameter may be used to page large results.
http://publications.europa.eu/webapi/notification/ingestion ?{parameters}
5.3. Notifications (Feeds)
Part 4: Access and Usage
RSS Feeds
22
curl -X GET http://publications.europa.eu/webapi/notification/ingestion?startDate=2022-01-01&endDate=2022-01-04&type=create&wemiClasses=work&page=1 -H "Accept: application/rss+xml"
5.3. Notifications (Feeds)
Part 4: Access and Usage
RSS Feeds