是否有微数据标签来指定值是数字、字符串还是布尔值?
Is there a microdata tag to designate whether a value is a number, string, or bool?
有一个名为 datetime
的 HTML5 属性,它表示值类型是日期时间。但是我看不出有什么方法可以表明 span
标签中的 itemprop
值是字符串、布尔值还是数字。没有办法将此类信息包含在微数据中,我说得对吗?如果是这样,是否有某些原因应省略此功能?
仅限微数据规范 differs between these types of values,它源自 HTML5 标记:
- item(如果一个元素有一个
itemprop
和一个itemscope
属性)
- absolute URL(如果
itemprop
在 URL 属性 元素上指定,例如 a
, video
等)
- datetime(如果在
time
元素上指定了 itemprop
)
- 字符串,即
- 对于
meta
元素:content
属性的值
- 对于
data
元素:value
属性的值
- 对于
meter
元素:value
属性的值
- 对于所有其他元素:其 textContent
虽然 RDFa 允许使用其 datatype
attribute 指定数据类型…
<span property="alive" datatype="xsd:boolean">true</span>
<!-- the value is boolean -->
…微数据不提供这样的属性:
<span itemprop="alive">true</span>
<!-- no way to denote that the value is boolean -->
有人认为 specify the datatype of Microdata properties in the vocabulary registry, but it seems 对此没有达成共识。
做什么?
词汇表可以在描述中定义其属性 should/must 具有哪些值。
词汇表Schema.org期望(并且有意不要求)特定类型。示例:
-
Values expected to be one of these types:
Boolean
词汇表vCard (as defined by the WHATWG)需要值类型。示例:
-
The value must be a valid date string.
-
The value must be one of F
, meaning "female", M
, meaning "male", N
, meaning "none or not applicable", O
, meaning "other", or U
, meaning "unknown".
当然可以 use/create 一个微数据词汇表来对其他微数据词汇表做出这样的陈述,类似于 RDFS。 Schema.org 是 using RDFa to define their types/properties, and they also use RDFS, but instead of defining a range with rdfs:range
(which would mean that all property values are (also) of that type), they made their own property rangeIncludes
,不允许这样的推论:
<div typeof="rdf:Property" resource="http://schema.org/free">
<span class="h" property="rdfs:label">free</span>
<span property="rdfs:comment">A flag to signal that the publication is accessible for free.</span>
<span>Domain: <a property="http://schema.org/domainIncludes" href="http://schema.org/PublicationEvent">PublicationEvent</a></span>
<span>Range: <a property="http://schema.org/rangeIncludes" href="http://schema.org/Boolean">Boolean</a></span>
</div>
有一个名为 datetime
的 HTML5 属性,它表示值类型是日期时间。但是我看不出有什么方法可以表明 span
标签中的 itemprop
值是字符串、布尔值还是数字。没有办法将此类信息包含在微数据中,我说得对吗?如果是这样,是否有某些原因应省略此功能?
仅限微数据规范 differs between these types of values,它源自 HTML5 标记:
- item(如果一个元素有一个
itemprop
和一个itemscope
属性) - absolute URL(如果
itemprop
在 URL 属性 元素上指定,例如a
,video
等) - datetime(如果在
time
元素上指定了itemprop
) - 字符串,即
- 对于
meta
元素:content
属性的值 - 对于
data
元素:value
属性的值 - 对于
meter
元素:value
属性的值 - 对于所有其他元素:其 textContent
- 对于
虽然 RDFa 允许使用其 datatype
attribute 指定数据类型…
<span property="alive" datatype="xsd:boolean">true</span>
<!-- the value is boolean -->
…微数据不提供这样的属性:
<span itemprop="alive">true</span>
<!-- no way to denote that the value is boolean -->
有人认为 specify the datatype of Microdata properties in the vocabulary registry, but it seems 对此没有达成共识。
做什么?
词汇表可以在描述中定义其属性 should/must 具有哪些值。
词汇表Schema.org期望(并且有意不要求)特定类型。示例:
-
Values expected to be one of these types:
Boolean
词汇表vCard (as defined by the WHATWG)需要值类型。示例:
-
The value must be a valid date string.
-
The value must be one of
F
, meaning "female",M
, meaning "male",N
, meaning "none or not applicable",O
, meaning "other", orU
, meaning "unknown".
当然可以 use/create 一个微数据词汇表来对其他微数据词汇表做出这样的陈述,类似于 RDFS。 Schema.org 是 using RDFa to define their types/properties, and they also use RDFS, but instead of defining a range with rdfs:range
(which would mean that all property values are (also) of that type), they made their own property rangeIncludes
,不允许这样的推论:
<div typeof="rdf:Property" resource="http://schema.org/free"> <span class="h" property="rdfs:label">free</span> <span property="rdfs:comment">A flag to signal that the publication is accessible for free.</span> <span>Domain: <a property="http://schema.org/domainIncludes" href="http://schema.org/PublicationEvent">PublicationEvent</a></span> <span>Range: <a property="http://schema.org/rangeIncludes" href="http://schema.org/Boolean">Boolean</a></span> </div>