我正在尝试为公司/子公司及其网站完成机器可理解的关系描述。假设有一家母公司有两家子公司,所有子公司都有自己的网站。我在每个主页上部署了一个Organization
脚本和一个WebSite
脚本。
上级组织的JSON-LD读取:
<script type="application/ld+json">
{
"@context": "http://www.schema.org",
"@type": "Organization",
"@id": "https://www.parentorg.com/#organization",
"name": "Parent Org",
"legalName": "Parent Org Inc.",
"description": "Description of company",
"foundingDate": "1978",
"logo": "https://www.parentorg.com/images/logo.png",
"image": "https://www.parentorg.com/de/images/outside.jpg",
"url": "https://www.parentorg.com/",
"address": {
"@type": "PostalAddress",
"streetAddress": "Street 110",
"addressLocality": "City",
"postalCode": "XX XXX",
"addressCountry": "XX"
},
"contactPoint": {
"@type": "ContactPoint",
"contactType": "customer support",
"telephone": "+12-345-678-91011",
"email": "[email protected]"
},
"sameAs": [
"https://twitter.com/parentorg/",
"https://www.instagram.com/parentorg/",
"https://www.youtube.com/user/parentorg/",
"https://plus.google.com/parentorg"
],
"subOrganization": [
{
"@type": "Organization",
"@id": "https://www.subsidiary-one.de/#organization",
"name": "Subsidiary One"
},
{
"@type": "Organization",
"@id": "https://www.subsidiary-two.de/#organization",
"name": "Subsidiary Two"
}
]
}
</script>
父母的网站JSON-LD是:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"@id": "https://www.parentorg.com/#website",
"url": "https://www.parentorg.com/",
"author": {
"@type": "Organization",
"@id": "https://www.parentorg.com/#organization",
"name": "Parent Org"
}
}
</script>
现在子公司的组织JSON-LD包含parentOrganization
属性:
"parentOrganization": {
"@type": "Organization",
"@id": "https://www.parentorg.com/#organization",
"name": "Parent Org"
}
这是交叉引用这些实体的好方法吗?当引用URI时,我甚至需要写出name
,subOrganization
和parentOrganization
中的author
属性吗?
是的,您遵循最佳实践如何交叉引用实体(通过giving each entity an @id
that is different from the url
)。
在引用实体时,您不必提供其他属性,因此这很好:
"author": {"@id": "https://www.parentorg.com/#organization"}
"subOrganization": [
{"@id": "https://www.subsidiary-one.de/#organization"},
{"@id": "https://www.subsidiary-two.de/#organization"}
]
"parentOrganization": {"@id": "https://www.parentorg.com/#organization"}
但是,这当然要求消费者获取引用的文档。但并非所有人(可能)都这样做。因此,如果您想为这些消费者提供数据,除了@id
之外,您还可以添加属性。它可能只是一个,几个甚至所有属性。我认为你的例子中的两个是最重要的:
@type
对于能够获取文档的消费者也是有用的,因为它可以允许他们在获取之前决定所引用的资源是否是他们感兴趣的。例如,一个消费者可能只关心由author
而不是Organization
所做的qazxs作品。Person
属性对于以某种方式显示包含的结构化数据并从名称/标签中受益的消费者非常有用。