I'm trying to create a SPARQL query to construct or insert graphs, following the BIBFRAME 2.0 Model, using a personal database with a lot of datas. I want to get a result like this:
Subject a bf:Topic, madsrdf:ComplexSubject ;
rdfs:label "Subject" ;
madsrdf:componentList [ a madsrdf:Topic ;
madsrdf:authoritativeLabel "FirstSubject" ] ;
But I do not know how to do it in SPARQL. I tryed with this query, but I always get a lot of blank nodes (as much as registers with empty "?Subject" fields I have in my database):
PREFIX bf: <http://id.loc.gov/ontologies/bibframe/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix madsrdf: <http://www.loc.gov/mads/rdf/v1#>
CONSTRUCT{
?subject a bf:Topic, madsrdf:ComplexSubject ;
rdfs:label ?subject;
madsrdf:componentList [ a madsrdf:Topic ;
madsrdf:authoritativeLabel ?firstsubject ];
} where{ service <http://localhost:.......> {
?registerRow a <urn:Row> ;
OPTIONAL{?registerRow <urn:col:Subject> ?subject ;}
OPTIONAL{?registerRow <urn:col:FirstSubject> ?firstsubject ;}
}
}