Is there a microdata tag to denote whether a value is a number, a string, or a bool?
There is an HTML5 attribute named datetime
which indicates that the value type is datetime. But I don't see a way to tell if the value itemprop
in the tag is a span
string, bool, or a number. Am I correct in saying that there is no such information in the microdata? If so, is there some reason why this possibility should be omitted?
source to share
Only the Microdata spec differs from these value types , which are derived from HTML5 markup:
- item (if the element has an attribute
itemprop
anditemscope
) - an absolute URL (if
itemprop
specified in a URL property element, for examplea
,video
etc.) - datetime (if
itemprop
specified in the elementtime
) - string , i.e.
- for
meta
elements: attribute valuecontent
- for
data
elements: attribute valuevalue
- for
meter
elements: attribute valuevalue
- for every other element: its textContent
- for
Whereas RDFa allows you to specify a data type with an attribute datatype
...
<span property="alive" datatype="xsd:boolean">true</span>
<!-- the value is boolean -->
... Microdata does not offer an attribute like this:
<span itemprop="alive">true</span>
<!-- no way to denote that the value is boolean -->
There was an idea to specify the datatype of Microdata properties in the vocabulary registry , but it seems there was no consensus for that.
What to do?
In their descriptions, dictionaries can be defined that must match / must have their own properties.
The Schema.org dictionary expects (and does not specifically require) certain types. Examples:
-
The expected values ββmust be one of the following types:
Boolean
The vCard dictionary (as defined by the WHATWG) requires value types. Examples:
-
The value must be a valid date string.
-
The value must be one of
F
, which means "woman",M
which means "man",N
which means "not or not applicable"O
, which means "other", orU
which means "unknown".
One could of course use / create a Microdata dictionary to make such statements about other Microdata dictionaries like RDFS. Schema.org uses RDFa to define its types / properties , and also uses RDFS, but instead of defining a range with rdfs:range
(which would mean that all property values ββare (also) of this type), they made their own property rangeIncludes
, which does not allow for 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>
source to share