File size: 1,087 Bytes
eed4206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
PREFIX d3f: <http://d3fend.mitre.org/ontologies/d3fend.owl#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX owl: <http://www.w3.org/2002/07/owl#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 

CONSTRUCT {
  ?s ?p ?new_o .
}
WHERE {
  ?s ?p ?o .

   # Transform rdfs:seeAlso strings that are valid QNames into URIs
  BIND(
    IF(
      ?p = rdfs:seeAlso && isLiteral(?o) && REGEX(STR(?o), "^d3f:([a-zA-Z_][a-zA-Z0-9_]*)$"),
      URI(REPLACE(STR(?o), "^d3f:", STR(d3f:))),
      ?o
    ) AS ?new_o
  )

  FILTER (?p NOT IN (
		     d3f:d3fend-data-property, 
		     d3f:d3fend-kb-data-property, 
		     d3f:d3fend-kb-object-property, 
		     d3f:d3fend-object-property,
		     d3f:todo
		     )
	  )

  FILTER (
	  !isLiteral(?new_o) || (isLiteral(?new_o) && STRLEN(STR(?new_o)) > 0)
	  )

  FILTER (
	  !(?p = rdfs:seeAlso && isLiteral(?new_o) && !REGEX(STR(?new_o), "^d3f:([a-zA-Z_][a-zA-Z0-9_]*)$"))
	  )

}