Skip to content

Instantly share code, notes, and snippets.

@gkellogg
Created November 6, 2017 19:39
Show Gist options
  • Save gkellogg/27fb0e0d0cf6dbf63078457e2a050c02 to your computer and use it in GitHub Desktop.
Save gkellogg/27fb0e0d0cf6dbf63078457e2a050c02 to your computer and use it in GitHub Desktop.
Verifiable Claims Vocabulary/Context

Updating vocabulary

Vocabulary definitions are managed in vocab.csv. Add or change entries within this file. Regenerate credentials.ttl, credentials.jsonld, and credentials.html as described below.

Building credentials.html, credentials.jsonld and credentials.ttl

All files are based on vocab.csv. Run mk_vocab.rb to build both credentials.html, credentials.jsonld and credentials.ttl

<html lang="en">
<head>
<meta charset='utf-8'/>
<title>Verifiable Claims Vocabulary</title>
<script class="remove" src="https://www.w3.org/Tools/respec/respec-w3c-common"></script>
<script src="https://opencreds.github.io/vc-common/common.js"></script>
<script class="remove">
var respecConfig = {
localBiblio: opencreds.localBiblio,
specStatus: "base",
shortName: "vc-vocab",
publishDate: "2017-11-05",
thisVersion: "http://w3id.org/credentials",
//edDraftURI: "https://w3c.github.io/vc-vocab/",
// lcEnd: "3000-01-01",
// crEnd: "3000-01-01",
editors: [{
name: "Gregg Kellogg",
url: "http://greggkellogg.net/",
company: "Spec-Ops",
companyURL: "https://spec-ops.io/",
w3cid: "44770"
}],
wg: "Verifiable Claims Working Group",
wgURI: "https://www.w3.org/2017/vc/",
wgPublicList: "public-vc-comments",
wgPatentURI: "https://www.w3.org/2004/01/pp-impl/98922/status",
alternateFormats: [
{uri: "credentials.ttl", label: "Turtle"},
{uri: "credentials.jsonld", label: "JSON-LD"}
],
//otherLinks: [{
// key: "Repository",
// data: [{
// value: "We are on GitHub",
// href: "https://github.com/shexSpec/shexspec.github.io/"
// }, {
// value: "File a bug",
// href: "https://github.com/shexSpec/shex/issues"
// }]
//}, {
// key: "Changes",
// data: [{
// // value: "Diff to previous version",
// // href: "diff-20140327.html"
// // }, {
// value: "Commit history",
// href: "https://github.com/shexSpec/shexspec.github.io/commits/master"
// }]
//}] ,
inlineCSS: true,
doRDFa: false,
noIDLIn: true,
//issueBase: "https://github.com/shexSpec/shex/issues/",
noLegacyStyle: false
};
</script>
<style type="text/css">
dl.terms dt {
float: left;
clear: left;
width: 17vw;
}
dl.terms dd:after {
content: '';
display: block;
clear: both;
margin-bottom: 5px;
}
table.rdfs-definition td {vertical-align: top;}
.bold {font-weight: bold;}
</style>
</head>
<body resource="https://w3id.org/credentials#" typeof="owl:Ontology" prefix="cred: https://w3id.org/credentials#">
<section id="abstract">
<p>This document describes the
<span property="dc:title">Verifiable Claims Vocabulary</span>
and Term definitions used
for describing Verfiable Claims [[verifiable-claims-data-model]]. This document provides the RDFS [[RDF-SCHEMA]] vocabulary definition and a description of the JSON-LD context definition for use with
defining Verfiable Claims.</p>
<p>Alternate versions of the vocabulary definition exist in
<a rel="alternate" href="credentials.ttl">Turtle</a> and
<a rel="alternate" href="credentials.jsonld">JSON-LD</a>,
which also includes the <code>@context</code> required for metadata descriptions.
<!--These versions may also be retrieved from <code>FIXME</code> using an appropiate HTTP <em>Accept</em> header.-->
</p>
<dl>
<dt>Published:</dt><dd><time property="dc:date">2017-11-05</time></dd>
<dt>Imports:</dt>
<dd><a href="http://purl.org/dc/terms/" property="owl:imports">http://purl.org/dc/terms/</a></dd>
<dd><a href="https://w3id.org/security" property="owl:imports">https://w3id.org/security</a></dd>
<dt>Version Info:</dt>
<dd><a href="" property="owl:versionInfo"></a></dd>
<dt>See Also:</dt>
<dd><a href="https://www.w3.org/TR/verifiable-claims-data-model/" property="rdfs:seeAlso">https://www.w3.org/TR/verifiable-claims-data-model/</a></dd>
</dl>
</section>
<section id="sotd">
<p>
FIXME
</p>
</section>
<section>
<h2>Introduction</h2>
<p property="dc:description">This document describes the RDFS vocabulary description used for Verifiable Claims [[verifiable-claims-data-model]] along with the default JSON-LD Context.</p>
<p>This specification makes use of the following namespaces:</p>
<dl class="terms">
<dt><code>cred</code>:</dt>
<dd><code>https://w3id.org/credentials#</code></dd>
<dt><code>dc</code>:</dt>
<dd><code>http://purl.org/dc/terms/</code></dd>
<dt><code>sec</code>:</dt>
<dd><code>https://w3id.org/security#</code></dd>
<dt><code>xsd</code>:</dt>
<dd><code>http://www.w3.org/2001/XMLSchema#</code></dd>
</dl>
</section>
<section>
<h2>Class Definitions</h2>
<p>The following are class definitions in the <code>shex</code> namespace:</p>
<table class="rdfs-definition">
<tr><td class="bold">Credential</td>
<td resource="cred:Credential" typeof="rdfs:Class">
<em property="rdfs:label">Credential</em>
<p property="rdfs:comment">FIXME</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
</td>
</tr>
</table>
</section>
<section>
<h2>Property Definitions</h2>
<p>The following are property definitions in the <code>shex</code> namespace:</p>
<table class="rdfs-definition">
<tr><td class="bold">claim</td>
<td resource="cred:claim" typeof="rdf:Property">
<em property="rdfs:label">claim</em>
<p property="rdfs:comment">A statement made about a `subject`. A **verifiable claim** is a claim that is tamper-resistant and whose authorship can be cryptographically verified.</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
<dl class="terms">
<dt>rdfs:range</dt>
<dd property="rdfs:range" resource="rdfs:Resource">rdfs:Resource</dd>
</dl>
</td>
</tr>
<tr><td class="bold">credential</td>
<td resource="cred:credential" typeof="rdf:Property">
<em property="rdfs:label">credential</em>
<p property="rdfs:comment">A set of one or more claims made by the same `entity` about a `subject`. A **verifiable credential** is a credential that is tamper-resistant and whose authorship can be cryptographically verified.</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
<dl class="terms">
<dt>rdfs:range</dt>
<dd property="rdfs:range" resource="cred:Credential">cred:Credential</dd>
</dl>
</td>
</tr>
<tr><td class="bold">issued</td>
<td resource="cred:issued" typeof="rdf:Property">
<em property="rdfs:label">issued</em>
<p property="rdfs:comment">The value of this property MUST be a string value of an [[ISO8601]] combined date and time string and represents the date and time the `credential` was issued. Note that this date represents the earliest date when the information associated with the _claim property became valid.</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
<dl class="terms">
<dt>rdfs:range</dt>
<dd property="rdfs:range" resource="xsd:dateTime">xsd:dateTime</dd>
</dl>
</td>
</tr>
<tr><td class="bold">issuer</td>
<td resource="cred:issuer" typeof="rdf:Property">
<em property="rdfs:label">issuer</em>
<p property="rdfs:comment">An `entit`y that creates a `verifiable claim`, associates it with a particular `subject`, and transmits it to a `holder`.</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
</td>
</tr>
<tr><td class="bold">recipient</td>
<td resource="cred:recipient" typeof="rdf:Property">
<em property="rdfs:label">recipient</em>
<p property="rdfs:comment">FIXME</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
</td>
</tr>
<tr><td class="bold">referenceId</td>
<td resource="cred:referenceId" typeof="rdf:Property">
<em property="rdfs:label">referenceId</em>
<p property="rdfs:comment">FIXME</p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
</td>
</tr>
</table>
</section>
<section>
<h2>Term Definitions</h2>
<dl class="terms">
<dt>Credential</dt>
<dd>
cred:Credential
</dd>
<dt>CryptographicKey</dt>
<dd>
sec:Key
</dd>
<dt>GraphSignature2012</dt>
<dd>
sec:GraphSignature2012
</dd>
<dt>Identity</dt>
<dd>
https://w3id.org/identity#Identity
</dd>
<dt>LinkedDataSignature2015</dt>
<dd>
sec:LinkedDataSignature2015
</dd>
<dt>claim</dt>
<dd>
cred:claim
with string values interpreted as @id
</dd>
<dt>created</dt>
<dd>
dc:created
with string values interpreted as xsd:dateTime
</dd>
<dt>creator</dt>
<dd>
dc:creator
with string values interpreted as @id
</dd>
<dt>cred</dt>
<dd>
https://w3id.org/credentials#
</dd>
<dt>credential</dt>
<dd>
cred:credential
with string values interpreted as @id
</dd>
<dt>dc</dt>
<dd>
http://purl.org/dc/terms/
</dd>
<dt>domain</dt>
<dd>
sec:domain
</dd>
<dt>expires</dt>
<dd>
sec:expiration
with string values interpreted as xsd:dateTime
</dd>
<dt>id</dt>
<dd>
@id
</dd>
<dt>issued</dt>
<dd>
cred:issued
with string values interpreted as xsd:dateTime
</dd>
<dt>issuer</dt>
<dd>
cred:issuer
with string values interpreted as @id
</dd>
<dt>nonce</dt>
<dd>
sec:nonce
</dd>
<dt>normalizationAlgorithm</dt>
<dd>
sec:normalizationAlgorithm
</dd>
<dt>owner</dt>
<dd>
sec:owner
with string values interpreted as @id
</dd>
<dt>privateKey</dt>
<dd>
sec:privateKey
with string values interpreted as @id
</dd>
<dt>privateKeyPem</dt>
<dd>
sec:privateKeyPem
</dd>
<dt>publicKey</dt>
<dd>
sec:publicKey
with string values interpreted as @id
</dd>
<dt>publicKeyPem</dt>
<dd>
sec:publicKeyPem
</dd>
<dt>publicKeyService</dt>
<dd>
sec:publicKeyService
with string values interpreted as @id
</dd>
<dt>recipient</dt>
<dd>
cred:recipient
with string values interpreted as @id
</dd>
<dt>referenceId</dt>
<dd>
cred:referenceId
</dd>
<dt>revoked</dt>
<dd>
sec:revoked
with string values interpreted as xsd:dateTime
</dd>
<dt>schema</dt>
<dd>
http://schema.org/
</dd>
<dt>sec</dt>
<dd>
https://w3id.org/security#
</dd>
<dt>signature</dt>
<dd>
sec:signature
</dd>
<dt>signatureAlgorithm</dt>
<dd>
sec:signatureAlgorithm
</dd>
<dt>signatureValue</dt>
<dd>
sec:signatureValue
</dd>
<dt>type</dt>
<dd>
@type
</dd>
<dt>xsd</dt>
<dd>
http://www.w3.org/2001/XMLSchema#
</dd>
</dl>
</section>
</body>
</html>
{
"@context": {
"id": "@id",
"type": "@type",
"cred": "https://w3id.org/credentials#",
"dc": "http://purl.org/dc/terms/",
"schema": "http://schema.org/",
"sec": "https://w3id.org/security#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"CryptographicKey": "sec:Key",
"GraphSignature2012": "sec:GraphSignature2012",
"Identity": "https://w3id.org/identity#Identity",
"LinkedDataSignature2015": "sec:LinkedDataSignature2015",
"created": {
"@id": "dc:created",
"@type": "xsd:dateTime"
},
"creator": {
"@id": "dc:creator",
"@type": "@id"
},
"domain": "sec:domain",
"expires": {
"@id": "sec:expiration",
"@type": "xsd:dateTime"
},
"nonce": "sec:nonce",
"normalizationAlgorithm": "sec:normalizationAlgorithm",
"owner": {
"@id": "sec:owner",
"@type": "@id"
},
"privateKey": {
"@id": "sec:privateKey",
"@type": "@id"
},
"privateKeyPem": "sec:privateKeyPem",
"publicKey": {
"@id": "sec:publicKey",
"@type": "@id"
},
"publicKeyPem": "sec:publicKeyPem",
"publicKeyService": {
"@id": "sec:publicKeyService",
"@type": "@id"
},
"revoked": {
"@id": "sec:revoked",
"@type": "xsd:dateTime"
},
"signature": "sec:signature",
"signatureAlgorithm": "sec:signatureAlgorithm",
"signatureValue": "sec:signatureValue",
"Credential": "cred:Credential",
"claim": {
"@id": "cred:claim",
"@type": "@id"
},
"credential": {
"@id": "cred:credential",
"@type": "@id"
},
"issued": {
"@id": "cred:issued",
"@type": "xsd:dateTime"
},
"issuer": {
"@id": "cred:issuer",
"@type": "@id"
},
"recipient": {
"@id": "cred:recipient",
"@type": "@id"
},
"referenceId": {
"@id": "cred:referenceId"
}
},
"@graph": {
"@context": {
"id": "@id",
"type": "@type",
"dc": "http://purl.org/dc/terms/",
"owl": "http://www.w3.org/2002/07/owl#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"dc:title": {
"@container": "@language"
},
"dc:description": {
"@container": "@language"
},
"dc:date": {
"@type": "xsd:date"
},
"rdfs:comment": {
"@container": "@language"
},
"rdfs:domain": {
"@type": "@id"
},
"rdfs:label": {
"@container": "@language"
},
"rdfs:range": {
"@type": "@id"
},
"rdfs:seeAlso": {
"@type": "@id"
},
"rdfs:subClassOf": {
"@type": "@id"
},
"rdfs:subPropertyOf": {
"@type": "@id"
},
"owl:equivalentClass": {
"@type": "@vocab"
},
"owl:equivalentProperty": {
"@type": "@vocab"
},
"owl:oneOf": {
"@container": "@list",
"@type": "@vocab"
},
"owl:imports": {
"@type": "@id"
},
"owl:versionInfo": {
"@type": "@id"
},
"owl:inverseOf": {
"@type": "@vocab"
},
"owl:unionOf": {
"@type": "@vocab",
"@container": "@list"
},
"rdfs_classes": {
"@reverse": "rdfs:isDefinedBy",
"@type": "@id"
},
"rdfs_properties": {
"@reverse": "rdfs:isDefinedBy",
"@type": "@id"
},
"rdfs_datatypes": {
"@reverse": "rdfs:isDefinedBy",
"@type": "@id"
},
"rdfs_instances": {
"@reverse": "rdfs:isDefinedBy",
"@type": "@id"
}
},
"@id": "https://w3id.org/credentials#",
"@type": "owl:Ontology",
"dc:title": {
"en": "Verifiable Claims Vocabulary"
},
"dc:description": {
"en": "This document describes the RDFS vocabulary description used for Verifiable Claims [[verifiable-claims-data-model]] along with the default JSON-LD Context."
},
"dc:date": "2017-11-05",
"owl:imports": [
"http://purl.org/dc/terms/",
"https://w3id.org/security"
],
"rdfs:seeAlso": [
"https://www.w3.org/TR/verifiable-claims-data-model/"
],
"rdfs_classes": [
{
"@id": "cred:Credential",
"@type": "rdfs:Class",
"rdfs:label": {
"en": "Credential"
},
"rdfs:comment": {
"en": "FIXME"
}
}
],
"rdfs_properties": [
{
"@id": "cred:claim",
"@type": "rdf:Property",
"rdfs:label": {
"en": "claim"
},
"rdfs:comment": {
"en": "A statement made about a `subject`. A **verifiable claim** is a claim that is tamper-resistant and whose authorship can be cryptographically verified."
},
"rdfs:range": "rdfs:Resource"
},
{
"@id": "cred:credential",
"@type": "rdf:Property",
"rdfs:label": {
"en": "credential"
},
"rdfs:comment": {
"en": "A set of one or more claims made by the same `entity` about a `subject`. A **verifiable credential** is a credential that is tamper-resistant and whose authorship can be cryptographically verified."
},
"rdfs:range": "cred:Credential"
},
{
"@id": "cred:issued",
"@type": "rdf:Property",
"rdfs:label": {
"en": "issued"
},
"rdfs:comment": {
"en": "The value of this property MUST be a string value of an [[ISO8601]] combined date and time string and represents the date and time the `credential` was issued. Note that this date represents the earliest date when the information associated with the _claim property became valid."
},
"rdfs:range": "xsd:dateTime"
},
{
"@id": "cred:issuer",
"@type": "rdf:Property",
"rdfs:label": {
"en": "issuer"
},
"rdfs:comment": {
"en": "An `entit`y that creates a `verifiable claim`, associates it with a particular `subject`, and transmits it to a `holder`."
}
},
{
"@id": "cred:recipient",
"@type": "rdf:Property",
"rdfs:label": {
"en": "recipient"
},
"rdfs:comment": {
"en": "FIXME"
}
},
{
"@id": "cred:referenceId",
"@type": "rdf:Property",
"rdfs:label": {
"en": "referenceId"
},
"rdfs:comment": {
"en": "FIXME"
}
}
]
}
}
@prefix dc: <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 cred: <https://w3id.org/credentials#> .
@prefix schema: <http://schema.org/> .
@prefix sec: <https://w3id.org/security#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
# CSVM Ontology definition
cred: a owl:Ontology;
dc:title "Verifiable Claims Vocabulary"@en;
dc:description """This document describes the RDFS vocabulary description used for Verifiable Claims [[verifiable-claims-data-model]] along with the default JSON-LD Context."""@en;
dc:date "2017-11-05"^^xsd:date;
dc:imports <http://purl.org/dc/terms/>, <https://w3id.org/security>;
rdfs:seeAlso <https://www.w3.org/TR/verifiable-claims-data-model/>;
# Class definitions
cred:Credential a rdfs:Class;
rdfs:label "Credential"@en;
rdfs:comment """FIXME"""@en;
rdfs:isDefinedBy cred: .
# Property definitions
cred:claim a rdf:Property;
rdfs:label "claim"@en;
rdfs:comment """A statement made about a `subject`. A **verifiable claim** is a claim that is tamper-resistant and whose authorship can be cryptographically verified."""@en;
rdfs:range rdfs:Resource;
rdfs:isDefinedBy cred: .
cred:credential a rdf:Property;
rdfs:label "credential"@en;
rdfs:comment """A set of one or more claims made by the same `entity` about a `subject`. A **verifiable credential** is a credential that is tamper-resistant and whose authorship can be cryptographically verified."""@en;
rdfs:range cred:Credential;
rdfs:isDefinedBy cred: .
cred:issued a rdf:Property;
rdfs:label "issued"@en;
rdfs:comment """The value of this property MUST be a string value of an [[ISO8601]] combined date and time string and represents the date and time the `credential` was issued. Note that this date represents the earliest date when the information associated with the _claim property became valid."""@en;
rdfs:range xsd:dateTime;
rdfs:isDefinedBy cred: .
cred:issuer a rdf:Property;
rdfs:label "issuer"@en;
rdfs:comment """An `entit`y that creates a `verifiable claim`, associates it with a particular `subject`, and transmits it to a `holder`."""@en;
rdfs:isDefinedBy cred: .
cred:recipient a rdf:Property;
rdfs:label "recipient"@en;
rdfs:comment """FIXME"""@en;
rdfs:isDefinedBy cred: .
cred:referenceId a rdf:Property;
rdfs:label "referenceId"@en;
rdfs:comment """FIXME"""@en;
rdfs:isDefinedBy cred: .
#! /usr/bin/env ruby
# Parse vocabulary definition in CSV to generate Context+Vocabulary in JSON-LD or Turtle
require 'getoptlong'
require 'csv'
require 'json'
require 'erubis'
class Vocab
JSON_STATE = JSON::State.new(
:indent => " ",
:space => " ",
:space_before => "",
:object_nl => "\n",
:array_nl => "\n"
)
TITLE = "Verifiable Claims Vocabulary".freeze
DESCRIPTION = %(This document describes the RDFS vocabulary description used for Verifiable Claims [[verifiable-claims-data-model]] along with the default JSON-LD Context.).freeze
attr_accessor :prefixes, :terms, :properties, :classes, :instances, :datatypes,
:imports, :date, :commit, :seeAlso
def initialize
path = File.expand_path("../vocab.csv", __FILE__)
csv = CSV.new(File.open(path))
@prefixes, @terms, @properties, @classes, @datatypes, @instances = {}, {}, {}, {}, {}, {}
@imports, @seeAlso = [], []
#git_info = %x{git log -1 #{path}}.split("\n")
#@commit = "https://github.com/w3c/vc-vocab/commit/" + (git_info[0] || 'uncommitted').split.last
date_line = nil #git_info.detect {|l| l.start_with?("Date:")}
@date = Date.parse((date_line || Date.today.to_s).split(":",2).last).strftime("%Y-%m-%d")
columns = []
csv.shift.each_with_index {|c, i| columns[i] = c.to_sym if c}
csv.sort_by(&:to_s).each do |line|
entry = {}
# Create entry as object indexed by symbolized column name
line.each_with_index {|v, i| entry[columns[i]] = v ? v.gsub("\r", "\n").gsub("\\", "\\\\") : nil}
case entry[:type]
when 'prefix' then @prefixes[entry[:id]] = entry
when 'term' then @terms[entry[:id]] = entry
when 'rdf:Property' then @properties[entry[:id]] = entry
when 'rdfs:Class' then @classes[entry[:id]] = entry
when 'rdfs:Datatype' then @datatypes[entry[:id]] = entry
when 'owl:imports' then @imports << entry[:subClassOf]
when 'rdfs:seeAlso' then @seeAlso << entry[:subClassOf]
else @instances[entry[:id]] = entry
end
end
end
def namespaced(term)
term.include?(":") ? term : "cred:#{term}"
end
def to_jsonld
context = {
"id" => "@id",
"type" => "@type",
}
rdfs_context = ::JSON.parse %({
"id": "@id",
"type": "@type",
"dc": "http://purl.org/dc/terms/",
"owl": "http://www.w3.org/2002/07/owl#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"dc:title": {"@container": "@language"},
"dc:description": {"@container": "@language"},
"dc:date": {"@type": "xsd:date"},
"rdfs:comment": {"@container": "@language"},
"rdfs:domain": {"@type": "@id"},
"rdfs:label": {"@container": "@language"},
"rdfs:range": {"@type": "@id"},
"rdfs:seeAlso": {"@type": "@id"},
"rdfs:subClassOf": {"@type": "@id"},
"rdfs:subPropertyOf": {"@type": "@id"},
"owl:equivalentClass": {"@type": "@vocab"},
"owl:equivalentProperty": {"@type": "@vocab"},
"owl:oneOf": {"@container": "@list", "@type": "@vocab"},
"owl:imports": {"@type": "@id"},
"owl:versionInfo": {"@type": "@id"},
"owl:inverseOf": {"@type": "@vocab"},
"owl:unionOf": {"@type": "@vocab", "@container": "@list"},
"rdfs_classes": {"@reverse": "rdfs:isDefinedBy", "@type": "@id"},
"rdfs_properties": {"@reverse": "rdfs:isDefinedBy", "@type": "@id"},
"rdfs_datatypes": {"@reverse": "rdfs:isDefinedBy", "@type": "@id"},
"rdfs_instances": {"@reverse": "rdfs:isDefinedBy", "@type": "@id"}
})
rdfs_classes, rdfs_properties, rdfs_datatypes, rdfs_instances = [], [], [], []
prefixes.each do |id, entry|
context[id] = entry[:subClassOf]
end
terms.each do |id, entry|
next if entry[:@type] == '@null'
context[id] = if [:@container, :@type].any? {|k| entry[k]}
{'@id' => entry[:subClassOf]}.
merge(entry[:@container] ? {'@container' => entry[:@container]} : {}).
merge(entry[:@type] ? {'@type' => entry[:@type]} : {})
else
entry[:subClassOf]
end
end
classes.each do |id, entry|
term = entry[:term] || id
context[term] = namespaced(id) unless entry[:@type] == '@null'
# Class definition
node = {
'@id' => namespaced(id),
'@type' => 'rdfs:Class',
'rdfs:label' => {"en" => entry[:label].to_s},
'rdfs:comment' => {"en" => entry[:comment].to_s},
}
node['rdfs:subClassOf'] = namespaced(entry[:subClassOf]) if entry[:subClassOf]
rdfs_classes << node
end
properties.each do |id, entry|
defn = {"@id" => namespaced(id)}
case entry[:range]
when "xsd:string" then defn['@language'] = nil
when /xsd:/ then defn['@type'] = entry[:range].split(',').first
when nil,
'rdfs:Literal' then ;
else defn['@type'] = '@id'
end
defn['@container'] = entry[:@container] if entry[:@container]
defn['@type'] = entry[:@type] if entry[:@type]
term = entry[:term] || id
context[term] = defn unless entry[:@type] == '@null'
# Property definition
node = {
'@id' => namespaced(id),
'@type' => 'rdf:Property',
'rdfs:label' => {"en" => entry[:label].to_s},
'rdfs:comment' => {"en" => entry[:comment].to_s},
}
node['rdfs:subPropertyOf'] = namespaced(entry[:subClassOf]) if entry[:subClassOf]
domains = entry[:domain].to_s.split(',')
case domains.length
when 0 then ;
when 1 then node['rdfs:domain'] = namespaced(domains.first)
else node['rdfs:domain'] = {'owl:unionOf' => domains.map {|d| namespaced(d)}}
end
ranges = entry[:range].to_s.split(',')
case ranges.length
when 0 then ;
when 1 then node['rdfs:range'] = namespaced(ranges.first)
else node['rdfs:range'] = {'owl:unionOf' => ranges.map {|r| namespaced(r)}}
end
rdfs_properties << node
end
datatypes.each do |id, entry|
context[id] = namespaced(id) unless entry[:@type] == '@null'
# Datatype definition
node = {
'@id' => namespaced(id),
'@type' => 'rdfs:Datatype',
'rdfs:label' => {"en" => entry[:label].to_s},
'rdfs:comment' => {"en" => entry[:comment].to_s},
}
node['rdfs:subClassOf'] = namespaced(entry[:subClassOf]) if entry[:subClassOf]
rdfs_datatypes << node
end
instances.each do |id, entry|
context[id] = namespaced(id) unless entry[:@type] == '@null'
# Instance definition
rdfs_instances << {
'@id' => namespaced(id),
'@type' => entry[:type],
'rdfs:label' => {"en" => entry[:label].to_s},
'rdfs:comment' => {"en" => entry[:comment].to_s},
}
end
# Use separate rdfs context so as not to polute the context.
ontology = {
"@context" => rdfs_context,
"@id" => prefixes["cred"][:subClassOf],
"@type" => "owl:Ontology",
"dc:title" => {"en" => TITLE},
"dc:description" => {"en" => DESCRIPTION},
"dc:date" => date,
"owl:imports" => imports,
#"owl:versionInfo" => commit,
"rdfs:seeAlso" => seeAlso,
"rdfs_classes" => rdfs_classes,
"rdfs_properties" => rdfs_properties,
"rdfs_datatypes" => rdfs_datatypes,
"rdfs_instances" => rdfs_instances
}.delete_if {|k,v| Array(v).empty?}
{
"@context" => context,
"@graph" => ontology
}.to_json(JSON_STATE)
end
def to_html
json = JSON.parse(to_jsonld)
eruby = Erubis::Eruby.new(File.read("template.html"))
eruby.result(ont: json['@graph'], context: json['@context'])
end
def to_ttl
output = []
prefixes = {
"dc" => {subClassOf: "http;//purl.org/dc/terms/"},
"owl" => {subClassOf: "http://www.w3.org/2002/07/owl#"},
"rdf" => {subClassOf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#"},
"rdfs" => {subClassOf: "http://www.w3.org/2000/01/rdf-schema#"},
}.merge(@prefixes).dup
prefixes.each {|id, entry| output << "@prefix #{id}: <#{entry[:subClassOf]}> ."}
output << "\n# CSVM Ontology definition"
output << "cred: a owl:Ontology;"
output << %( dc:title "#{TITLE}"@en;)
output << %( dc:description """#{DESCRIPTION}"""@en;)
output << %( dc:date "#{date}"^^xsd:date;)
output << %( dc:imports #{imports.map {|i| '<' + i + '>'}.join(", ")};)
#output << %( owl:versionInfo <#{commit}>;)
output << %( rdfs:seeAlso #{seeAlso.map {|i| '<' + i + '>'}.join(", ")};)
output << "\n# Class definitions" unless @classes.empty?
@classes.each do |id, entry|
output << "cred:#{id} a rdfs:Class;"
output << %( rdfs:label "#{entry[:label]}"@en;)
output << %( rdfs:comment """#{entry[:comment]}"""@en;)
output << %( rdfs:subClassOf #{namespaced(entry[:subClassOf])};) if entry[:subClassOf]
output << %( rdfs:isDefinedBy cred: .)
end
output << "\n# Property definitions" unless @properties.empty?
@properties.each do |id, entry|
output << "cred:#{id} a rdf:Property;"
output << %( rdfs:label "#{entry[:label]}"@en;)
output << %( rdfs:comment """#{entry[:comment]}"""@en;)
output << %( rdfs:subPropertyOf #{namespaced(entry[:subClassOf])};) if entry[:subClassOf]
domains = entry[:domain].to_s.split(',')
case domains.length
when 0 then ;
when 1 then output << %( rdfs:domain #{namespaced(entry[:domain])};)
else
output << %( rdfs:domain [ owl:unionOf (#{domains.map {|d| namespaced(d)}.join(' ')})];)
end
ranges = entry[:range].to_s.split(',')
case ranges.length
when 0 then ;
when 1 then output << %( rdfs:range #{namespaced(entry[:range])};)
else
output << %( rdfs:range [ owl:unionOf (#{ranges.map {|d| namespaced(d)}.join(' ')})];)
end
output << %( rdfs:isDefinedBy cred: .)
end
output << "\n# Datatype definitions" unless @datatypes.empty?
@datatypes.each do |id, entry|
output << "cred:#{id} a rdfs:Datatype;"
output << %( rdfs:label "#{entry[:label]}"@en;)
output << %( rdfs:comment """#{entry[:comment]}"""@en;)
output << %( rdfs:subClassOf #{namespaced(entry[:subClassOf])};) if entry[:subClassOf]
output << %( rdfs:isDefinedBy cred: .)
end
output << "\n# Instance definitions" unless @instances.empty?
@instances.each do |id, entry|
output << "cred:#{id} a #{namespaced(entry[:type])};"
output << %( rdfs:label "#{entry[:label]}"@en;)
output << %( rdfs:comment """#{entry[:comment]}"""@en;)
output << %( rdfs:isDefinedBy cred: .)
end
output.join("\n")
end
end
options = {
output: $stdout
}
OPT_ARGS = [
["--format", "-f", GetoptLong::REQUIRED_ARGUMENT,"Output format, default #{options[:format].inspect}"],
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT,"Output to the specified file path"],
["--quiet", GetoptLong::NO_ARGUMENT, "Supress most output other than progress indicators"],
["--help", "-?", GetoptLong::NO_ARGUMENT, "This message"]
]
def usage
STDERR.puts %{Usage: #{$0} [options] URL ...}
width = OPT_ARGS.map do |o|
l = o.first.length
l += o[1].length + 2 if o[1].is_a?(String)
l
end.max
OPT_ARGS.each do |o|
s = " %-*s " % [width, (o[1].is_a?(String) ? "#{o[0,2].join(', ')}" : o[0])]
s += o.last
STDERR.puts s
end
exit(1)
end
opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})
opts.each do |opt, arg|
case opt
when '--format' then options[:format] = arg.to_sym
when '--output' then options[:output] = File.open(arg, "w")
when '--quiet' then options[:quiet] = true
when '--help' then usage
end
end
vocab = Vocab.new
case options[:format]
when :jsonld then options[:output].puts(vocab.to_jsonld)
when :ttl then options[:output].puts(vocab.to_ttl)
when :html then options[:output].puts(vocab.to_html)
else
[:jsonld, :ttl, :html].each do |format|
fn = {jsonld: "credentials.jsonld", ttl: "credentials.ttl", html: "credentials.html"}[format]
File.open(fn, "w") do |output|
output.puts(vocab.send("to_#{format}".to_sym))
end
end
end
<html lang="en">
<head>
<meta charset='utf-8'/>
<title><%= ont["dc:title"]["en"] %></title>
<script class="remove" src="https://www.w3.org/Tools/respec/respec-w3c-common"></script>
<script src="https://opencreds.github.io/vc-common/common.js"></script>
<script class="remove">
var respecConfig = {
localBiblio: opencreds.localBiblio,
specStatus: "base",
shortName: "vc-vocab",
publishDate: "<%=ont["dc:date"]%>",
thisVersion: "http://w3id.org/credentials",
//edDraftURI: "https://w3c.github.io/vc-vocab/",
// lcEnd: "3000-01-01",
// crEnd: "3000-01-01",
editors: [{
name: "Gregg Kellogg",
url: "http://greggkellogg.net/",
company: "Spec-Ops",
companyURL: "https://spec-ops.io/",
w3cid: "44770"
}],
wg: "Verifiable Claims Working Group",
wgURI: "https://www.w3.org/2017/vc/",
wgPublicList: "public-vc-comments",
wgPatentURI: "https://www.w3.org/2004/01/pp-impl/98922/status",
alternateFormats: [
{uri: "credentials.ttl", label: "Turtle"},
{uri: "credentials.jsonld", label: "JSON-LD"}
],
//otherLinks: [{
// key: "Repository",
// data: [{
// value: "We are on GitHub",
// href: "https://github.com/shexSpec/shexspec.github.io/"
// }, {
// value: "File a bug",
// href: "https://github.com/shexSpec/shex/issues"
// }]
//}, {
// key: "Changes",
// data: [{
// // value: "Diff to previous version",
// // href: "diff-20140327.html"
// // }, {
// value: "Commit history",
// href: "https://github.com/shexSpec/shexspec.github.io/commits/master"
// }]
//}] ,
inlineCSS: true,
doRDFa: false,
noIDLIn: true,
//issueBase: "https://github.com/shexSpec/shex/issues/",
noLegacyStyle: false
};
</script>
<style type="text/css">
dl.terms dt {
float: left;
clear: left;
width: 17vw;
}
dl.terms dd:after {
content: '';
display: block;
clear: both;
margin-bottom: 5px;
}
table.rdfs-definition td {vertical-align: top;}
.bold {font-weight: bold;}
</style>
</head>
<body resource="<%=context['cred']%>" typeof="owl:Ontology" prefix="cred: <%=context['cred']%>">
<section id="abstract">
<p>This document describes the
<span property="dc:title"><%= ont["dc:title"]["en"] %></span>
and Term definitions used
for describing Verfiable Claims [[verifiable-claims-data-model]]. This document provides the RDFS [[RDF-SCHEMA]] vocabulary definition and a description of the JSON-LD context definition for use with
defining Verfiable Claims.</p>
<p>Alternate versions of the vocabulary definition exist in
<a rel="alternate" href="credentials.ttl">Turtle</a> and
<a rel="alternate" href="credentials.jsonld">JSON-LD</a>,
which also includes the <code>@context</code> required for metadata descriptions.
<!--These versions may also be retrieved from <code>FIXME</code> using an appropiate HTTP <em>Accept</em> header.-->
</p>
<dl>
<dt>Published:</dt><dd><time property="dc:date"><%=ont["dc:date"]%></time></dd>
<%- unless Array(ont["owl:imports"]).empty?%>
<dt>Imports:</dt>
<%- Array(ont["owl:imports"]).each do |ref| %>
<dd><a href="<%=ref%>" property="owl:imports"><%=ref%></a></dd>
<% end -%>
<% end -%>
<dt>Version Info:</dt>
<dd><a href="<%=ont['owl:versionInfo']%>" property="owl:versionInfo"><%=ont['owl:versionInfo']%></a></dd>
<dt>See Also:</dt>
<% Array(ont["rdfs:seeAlso"]).each do |ref| %>
<dd><a href="<%=ref%>" property="rdfs:seeAlso"><%=ref%></a></dd>
<% end %>
</dl>
</section>
<section id="sotd">
<p>
FIXME
</p>
</section>
<section>
<h2>Introduction</h2>
<p property="dc:description"><%= ont["dc:description"]["en"] %></p>
<p>This specification makes use of the following namespaces:</p>
<dl class="terms">
<dt><code>cred</code>:</dt>
<dd><code>https://w3id.org/credentials#</code></dd>
<dt><code>dc</code>:</dt>
<dd><code>http://purl.org/dc/terms/</code></dd>
<dt><code>sec</code>:</dt>
<dd><code>https://w3id.org/security#</code></dd>
<dt><code>xsd</code>:</dt>
<dd><code>http://www.w3.org/2001/XMLSchema#</code></dd>
</dl>
</section>
<%
[{
heading: "Class Definitions",
key: "rdfs_classes"
}, {
heading: "Property Definitions",
key: "rdfs_properties"
}, {
heading: "Datatype Definitions",
key: "rdfs_datatypes"
}, {
heading: "Instance Definitions",
key: "rdfs_instances"
}].each do |sect|
%>
<% next if Array(ont[sect[:key]]).empty? %>
<section>
<h2><%= sect[:heading] %></h2>
<p>The following are <%= sect[:heading].downcase %> in the <code>shex</code> namespace:</p>
<table class="rdfs-definition">
<% Array(ont[sect[:key]]).each do |defn| -%>
<tr><td class="bold"><%= defn['@id'][5..-1] %></td>
<td resource="<%= defn['@id'] %>" typeof="<%= Array(defn['@type']).join(" ") %>">
<em property="rdfs:label"><%= defn['rdfs:label']['en'] %></em>
<p property="rdfs:comment"><%= defn['rdfs:comment']['en'] %></p>
<span property="rdfs:isDefinedBy" resource="shex:"></span>
<% if %w(rdfs:subClassOf rdfs:subPropertyOf rdfs:range rdfs:domain).any? { |p| defn.has_key?(p)} %>
<dl class="terms">
<% %w(rdfs:subClassOf rdfs:subPropertyOf rdfs:range rdfs:domain).each do |p| %>
<% if defn.has_key?(p) %>
<dt><%= p %></dt>
<% Array(defn[p]).each do |v| %>
<%if v.is_a?(Array) && v.first == 'owl:unionOf' %>
<dd property="<%= p %>" resource="_:">
Union of
<% v.last.each do |c| %>
<span property="owl:unionOf" inlist=true resource="<%= c %>"><%= c %></span>
<% end%>
</dd>
<% else %>
<dd property="<%= p %>" resource="<%= v %>"><%= v %></dd>
<% end %>
<% end %>
<% end %>
<% end %>
</dl>
<% end %>
</td>
</tr>
<% end -%>
</table>
</section>
<% end%>
<section>
<h2>Term Definitions</h2>
<dl class="terms">
<% context.keys.sort.each do |term|%>
<% defn = context[term] %>
<dt><%= term %></dt>
<dd>
<% if defn.is_a?(String) %>
<%= defn %>
<% elsif defn['@id'] %>
<%= defn['@id'] %>
<% elsif defn['@reverse'] %>
reverse of <%= defn['@reverse'] %>
<% else %>
<%= term %>
<% end %>
<% if defn.is_a?(Hash) && defn['@type'] %>
with string values interpreted as <%= defn['@type'] %>
<% end%>
<% if defn.is_a?(Hash) && defn['@container'] %>
<% if defn['@container'] == '@language' %>
with object values interpreted as language-specific, indexed by language
<% elsif defn['@container'] == '@index' %>
with object values interpreted indexed by index
<% else %>
with array values interpreted as <%= defn['@container'] %>
<% end %>
<% end%>
</dd>
<% end %>
</dl>
</section>
</body>
</html>
id type label subClassOf range range @type @container comment
cred prefix https://w3id.org/credentials#
dc prefix http://purl.org/dc/terms/
sec prefix https://w3id.org/security#
schema prefix http://schema.org/
xsd prefix http://www.w3.org/2001/XMLSchema#
owl:imports http://purl.org/dc/terms/
owl:imports https://w3id.org/security
rdfs:seeAlso https://www.w3.org/TR/verifiable-claims-data-model/
claim rdf:Property claim Credential rdfs:Resource A statement made about a `subject`. A **verifiable claim** is a claim that is tamper-resistant and whose authorship can be cryptographically verified.
credential rdf:Property credential Credential A set of one or more claims made by the same `entity` about a `subject`. A **verifiable credential** is a credential that is tamper-resistant and whose authorship can be cryptographically verified.
issued rdf:Property issued Credential xsd:dateTime The value of this property MUST be a string value of an [[ISO8601]] combined date and time string and represents the date and time the `credential` was issued. Note that this date represents the earliest date when the information associated with the _claim property became valid.
issuer rdf:Property issuer Credential @id An `entit`y that creates a `verifiable claim`, associates it with a particular `subject`, and transmits it to a `holder`.
recipient rdf:Property recipient @id FIXME
referenceId rdf:Property referenceId FIXME
Credential rdfs:Class Credential FIXME
Identity term https://w3id.org/identity#Identity FIXME
created term dc:created xsd:dateTime
creator term dc:creator @id
domain term sec:domain
expires term sec:expiration xsd:dateTime
nonce term sec:nonce
normalizationAlgorithm term sec:normalizationAlgorithm
owner term sec:owner @id
privateKey term sec:privateKey @id
privateKeyPem term sec:privateKeyPem
publicKey term sec:publicKey @id
publicKeyPem term sec:publicKeyPem
publicKeyService term sec:publicKeyService @id
revoked term sec:revoked xsd:dateTime
signature term sec:signature
signatureAlgorithm term sec:signatureAlgorithm
signatureValue term sec:signatureValue
CryptographicKey term sec:Key
GraphSignature2012 term sec:GraphSignature2012
LinkedDataSignature2015 term sec:LinkedDataSignature2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment