GRValidator Implemented E21

Error 21

E21: Check whether eligibleRegions values are valid two-character version of ISO 3166-1 (ISO 3166-1 alpha-2) for regions or ISO 3166-2, which breaks down the countries from ISO 3166-1 into administrative subdivision and NOT use 3-letter ISO 3166-1 codes!

Validator Tool: Step # 16

Error Message

All eligibleRegions values must be valid codes of ISO 3166-1 or ISO 3166-2

Potential Problem

"AT", "DE", "US", etc. are valid ISO 3166-1 codes. "AT-7" (Tyrol), "DE-BY" (Bavaria), etc. are valid ISO 3166-2 codes.

Examples of Wrong Data

@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix toy: <http://www.heppnetz.de/ontologies/examples/toy#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<http://www.heppnetz.de/ontologies/examples/gr#Offering_1> a gr:Offering;
    gr:hasBusinessFunction gr:Sell;
    gr:validFrom "2010-11-12T00:00:00+01:00"^^xsd:dateTime;
    gr:validThrough "2010-11-12T23:59:59+01:00"^^xsd:dateTime;
        gr:eligibleRegions "AT-77"^^xsd:string.

SPARQL Query

PREFIX gr:<http://purl.org/goodrelations/v1#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geonames: <http://www.geonames.org/ontology#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?object WHERE {
  ?object gr:eligibleRegions ?value .
  FILTER (
    !bif:exists ((
      SELECT ?code FROM <http://ontologi.es/place/>
      WHERE {
       {?s a geonames:Country.} UNION {?s a geonames:Feature.}
       ?s skos:notation ?code.
       FILTER(str(?value) = str(?code))
     }
    ))
  )
}