There is an HTML5 attribute called datetime
that indicates that a value type is a datetime. But I see no way to indicate whether a itemprop
value in span
tag is a string, bool, or number. Am I right that there is no way to include this kind of information in microdata? If so, is there some reason why this capability should be omitted?
The Microdata specification only differs between these types of values, which get derived from the HTML5 markup:
- item (if an element has an
itemprop
and anitemscope
attribute) - absolute URL (if the
itemprop
is specified on an URL property element likea
,video
etc.) - datetime (if the
itemprop
is specified on atime
element) - string, i.e.,
- for
meta
elements: the value of thecontent
attribute - for
data
elements: the value of thevalue
attribute - for
meter
elements: the value of thevalue
attribute - for every other element: its textContent
- for
While RDFa allows to specify the datatype with its datatype
attribute …
<span property="alive" datatype="xsd:boolean">true</span>
<!-- the value is boolean -->
… Microdata doesn’t offer such an attribute:
<span itemprop="alive">true</span>
<!-- no way to denote that the value is boolean -->
There was the idea to specify the datatype of Microdata properties in the vocabulary registry, but it seems that there was no consensus for this.
What do to?
Vocabularies could define in their descriptions which values their properties should/must have.
The vocabulary Schema.org expects (and does intentionally not require) specific types. Examples:
-
Values expected to be one of these types:
Boolean
The vocabulary vCard (as defined by the WHATWG) requires values types. Examples:
-
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".
Of course one could use/create a Microdata vocabulary to make such statements about other Microdata vocabularies, similar to RDFS. Schema.org is 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
, which doesn’t allow this inference:
<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>
来源:https://stackoverflow.com/questions/27869288/is-there-a-microdata-tag-to-designate-whether-a-value-is-a-number-string-or-bo