Project:SPARQL/examples: Difference between revisions

m
Line 1,053: Line 1,053:


<sparql tryit="1">
<sparql tryit="1">
# a union query to fetch stuff for multiple properties, in this case dates recorded in EDTF which need slightly different handling from PIT dates


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,067: Line 1,068:
       FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }  
       FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }  
        
        
          ## short form of UNION using |   
    ## short form of UNION using |   
       ?person ( bnwdt:P131 | bnwdt:P132 | bnwdt:P133  ) ?date_edtf .
       ?person ( bnwdt:P131 | bnwdt:P132 | bnwdt:P133  ) ?date_edtf .
   
   
Line 1,073: Line 1,074:
## {?person bnwdt:P131 ?date_edtf } union {?person bnwdt:P132 ?date_edtf } union {?person bnwdt:P133 ?date_edtf }   
## {?person bnwdt:P131 ?date_edtf } union {?person bnwdt:P132 ?date_edtf } union {?person bnwdt:P133 ?date_edtf }   
      
      
        ## need to know what kind of date it is
    ## we'll need to know what kind of date it is
      ?person ?date_type ?date_edtf .
    ?person ?date_type ?date_edtf .
        
        
        ## this filter is important for edtf dates! https://github.com/ProfessionalWiki/WikibaseEdtf
    ## this filter is important for edtf dates!  
      FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
    ## https://github.com/ProfessionalWiki/WikibaseEdtf
 
    FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
              
              
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
     }
     }


579

edits