从 schema.org 加载 JSON-LD 架构
Load JSON-LD schema from schema.org
这可能是个愚蠢的问题,但我正在尝试弄清楚如何从 https://schema.org/Person.
中将实际的 Person 模式作为 JSON-LD 文档加载
根据我的理解,应该有一个包含架构定义的脚本标记,如下所示:
<script type="application/ld+json">
{
// here would be the schema definition in JSON-LD format
}
<script/>
但是,我在这个网站上找不到这样的标签。
这里有另一个端点可以下载模式集合 https://schema.org/version/latest/schemaorg-current-http.jsonld。在此模式中,我可以使用以下搜索查询 "@id": "schema:Person"
找到一个 Person 模式。然而,这个对象似乎并不完整,因为它只包含以下信息:
{
"@id": "schema:Person",
"@type": "rdfs:Class",
"http://www.w3.org/2002/07/owl#equivalentClass": {
"@id": "http://xmlns.com/foaf/0.1/Person"
},
"rdfs:comment": "A person (alive, dead, undead, or fictional).",
"rdfs:label": "Person",
"rdfs:subClassOf": {
"@id": "schema:Thing"
},
"schema:source": {
"@id": "http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_rNews"
}
}
如果我只对 Person 模式感兴趣,那么总是下载整个 json-ld 集合似乎也不是很有效。所以我想,我在从 schema.org.
检索 JSON-LD 文档的过程中误解了一些东西
谁能解释一下我应该如何使用模式形式 schema.org?
编辑:为了更清楚,让我添加一个用例。以下 json-ld 文档来自 here:
{ // external (all terms in this example)
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/citizenship/v1"
],
"type": [
"VerifiableCredential",
"PermanentResidentCard"
],
"credentialSubject": {
"id": "did:example:123",
"type": [
"PermanentResident",
"Person"
],
"givenName": "JOHN",
"familyName": "SMITH",
"gender": "Male",
"image": "data:image/png;base64,iVBORw0KGgo...kJggg==",
"residentSince": "2015-01-01",
"lprCategory": "C09",
"lprNumber": "000-000-204",
"commuterClassification": "C1",
"birthCountry": "Bahamas",
"birthDate": "1958-08-17"
},
"issuer": "did:example:456",
"issuanceDate": "2020-04-22T10:37:22Z",
"identifier": "83627465",
"name": "Permanent Resident Card",
"description": "Government of Example Permanent Resident Card.",
"proof": {
"type": "Ed25519Signature2018",
"created": "2020-04-22T10:37:22Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:example:456#key-1",
"jws": "eyJjcml0IjpbImI2NCJdLCJiNjQiOmZhbHNlLCJhbGciOiJFZERTQSJ9..BhWew0x-txcroGjgdtK-yBCqoetg9DD9SgV4245TmXJi-PmqFzux6Cwaph0r-mbqzlE17yLebjfqbRT275U1AA"
}
}
在此示例中,我可以通过遵循 links https://www.w3.org/2018/credentials/v1 and https://w3id.org/citizenship/v1 来获取架构定义。使用 @type
我知道我应该只考虑 VerifiableCredential
作为第一个上下文和 PermanentResidentCard
(尽管它应该是 PermanentResident
IMO 因为 birthDate
不是一部分PermanentResidentCard
) 第二个 link。因此,我知道 birthDate
可以解释为 date
.
如何使用来自 schema.org 的模式获得相同的逻辑?
我发布了另一个更简单的问题,阐明了解决方案的工作原理。查看答案 .
这可能是个愚蠢的问题,但我正在尝试弄清楚如何从 https://schema.org/Person.
中将实际的 Person 模式作为 JSON-LD 文档加载根据我的理解,应该有一个包含架构定义的脚本标记,如下所示:
<script type="application/ld+json">
{
// here would be the schema definition in JSON-LD format
}
<script/>
但是,我在这个网站上找不到这样的标签。
这里有另一个端点可以下载模式集合 https://schema.org/version/latest/schemaorg-current-http.jsonld。在此模式中,我可以使用以下搜索查询 "@id": "schema:Person"
找到一个 Person 模式。然而,这个对象似乎并不完整,因为它只包含以下信息:
{
"@id": "schema:Person",
"@type": "rdfs:Class",
"http://www.w3.org/2002/07/owl#equivalentClass": {
"@id": "http://xmlns.com/foaf/0.1/Person"
},
"rdfs:comment": "A person (alive, dead, undead, or fictional).",
"rdfs:label": "Person",
"rdfs:subClassOf": {
"@id": "schema:Thing"
},
"schema:source": {
"@id": "http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_rNews"
}
}
如果我只对 Person 模式感兴趣,那么总是下载整个 json-ld 集合似乎也不是很有效。所以我想,我在从 schema.org.
检索 JSON-LD 文档的过程中误解了一些东西谁能解释一下我应该如何使用模式形式 schema.org?
编辑:为了更清楚,让我添加一个用例。以下 json-ld 文档来自 here:
{ // external (all terms in this example)
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/citizenship/v1"
],
"type": [
"VerifiableCredential",
"PermanentResidentCard"
],
"credentialSubject": {
"id": "did:example:123",
"type": [
"PermanentResident",
"Person"
],
"givenName": "JOHN",
"familyName": "SMITH",
"gender": "Male",
"image": "data:image/png;base64,iVBORw0KGgo...kJggg==",
"residentSince": "2015-01-01",
"lprCategory": "C09",
"lprNumber": "000-000-204",
"commuterClassification": "C1",
"birthCountry": "Bahamas",
"birthDate": "1958-08-17"
},
"issuer": "did:example:456",
"issuanceDate": "2020-04-22T10:37:22Z",
"identifier": "83627465",
"name": "Permanent Resident Card",
"description": "Government of Example Permanent Resident Card.",
"proof": {
"type": "Ed25519Signature2018",
"created": "2020-04-22T10:37:22Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:example:456#key-1",
"jws": "eyJjcml0IjpbImI2NCJdLCJiNjQiOmZhbHNlLCJhbGciOiJFZERTQSJ9..BhWew0x-txcroGjgdtK-yBCqoetg9DD9SgV4245TmXJi-PmqFzux6Cwaph0r-mbqzlE17yLebjfqbRT275U1AA"
}
}
在此示例中,我可以通过遵循 links https://www.w3.org/2018/credentials/v1 and https://w3id.org/citizenship/v1 来获取架构定义。使用 @type
我知道我应该只考虑 VerifiableCredential
作为第一个上下文和 PermanentResidentCard
(尽管它应该是 PermanentResident
IMO 因为 birthDate
不是一部分PermanentResidentCard
) 第二个 link。因此,我知道 birthDate
可以解释为 date
.
如何使用来自 schema.org 的模式获得相同的逻辑?
我发布了另一个更简单的问题,阐明了解决方案的工作原理。查看答案