engSamling av SPARQL spørringer - Utdanningsdirektoratet/Grep_SPARQL GitHub Wiki

Collection of SPARQL queries

Examples of SPARQL queries that can be tested from

For prefixes in the queries, see eng:Prefikser.

Exploratory SPARQL Queries

List types (the rdf way with prefix)

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
SELECT DISTINCT ?type
WHERE { 
?s rdf:type ?type 
}

or

SELECT DISTINCT ?type
WHERE { 
?s rdf:type ?type 
}

or

SELECT DISTINCT ?type { ?s a ?type }

LList types in the Grip way (with grep-types)

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT DISTINCT ?type
WHERE {
?s u:grep-type ?type
}

List all properties

SELECT DISTINCT ?property
WHERE {
  ?s ?property ?o .
}

More useful: Which properties are used by a particular type

SELECT DISTINCT ?property
WHERE {
  ?s a <http://psi.udir.no/ontologi/kl06/laereplan>;
     ?property ?o .
}

List what's inside a given item (url-data)

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?p ?o WHERE {
?psi u:url-data <https://data.udir.no/kl06/v201906/laereplaner/NOR1-05> ;
     ?p ?o
}

Statistics

Number of triples

SELECT (COUNT(*) AS ?triples) { ?s ?p ?o  }

Number of entities

SELECT (COUNT(distinct ?s) AS ?entities) { ?s a [] }

Number of types (classes)

SELECT (COUNT(distinct ?o) AS ?types) { ?s rdf:type ?o }

Number of distinct predicates

SELECT (COUNT(distinct ?p) AS ?predicates) { ?s ?p ?o }

Number of distinct subject nodes

SELECT (COUNT(DISTINCT ?s ) AS ?nodes) { ?s ?p ?o }

Number of distinct object nodes

SELECT (COUNT(DISTINCT ?o ) AS ?nodes) { ?s ?p ?o filter(!isLiteral(?o)) }

Queries to the content

What is hidden behind a UUID reference?

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?code ?psi ?title ?type WHERE {
?psi u:id "uuid:01b784dd-aebc-46ec-9dfd-a0ad38fe8225" ;
u:tittel ?title ;
u:url-data ?code ;
rdf:type ?type ;
u:id ?uuid
FILTER (lang(?title) = "default")
} ORDER BY str(?code)

List all of the laereplan (curriculum) type in the default language

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT  ?title ?code WHERE {
?uri rdf:type u:laereplan ;
u:tittel ?title ;
u:url-data ?code .
FILTER (lang(?title) = "default")
} ORDER BY ?code ?title

