DS Specifications
Domain SpecificationsListsVocabularies
main
main
  • DS Specifications Overview
  • Domain Specifications
    • DS-V7
      • DS-V7 - Changelog
      • DS-V7 - Developer Notes
      • DS-V7 - Grammar
        • Domain Specification
          • @Context
          • Domain Specification Node
          • Property Node
          • Class Node
          • DataType Node
          • Enumeration Node
        • Verification Report
          • Verification Report Node
          • Error Entry Node
          • Error List for the domain-specific verification
        • DS-Path
      • DS-V7 - Examples
    • DS-V6
    • DS-V5
      • DS-V5 - Grammar
        • VerificationReport
          • Error List for the basic verification
          • Verification of schema.org annotations
          • Error List for the Meta verification of DS (unfinished)
          • Error List for the DS-based verification
        • Grammar and semantics of Domain Specifications
          • Enumeration Node
          • Property Node
          • Domain Specification Node
          • Class Node
          • Terms used in Domain Specifications
          • @Context
          • DataType Node
      • DS-V5 - Examples
    • DS-V4
    • DS-V3
      • DS-V3 - Examples
      • DS-V3 - Grammar
        • VerificationReport
          • Error List for the basic verification
          • Verification of schema.org annotations
          • Error List for the DS-based verification
          • Error List for the Meta verification of DS
        • Grammar and semantics of Domain Specifications
          • SDO Enumeration
          • SDO Property
          • Domain Specification
          • SDO Class
          • SDO Datatype
          • @Context
    • DS-V2
      • DS-V2 - Grammar
        • Grammar and semantics of Domain Specifications
          • Grammar Documentation for node type "RestrictedEnumeration"
          • Grammar Documentation for node type "CustomEnumerationValue"
          • Grammar Documentation for node type "Enumeration"
          • Grammar Documentation for node type "Property"
          • Grammar Documentation for node type "RestrictedProperty"
          • Grammar Documentation for node type "DomainSpecification"
          • Grammar Documentation for node type "RestrictedClass"
          • Grammar Documentation for node type "EnumerationValue"
          • Grammar Documentation for node type "Class"
          • Grammar Documentation for node type "DataType"
        • Numeric Pattern
        • Grammar Documentation for node type "VerificationReport"
          • Grammar Documentation for node type "Error"
          • Error codes for Verification Reports
        • Rules Grammar
          • Grammar Documentation for node type "ComplexRule"
          • Grammar Documentation for node type "DateRule"
          • Grammar Documentation for node type "TextRule"
          • Grammar Documentation for node type "TimeRule"
          • Grammar Documentation for node type "NumberRule"
          • Grammar Documentation for node type "BooleanRule"
          • Grammar Documentation for node type "DateTimeRule"
      • DS-V2 - Examples
    • DS-V1
      • DS-V1 - Examples
      • DS-V1 - Grammar
  • SDO-Verification
  • Lists
    • List-V1
  • Vocabularies
  • DS-Vocabulary
    • Input
      • Vocabulary for Domain Specifications
      • DS-Vocabulary
    • DS-Vocab-V1
Powered by GitBook
On this page
  • JSON Syntax of DS-V1
  • SHACL JSON-LD Syntax of DS-V3
  • Target Annotation structure (JSON-LD)
  • Expected Annotation structure (JSON-LD)
  1. Domain Specifications
  2. DS-V3
  3. DS-V3 - Grammar
  4. Grammar and semantics of Domain Specifications

SDO Enumeration

JSON Syntax of DS-V1

A dsv:RestrictedEnumeration node appears as value for the dsv:expectedType property of a dsv:Property node. The enumeration consists of the dsv:RestrictedEnumeration object that specifies the enumeration class, and the valid enumeration members that are listed in the array of dsv:expectedEnumerationValue.

{
  "@type": "dsv:Property",
  "dsv:baseProperty": {
    "@id": "schema:dayOfWeek"
  },
  "dsv:expectedType": [
    {
      "@type": "dsv:RestrictedEnumeration",
      "dsv:baseEnumeration": {
        "@id": "schema:DayOfWeek"
      },
      "dsv:expectedEnumerationValue": [
        {
          "@type": "dsv:EnumerationValue",
          "@id": "schema:Sunday"
        },
        {
          "@type": "dsv:EnumerationValue",
          "@id": "schema:Thursday"
        }
      ]
    }
  ]
}

SHACL JSON-LD Syntax of DS-V3

sh:class is used to specify the expected enumeration type (e.g. schema:DayOfWeek). Note that since a normal type also uses sh:class, the software interpreting the DS must be able to differentiate types from enumerations. sh:in CAN be used to specify the set of allowed enumeration members for that enumeration type (e.g. schema:Sunday, schema:Monday, etc.). If sh:in it not given, then any enumeration member of the target enumeration type is allowed (see second example). If the enumeration has no enumeration members (happens in Schema.org ...) the enumeration value is valid, as long as it is a URI.

Example uses @context of context.md

{
  "@type": "sh:PropertyShape",
  "sh:path": "schema:dayOfWeek",
  "sh:class": "schema:DayOfWeek",
  "sh:in": {
    "@list": [
      "schema:Sunday",
      "schema:Thursday"
    ]
  }
}
{
  "@type": "sh:PropertyShape",
  "sh:path": "schema:dayOfWeek",
  "sh:class": "schema:DayOfWeek"
}

Target Annotation structure (JSON-LD)

This is a Schema.org annotation that is valid for the previous enumeration constraint. This example uses a "correct and complete" JSON-LD syntax.

{
  "@context": {
    "@vocab": "http://schema.org/"
  },
  "@type": "OpeningHoursSpecification",
  "dayOfWeek": {
    "@id": "http://schema.org/Thursday",
    "@type": "http://schema.org/DayOfWeek"
  }
}

Expected Annotation structure (JSON-LD)

This annotation shows a simplified syntax (how it is used in the wild) for the previous example Schema.org annotation. This syntax is usually not enough to be processed by a SHACL validator for the previous enumeration constraint example, however our validation tool should be able to interpret/validate it.

{
  "@context": "http://schema.org/",
  "@type": "OpeningHoursSpecification",
  "dayOfWeek": "http://schema.org/Thursday"
}
PreviousGrammar and semantics of Domain SpecificationsNextSDO Property

Last updated 4 years ago