Same as above, but filtered on the published-status

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT  ?title ?code WHERE {
?uri rdf:type u:laereplan ;
u:tittel ?title ;
u:status ?status ;
u:url-data ?code .
    FILTER REGEX(str(?status), "publisert", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?code ?title

All published læreplaner (curricula) for primary school in the default language

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?title ?code WHERE {
?curr rdf:type u:laereplan ;
u:tittel ?title ;
u:url-data ?code ;
u:opplaeringsnivaa ?level ;
u:status ?status .
FILTER regex(str(?status), "publisert", "i")
FILTER regex(str(?level), "grunnskole", "i") # grunnskole = primary school
FILTER (lang(?title) = "default")
} ORDER BY ?title ?code

Published "curricula" without replacement-relationship using negation

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?title ?code WHERE {
?curr rdf:type u:laereplan ;
u:uri ?uri;
u:tittel ?title ;
u:url-data ?code ;
u:status ?status .
MINUS { ?curr u:har-erstatter ?replaces. } # har-erstatter = has-replaces
FILTER regex(str(?status), "publisert", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?code

English translation of the specified "tittel" ("title")

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT *
 WHERE { ?x u:tittel  "Læreplan i norsk"@nob ;
            u:tittel  ?title .
         FILTER langMatches(lang(?title), "eng" )
}

Text search in mutiple text fields in curricula

PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode:<http://psi.udir.no/kl06/>
SELECT DISTINCT ?searchText ?data ?type ?currTitle WHERE {
{
?compAim rdf:type u:kompetansemaal ;
u:tittel ?searchText ;
u:kode ?code ;
u:url-data ?data ;
u:grep-type ?type ;
u:tilhoerer-laereplan ?curr ;
u:tilhoerer-kompetansemaalsett ?compAimSet .
?curr u:tittel ?currTitle .
FILTER (lang(?currTitle) = "default")
FILTER (lang(?searchText) = "default")
}
UNION
{
?curr rdf:type u:laereplan .
?curr u:tittel ?searchText ;
u:tittel ?currTitle ;
u:kode ?code ;
u:url-data ?data ;
u:status ?status ;
u:grep-type ?type .
FILTER regex(str(?status), "publisert", "i")
FILTER (lang(?currTitle) = "default")
FILTER (lang(?searchText) = "default")
}
UNION
{?curr rdf:type u:laereplan .
?curr u:formaal ?searchText ;
u:kode ?code ;
u:tittel ?currTitle ;
u:url-data ?data ;
u:grep-type ?type ;
u:status ?status .
FILTER regex(str(?status), "publisert", "i")
FILTER (lang(?currTitle) = "default")
FILTER (lang(?searchText) = "default")
}
FILTER regex(?searchText, "i forhold til", "i")
} ORDER BY ?type ?data

Text search in "kompetansemaal" (competence aims) to find a curriculum

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT DISTINCT ?compCode ?compTxt ?currTitle ?curr WHERE {
?compAim rdf:type u:kompetansemaal ;
    u:tittel ?compTxt ;
    u:kode ?compCode ;
    u:tilhoerer-kompetansemaalsett ?compAimSet .
?compAimSet u:etter-fag ?teachingSubject .
?teachingSubject u:laereplan-referanse ?curr .
?curr u:tittel ?currTitle .
    FILTER regex(?compTxt, "i forhold til", "i")
    FILTER (lang(?compTxt) = "default")
    FILTER (lang(?currTitle) = "default")
 } ORDER BY ?curr ?compCode

Competence aims that are linked to several given basic skills, listed in line 9 (LK20)

PREFIX d: <http://psi.udir.no/kl06/>
PREFIX u: <http://psi.udir.no/ontologi/kl06/>
select distinct ?curr ?currTitle ?compAimSetKode ?compAimSetTitle ?CompAim ?title  where { 
?CompAim a u:kompetansemaal_lk20 ;
    u:kode ?CompAim ;
    u:tittel ?title ;
    u:tilhoerer-kompetansemaalsett ?compAimSet ;
    u:tilhoerer-laereplan ?curr ;
    u:tilknyttede-grunnleggende-ferdigheter d:GF1, d:GF2, d:GF3, d:GF4, d:GF5 .
    FILTER (lang(?title) = "default")

#    MINUS { ?CompAim u:tilknyttede-grunnleggende-ferdigheter [] . }
?curr u:tittel ?currTitle ;
    u:kode ?currCode .
    FILTER (lang(?currTitle) = "default")
?compAimSet u:tittel ?compAimSetTitle ;
     u:kode ?compAimSetKode . 
    FILTER (lang(?compAimSetTitle) = "default")

} ORDER BY ?curr ?compAimSet ?CompAim

List curricula (LK06) established by the Ministry of Education and Research

prefix u: <http://psi.udir.no/ontologi/kl06/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
?uri a u:laereplan ;
u:tittel ?title ;
u:kode ?code ;
u:fastsettelsestekst ?etablishedBy .
    FILTER regex(?etablishedBy, "av K", "i")
    FILTER (lang(?title) = "default")
    FILTER (lang(?etablishedBy) = "default")
}

Number of published curricula

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT (count (?countingObject) as ?antall) WHERE {
?countingObject rdf:type u:laereplan ;
u:status ?status .
FILTER regex(str(?status), "publisert","i")
}

Number of curricula in a given language

prefix u: <http://psi.udir.no/ontologi/kl06/>
select (count (?countingObject) as ?antall) where {
?countingObject rdf:type
u:laereplan;
u:tittel ?title ;
u:status ?status .
FILTER regex(str(?status), "publisert","i")
FILTER (lang(?title) = "nob")
}

Which subjects have the tag "deviation subjects"?

prefix u: <http://psi.udir.no/ontologi/kl06/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?title ?code WHERE {
?subjectCode rdf:type u:fagkode ;
u:tittel ?title ;
u:url-data ?code ;
u:merkelapper ?tag .
FILTER regex(str(?tag), "avvik", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?code

Which subjects have the tag "optional subjects"?

prefix u: <http://psi.udir.no/ontologi/kl06/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?title ?code ?curr WHERE {
?curr rdf:type u:laereplan ;
u:tittel ?title ;
u:kode ?code ;
u:merkelapper ?tag .
FILTER regex(str(?tag), "valg", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?title ?code

List of subject codes that have tags

prefix u: <http://psi.udir.no/ontologi/kl06/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {
?subjectCode rdf:type u:fagkode ;
u:tittel ?title ;
u:url-data ?code ;
u:merkelapper ?tag .
FILTER (lang(?title) = "default")
} ORDER BY ?tag ?code

List of published curricula (LK06) that have a tag

prefix u: <http://psi.udir.no/ontologi/kl06/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?title ?code ?tagTittle WHERE {
?curr rdf:type u:laereplan ;
u:tittel ?title ;
u:url-data ?code ;
u:status ?status ;
u:merkelapper ?tag .
FILTER regex(str(?status), "publisert")
FILTER (lang(?title) = "default")
?tag u:tittel ?tagTittle .
FILTER (lang(?tagTittle) = "default")
} ORDER BY ?curr ?tag ?code

Given a subject code, give me the current curriculum (LK06)

PREFIX d: <http://psi.udir.no/kl06/>
PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?subjectCodetittel ?zCode ?zTitle ?curr ?currTitle  WHERE {
d:NOR0214 u:tittel ?subjectCodetittel ;
u:opplaeringsfag ?zCode
FILTER (lang(?subjectCodetittel) = 'default') .
 
?compAimSet u:etter-fag ?zCode ;
    u:tittel ?zTitle ;
    u:status ?zstatus .
    FILTER (lang(?zTitle) = "default")
    FILTER regex(str(?zstatus), "publisert")
 
?zCode u:laereplan-referanse ?curr ;
    u:tittel ?currTitle ;
    u:url-data ?currLink ;
    u:status ?currStatus .
    FILTER (lang(?currTitle) = "default")
    FILTER regex(str(?currStatus), "publisert")
}

Given a subject code, give me the current curriculum (both LK06 and LK20)

PREFIX d: <http://psi.udir.no/kl06/>
PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?subjectCodetittel ?zCode ?zTitle ?curr ?currLink ?currType WHERE {

d:NOR1231 u:tittel ?subjectCodetittel ;
    u:opplaeringsfag ?zCode .
FILTER (lang(?subjectCodetittel) = 'default')

?zCode u:laereplan-referanse ?curr ;
    u:tittel ?zTitle ;
    u:status ?currStatus .
    FILTER (lang(?zTitle) = 'default')
    FILTER regex(str(?currStatus), "publisert")

?curr u:url-data ?currLink ;
#    a ?currType . (just a variation of the line below (same as rdf:type))
    u:grep-type ?currType .
#    a u:laereplan_lk20 . (if you want to filter on LK20 curricula, evt "a u:laereplan" if only LK06)
}

List of 'aarstrinn' (year level)

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?url ?title WHERE {
?url rdf:type u:aarstrinn;
u:tittel ?title
FILTER (lang(?title) = "default")
}

List 'aarstrinn' (year level), ordered by the order statement

prefix u: <http://psi.udir.no/ontologi/kl06/>
SELECT ?url ?title WHERE {
?url rdf:type u:aarstrinn;
u:rekkefoelge ?order;
u:tittel ?title
FILTER (lang(?title) = "default")
} ORDER BY ?order

Given a subject code, list the current 'opplæringsfag' (teaching subject)

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
 
SELECT ?subjectCode ?subjectCodetittel ?zCode ?teachingSubject WHERE {
kode:NOR0214 u:tittel ?subjectCodetittel ;
u:uri ?subjectCode ;
u:tittel ?subjectCodetittel .
    FILTER (lang(?subjectCodetittel) = "default")
     
?subjectCode u:opplaeringsfag ?zCode ;
u:status ?zstatus ;
u:tittel ?teachingSubject.
    FILTER (lang(?teachingSubject) = "default")
    FILTER regex(str(?zstatus), "publisert")
}

From teaching subjects to year levels via competence-aim-set v.1

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
SELECT DISTINCT ?teachingSubject ?compAimSetTitle ?compAimSet ?teachingSubjectTitle ?yearLevel WHERE {
<http://psi.udir.no/kl06/NOR1Z37> ?p ?o ;
u:tittel ?teachingSubjectTitle ;
u:kode ?teachingSubject ;
u:tilhoerende-kompetansemaalsett ?compAimSet .
    FILTER (lang(?teachingSubjectTitle) = 'default')
?compAimSet u:etter-aarstrinn ?yearLevel ;
u:tittel ?compAimSetTitle .
FILTER (lang(?compAimSetTitle) = 'default') .
}

From teaching subjects to year levels via competence-aim-set v.2

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
SELECT DISTINCT ?compAimSet ?yearLevel WHERE {
kode:NOR1Z37 ?p ?o ;
u:tilhoerende-kompetansemaalsett ?compAimSet .
?compAimSet u:etter-aarstrinn ?yearLevel .
}

List competence aims for a given curriculum (ordered by year level and competence-aim-set (LK06)

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?currCode ?currTitle ?yearLevel ?compAimSet ?CompAim ?kmtittel
WHERE {
# ?CompAim u:laereplan-referanser ?curr ;
?CompAim u:tilhoerer-laereplan ?curr ;
    u:tittel ?kmtittel ;
#   u:tilhoerende-kompetansemaalsett ?compAimSet .
    u:tilhoerer-kompetansemaalsett ?compAimSet .
    FILTER (lang(?kmtittel) = "default")
    FILTER regex(str(?lp), "NOR1-05", "i")
?curr u:tittel ?currTitle ;
    u:kode ?currCode
    FILTER (lang(?currTitle) = "default")
?compAimSet u:etter-aarstrinn ?yearLevel .
    ?yearLevel u:rekkefoelge ?yearLevelOrder
} ORDER BY ?yearLevelOrder ?compAimSet ?CompAim

What year level does the curriculum apply to?

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
PREFIX d: <http://data.udir.no/ontologi/kl06>
 
SELECT DISTINCT ?currTitle ?yearLevel 
WHERE {
kode:SAS1-04 u:uri ?curr ;
u:tittel ?currTitle ;
u:kompetansemaalsett ?compAimSet .
FILTER (lang(?currTitle) = 'default')
 
?compAimSet u:etter-aarstrinn ?yearLevel ;
u:kompetansemaal ?CompAim .
?yearLevel u:rekkefoelge ?yearLevelOrder ;
u:tittel ?yearLevel .
FILTER (lang(?yearLevel) = 'default')
 
?CompAim u:tittel ?kmtittel .
FILTER (lang(?kmtittel) = 'default')
 
# ?CompAim u:tilhoerende-kompetansemaalsett ?compAimSet .
?CompAim u:tilhoerer-kompetansemaalsett ?compAimSet .
 
}
ORDER BY ?yearLevelOrder ?compAimSet ?CompAim

From competence aim to curriculum

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
 
SELECT ?compCode ?compAim ?compAimSetTitle ?curr ?currCode
WHERE {
 
kode:K15426 u:tittel ?compAim ;
u:kode ?compCode ;
# u:laereplan-referanser ?curr ;
u:tilhoerer-laereplan ?curr ;
# u:tilhoerende-kompetansemaalsett ?compAimSet .
u:tilhoerer-kompetansemaalsett ?compAimSet .
 
?compAimSet u:tittel ?compAimSetTitle .
FILTER (lang(?compAim) = 'default')
FILTER (lang(?compAimSetTitle) = 'default')
 
?curr u:tittel ?curr ;
u:kode ?currCode .
FILTER (lang(?curr) = 'default')
}

From competence aim to year level

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
 
SELECT ?title ?yearLevel WHERE {
kode:K1 u:tittel ?title ;
# u:tilhoerende-kompetansemaalsett ?compAimSet .
u:tilhoerer-kompetansemaalsett ?compAimSet .
FILTER (lang(?title) = 'default')
 
?compAimSet u:benyttes-paa-aarstrinn ?yLevel.
 
?yLevel u:tittel ?yearLevel .
FILTER (lang(?yearLevel) = 'default')
}

From subject area to curriculum

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
PREFIX d: <http://psi.udir.no/kl06/>
 
SELECT DISTINCT ?curr ?title ?status
WHERE {
?teachSubj rdf:type u:opplaeringsfag;
    u:fagomraade-referanser d:FOMR404 ;
    u:laereplan-referanse ?curr .
?curr u:tittel ?title ;
    u:grep-type ?type ;
    u:status ?status
    FILTER (lang(?title) = "default")

} ORDER BY ?type ?lp

In which subjects (subject codes) is teaching given in the first semester of 2018?

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
 
SELECT ?title ?code WHERE {
?subjectCode rdf:type u:fagkode ;
u:tittel ?title ;
u:url-data ?code ;
u:naar-gis-det-undervisning-foerste-semester ?firstSemester .
FILTER regex(str(?firstSemester), "semester_hoest_2018", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?code

In which programme areas is teaching given in the first semester of 2017?

prefix u: <http://psi.udir.no/ontologi/kl06/>
 
SELECT ?title ?code WHERE {
?subjectCode rdf:type u:programomraade ;
u:tittel ?title ;
u:url-data ?code ;
u:foerste-semester ?firstSemester .
FILTER regex(str(?firstSemester), "2017", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?code

In which education programmes is teaching given in the first semester of 2016?

prefix u: <http://psi.udir.no/ontologi/kl06/>
 
SELECT ?title ?code WHERE {
?uri rdf:type u:utdanningsprogram ;
u:tittel ?title ;
u:url-data ?code ;
u:foerste-semester ?firstSemester .
FILTER (lang(?title) = "default")
FILTER regex(str(?firstSemester), "2016", "i")
} ORDER BY ?code

List education programmes, subject type, final qualifications and professional title

prefix u: <http://psi.udir.no/ontologi/kl06/>
 
SELECT DISTINCT ?edProg ?pa ?paTitle ?curr ?subjType ?finalQualification ?occupationalTitle WHERE {
?teachingSubject rdf:type u:opplaeringsfag ;
u:status ?ofstatus ;
u:tittel ?teachingSubjectTitle ;
u:programomraader-referanse ?pa ;
u:fagtype ?subjType ;
u:status ?paStatus ;
u:laereplan-referanse ?curr .
# r:etter-fag ?compAimSet .
 
?pa u:tittel ?paTitle .
 
# ?compAimSet r:har-kompetansemaalsett ?curr .
FILTER regex(str(?subjType), "program", "i")
 
?pa u:utdanningsprogram-referanse ?edProg ;
u:sluttkompetanse ?finalQualification ;
u:yrkestittel ?occupationalTitle ;
u:status ?edProgStatus .
 
FILTER regex(str(?paStatus), "publisert", "i")
FILTER (lang(?teachingSubjectTitle) = "default")
FILTER (lang(?paTitle) = "default")
FILTER (lang(?occupationalTitle) = "default")
}
ORDER BY ?edProg ?pa ?curr ?paStatus

List of curricula for vocational subjects ("yrkesfag") only (i.e. without common core subjects ("fellesfag"))

prefix u: <http://psi.udir.no/ontologi/kl06/>
 
SELECT DISTINCT ?code ?title ?edProg ?pa WHERE {
?teachingSubject rdf:type u:opplaeringsfag ;
u:fagtype ?subjType ;
u:programomraader-referanse ?pa ;
u:status ?teachSubjStatus .
FILTER regex(str(?teachSubjStatus), "publisert", "i")
FILTER regex(str(?subjType), "program", "i")
?pa u:utdanningsprogram-referanse ?edProg .
?edProg u:type-utdanningsprogram ?edProgType .
FILTER regex(str(?edProgType), "yrke", "i")
?teachingSubject u:tilhoerende-kompetansemaalsett ?set ;
u:laereplan-referanse ?curr .
#   u:tilhoerer-laereplan ?curr .     | Candidate to replace the line above, if we want harmonization of Curr references in other types (eg equivalent in CompAimSet)
# ?set r:har-kompetansemaalsett ?curr .
?curr u:kode ?code ;
u:status ?status ;
u:tittel ?title .
FILTER regex(str(?status), "publisert", "i")
FILTER (lang(?title) = "default")
} ORDER BY ?edProg ?pa ?code ?title

List of curricula available in both Bokmål (@nob) and Nynorsk (@nno) with UNION (LK06 and LK20)

prefix u: <http://psi.udir.no/ontologi/kl06/>
 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT  ?code ?nobTitle ?nnoTitle ?establishedLanguage WHERE {
{?uri rdf:type u:laereplan_lk20 ;
u:tittel ?nobTitle ;
u:tittel ?nnoTitle ;
u:fastsatt-spraak ?establishedLanguage ;
u:url-data ?code .
FILTER (lang(?nobTitle) = "nob")
FILTER (lang(?nnoTitle) = "nno")
}
    UNION
{?uri rdf:type u:laereplan ;
u:tittel ?nobTitle ;
u:tittel ?nnoTitle ;
u:fastsatt-spraak ?establishedLanguage ;
u:url-data ?code .
FILTER (lang(?nobTitle) = "nob")
FILTER (lang(?nnoTitle) = "nno")
}
}ORDER BY ?establishedLanguage ?code

List of curricula available in both Bokmål (@nob) and Nynorsk (@nno) without UNION (LK06 and LK20)

PREFIX u: <http://psi.udir.no/ontologi/kl06/>

SELECT DISTINCT ?code ?nobTitle ?nnoTitle ?establishedLanguage ?type WHERE {
    ?teachSubj rdf:type u:opplaeringsfag;
        u:laereplan-referanse ?curr .
    ?curr u:tittel ?nobTitle ;
        u:tittel ?nnoTitle ;
	u:fastsatt-spraak ?establishedLanguage ;
	u:url-data ?code ;
    	u:grep-type ?type .
FILTER (lang(?nobTitle) = "nob")
FILTER (lang(?nnoTitle) = "nno")
} ORDER BY ?establishedLanguage ?code

Number of competence aims per published curriculum

prefix u: <http://psi.udir.no/ontologi/kl06/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# SELECT ?currkode ?currTitle ?compAimSetTitle (COUNT (distinct ?CompAim) as ?numberOfCompAim) WHERE {
# SELECT DISTINCT ?currkode ?currTitle ?compAimSetTitle (COUNT (?CompAim) as ?numberOfCompAim) WHERE {
SELECT (COUNT(distinct ?CompAim) as ?numberOfCompAim) WHERE {
?uri rdf:type u:laereplan ;
    u:tittel ?currTitle ;
    u:kode ?currkode ;
    u:kompetansemaalsett ?compAimSet ;
    u:status ?currStatus ;
    u:url-data ?currCode .
FILTER regex(str(?currStatus), "publisert","i")
FILTER (lang(?currTitle) = "default")
 
?compAimSet u:kompetansemaal ?CompAim ;
u:tittel ?compAimSetTitle .
FILTER (lang(?compAimSetTitle) = "default")
 
}
# ORDER BY ?currkode ?compAimSet
# ORDER BY DESC(?numberOfCompAim)
 
# Trouble: GraphDB does not allow anything between "SELECT" and "(COUNT ..."

SPARQL queries that correspond to the so-called special queries in REST

Retrieves all programme areas for a subject

PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode:<http://psi.udir.no/kl06/>
 
SELECT ?status ?code ?uri ?urlData ?title WHERE {
 
?subjectCode a u:fagkode ;
u:opplaeringsfag ?viaTeachSubj .
FILTER regex(str(?subjectCode), "AMB2002", "i")
 
?viaTeachSubj u:programomraader-referanse ?uri .
?uri u:tittel ?title ;
u:status ?status ;
u:kode ?code ;
u:url-data ?urlData .
FILTER (lang(?title) = "default")
}

Retrieves all programme areas for a given teaching subject

PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode:<http://psi.udir.no/kl06/>
SELECT ?teachingSubject ?teachingSubjectTitle ?programmeAreas ?programmeAreaTitle WHERE {
?teachingSubject ?p kode:AMB2Z02 .
?teachingSubject u:tittel ?teachingSubjectTitle ;
u:programomraader-referanse ?programmeAreas ;
u:tittel ?programmeAreaTitle .
FILTER (lang(?teachingSubjectTitle) = "default")
FILTER (lang(?programmeAreaTitle) = "default")
}

Retrieves all curricula for a programme area

PREFIX u: <http://psi.udir.no/ontologi/kl06/>
 
SELECT DISTINCT ?curr ?title WHERE {
?curr rdf:type u:laereplan ;
u:tittel ?title ;
u:kode ?currCode ;
u:kompetansemaalsett ?compAimSet.
?compAimSet u:etter-fag ?teachingSubject .
?teachingSubject u:programomraader-referanse ?programmeArea .
?programmeArea u:kode ?programmeAreaCode ;
u:tittel ?opplfag_tittel .
FILTER regex(?programmeAreaCode, "DHTRB3----")
FILTER (lang(?title) = "default")
} ORDER BY  ?curr

Retrieves all training subjects for a given programme area with specification of subject type

PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode:<http://psi.udir.no/kl06/>
SELECT DISTINCT ?teachSubj ?title WHERE {
 ?teachSubj  ?o kode:DHTRB3---- .
 ?teachSubj u:grep-type u:opplaeringsfag ;
     u:tittel ?title ;
     ?b ?subjType .
    FILTER (lang(?title) = "default")
    FILTER REGEX(str(?subjType), "felles_programfag")
?subjType u:tittel ?subjTypetittel
    FILTER (lang(?subjTypetittel) = "default")
}

Retrieve all teaching subjects for subjects with specification of subject type

PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode:<http://psi.udir.no/kl06/>
SELECT DISTINCT ?teachingSubject ?title WHERE {
?subjectCode u:uri kode:AMB2002 ;
u:opplaeringsfag ?teachingSubject ;
u:fagtype ?subjType .
?teachingSubject u:tittel ?title .
FILTER regex(str(?subjType), "fagtype_felles_programfag")
FILTER (lang(?title) = "default")
}

Retrieve all subject codes for programme area with specification of subject type

PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode:<http://psi.udir.no/kl06/>
 
SELECT DISTINCT ?subjectCode ?title WHERE {
?subjectCode rdf:type u:fagkode ;
u:tittel ?title  ;
u:fagtype kode:fagtype_fellesfag ;
u:opplaeringsfag ?teachingSubject.
FILTER (lang(?title) = "default")
?teachingSubject u:programomraader-referanse ?programmeArea .
 
?programmeArea u:kode ?programomraadekode .
FILTER regex(str(?programomraadekode), "BABAT1----")
}
ORDER BY ?subjectCode

Find differences in competence aims for curricula A and B

prefix u: <http://psi.udir.no/ontologi/kl06/>
prefix d: <http://psi.udir.no/kl06/>
 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?currTitle ?currA ?currB ?code ?compTxt ?compAimSet WHERE {
 
{
  ?compAim rdf:type u:kompetansemaal ;
  u:tittel ?compTxt ;
  u:kode ?code ; u:url-data ?data ;
  u:grep-type ?type ;
  u:laereplan-referanser ?currA ;
  u:tilhoerende-kompetansemaalsett ?compAimSet .
 
  ?compAimSet u:tittel ?compAimSet .
  FILTER (lang(?compAimSet) = "default")
 
#  ?compAimSet r:kompetansemaalsett ?currA .
  ?currA u:uri d:NOR1-04 ;
  u:tittel ?currTitle .
  FILTER (lang(?currTitle) = "default")
  FILTER (lang(?compTxt) = "default")
}
UNION
{
  ?compAim rdf:type u:kompetansemaal ;
  u:tittel ?compTxt ;
  u:kode ?code ; u:url-data ?data ;
  u:grep-type ?type ;
#  u:laereplan-referanser ?currB ;
  u:tilhoerer-laereplan ?currB ;
#  u:tilhoerende-kompetansemaalsett ?compAimSet .
  u:tilhoerende-kompetansemaalsett ?compAimSet .
 
  ?compAimSet u:tittel ?compAimSet .
  FILTER (lang(?compAimSet) = "default")
 
  ?compAimSet r:kompetansemaalsett ?currB .
  ?currB u:uri d:NOR1-05 ;
  u:tittel ?currTitle .
  FILTER (lang(?currTitle) = "default")
  FILTER (lang(?compTxt) = "default")
}
}
ORDER BY ?compTxt ?compAimSet ?currA ?currB

# endringer: fjernet linje 17, erst med linje 11
# og fjernet linje 36, ertattet med linje 30
# fordi vi ikke har KMS -> LP-referanse
# Edit 2021-05-20: NB: LP-referanse for KMS er på vei

As above, but compares an LK06 curriculum with an LK20 curriculum

prefix u: <http://psi.udir.no/ontologi/kl06/>
prefix d: <http://psi.udir.no/kl06/>
  
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?currTitle ?currA ?currB ?code ?compTxt ?compAimSet WHERE {
  
{
  ?compAim rdf:type u:kompetansemaal ;
  u:tittel ?compTxt ;
  u:kode ?code ; u:url-data ?data ;
  u:grep-type ?type ;
  u:tilhoerer-laereplan ?currA ;
  u:tilhoerer-kompetansemaalsett ?compAimSet .
  
  ?compAimSet u:tittel ?compAimSet .
  FILTER (lang(?compAimSet) = "default")
  
  ?currA u:uri d:NOR1-05 ;
  u:tittel ?currTitle .
  FILTER (lang(?currTitle) = "default")
  FILTER (lang(?compTxt) = "default")
}
UNION
{
  ?compAim rdf:type u:kompetansemaal_lk20 ;
  u:tittel ?compTxt ;
  u:kode ?code ; u:url-data ?data ;
  u:grep-type ?type ;
  u:tilhoerer-laereplan ?currB ;
  u:tilhoerer-kompetansemaalsett ?compAimSet .
  
  ?compAimSet u:tittel ?compAimSet .
  FILTER (lang(?compAimSet) = "default")
  
#  ?compAimSet r:kompetansemaalsett ?currB .
  ?currB u:uri d:NOR01-06 ;
  u:tittel ?currTitle .
  FILTER (lang(?currTitle) = "default")
  FILTER (lang(?compTxt) = "default")
}
}
ORDER BY ?compTxt ?compAimSet ?currA ?currB

List of last published changes

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX u:<http://psi.udir.no/ontologi/kl06/>
PREFIX kode: <http://psi.udir.no/kl06/>
 
SELECT DISTINCT *
WHERE {
 
?uri u:kode ?code ;
     u:sist-endret ?uriLastChanged ;
     u:url-data ?data .
}
 ORDER BY DESC(?uriLastChanged)
# ORDER BY ?dataLastChanged
 
LIMIT 100