value-class-pattern: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(→‎iCalendar generators: number items for easier reference)
(editorial: keep discouragement of colons in published tz offsets)
 
(53 intermediate revisions by 13 users not shown)
Line 1: Line 1:
<entry-title>Value Class Pattern</entry-title>
{{DISPLAYTITLE:Value Class Pattern}}


The value class pattern is derived from [[hCard#Value_excerpting|value-excerpting]] in hCard.
The '''<dfn>value class pattern</dfn>''' is a standard set of techniques to markup the value of a microformats property in part of an element, a title attribute, or across multiple elements, and how to parse & normalize those markup techniques.
 
''The editors believe the value-class-pattern to be feature complete and ready for use in markup. Implementers are encouraged to update accordingly and provide [[value-class-pattern-feedback|feedback]]. '''Note''', the precise parsing behavior could change in response to implementer feedback, but the core methods are stable. You should watch this page for updates.''
 
See also, the [http://microformats.org/blog/2009/05/12/value-class-pattern/ blog announcement].


__TOC__
; Editors
; Editors
: <span class="vcard"><span class="fn">[[User:BenWard|Ben Ward]]</span></span>
: <span class="h-card vcard"><span class="fn">[[User:BenWard|Ben Ward]]</span></span>
: <span class="vcard"><span class="fn">[[User:Tantek|Tantek Çelik]]</span></span>
: <span class="h-card vcard"><span class="fn">[[User:Tantek|Tantek Çelik]]</span></span>
; Short URL
; Short URL
: <kbd>http://tr.im/valueclass</kbd>
: <kbd>http://ufs.cc/w/vcp</kbd>
 
== Introduction ==
This section is '''informative'''.


Sometimes, only a part of an element's content is to be used as the value of a microformat property. This may occur when a property has optional subproperties, such as <code>tel: type</code> and <code>tel: value</code> in [[hCard]]. Other times, the most appropriate structure for a property may include other content.
Use the value class pattern when you need to markup:
# Only part of an element's content as the value of a property
# The displayed value written a certain way for design reasons, and a more universal value in the title attribute of an element
# Multiple elements that need to be combined to set the value of a property


For these purposes, the special class name <code>value</code> is used to mark-up the relevant data excerpt from larger element content.
For these purposes, the special class name <code>value</code> is used to mark-up the relevant data excerpt from larger element content.
==Status==
This section is '''informative'''.
The value-class-pattern is feature complete, ready for use in markup, and supported in implementations such as [[search engines]], [[parsers]], and Firefox [[Operator]]. [[H2VX]] supports parsing date and time separation but not value-title. See also the [http://microformats.org/blog/2009/05/12/value-class-pattern/ blog announcement].
The [[microformats2-parsing]] specification normatively references the value-class-pattern, and [[microformats2]] parsers implement it.


==Simple Examples==
==Simple Examples==
This section is '''informative'''.


Here is markup for a home phone number:
Here is markup for a home phone number:
Line 67: Line 76:
==Basic Parsing==
==Basic Parsing==
# The value class pattern only applies to properties which are simple strings, enumerated values, telephone numbers, and datetimes. The value class pattern does not affect parsing of properties of type email, URL, URI, UID.
# The value class pattern only applies to properties which are simple strings, enumerated values, telephone numbers, and datetimes. The value class pattern does not affect parsing of properties of type email, URL, URI, UID.
# Where an element with such a microformat property class name has a descendant with class name <code>value</code> (a "value" element), parsers should use the following portion of that element:
# Where an element with such a microformat property class name has a descendant with class name <code>value</code> (a "value element") not inside some other property element, parsers should use the following portion of that value element:  
## if the value element is an <code>img</code> or <code>area</code> element, then use the element's <code>alt</code> attribute value.
## if the value element is an <code>img</code> or <code>area</code> element, then use the element's <code>alt</code> attribute value.
## if the value element is an <code>abbr</code> element, then use the element's <code>title</code> attribute value.
## if the value element is a <code>data</code> element, then use the element's <code>value</code> attribute value if present, otherwise its inner-text.
## if the value element is an <code>abbr</code> element, then use the element's <code>title</code> attribute value if present, otherwise its inner-text.
## for any other element, use its inner-text.
## for any other element, use its inner-text.
# Where there are multiple descendants of a property with class name of <code>value</code> (multiple value elements)
# Where there are multiple descendants of a property with class name of <code>value</code> (multiple value elements)
Line 88: Line 98:


In this example, <code>description</code> has a child ‘<code>value</code>’, and that child has a ''grandchild'' ‘<code>value</code>’. However, the parsing of <code>value</code> classes stops at the first level, so the data for <code>description</code> is: <samp><code>&lt;em class="value">Puppies Rule!&lt;/em>&lt;strong>But kittens are better!&lt;/strong></code></samp>, not just <samp>Puppies Rule!</samp>.
In this example, <code>description</code> has a child ‘<code>value</code>’, and that child has a ''grandchild'' ‘<code>value</code>’. However, the parsing of <code>value</code> classes stops at the first level, so the data for <code>description</code> is: <samp><code>&lt;em class="value">Puppies Rule!&lt;/em>&lt;strong>But kittens are better!&lt;/strong></code></samp>, not just <samp>Puppies Rule!</samp>.


== Date and time values ==
== Date and time values ==
=== Summary ===
=== Summary ===
Some microformats properties expect an ISO8601 datetime value, e.g.  [[hCalendar]] <code>dtstart</code> and <code>dtend</code> or [[hAtom]] <code>published</code>.   
Some microformats properties expect an ISO8601 datetime value, e.g.  [[hCalendar]] <code>dtstart</code> and <code>dtend</code>, [[hAtom]] <code>published</code> and <code>updated</code>, and all [[microformats2]] <code>dt-*</code> properties.   


Authors may use the value class pattern to separately specify the date and the time, which are then combined to specify a single datetime value.
Authors may use the value class pattern to separately specify the date and the time, which are then combined to specify a single datetime value.


Example, this hCalendar 'dtstart' property with 'value' elements:  
Example, this hCalendar 'dtstart' property with 'value' elements:  
<source lang=xml>
<p>The weekly dinner will be on
    <span class="dtstart">
        <time class="value" datetime="2008-06-24">this Tuesday</time>
    at <time class="value">18:30</time>
    </span>
</p>
</source>
Alternatively, if you're not able to use the [[HTML5]] &lt;time&gt; element:


<source lang=html4strict>
<source lang=html4strict>
Line 106: Line 128:
</source>
</source>


produces the following 'dtstart' value:
both produce the following 'dtstart' value:


<source lang=text>
<source lang=text>
2008-06-24T18:30:00
2008-06-24 18:30
</source>
</source>


Line 118: Line 140:
</source>
</source>


The lack of a timezone indicates a "floating" datetime, that is a datetime independent of any particular timezone. Examples of floating datetimes could be an alarm clock you set to ring at 7am, or the common 9am-5pm workday.
Note: The lack of a timezone indicates a "floating" datetime, that is a datetime independent of any particular timezone. Examples of floating datetimes could be an alarm clock you set to ring at 7am, or the common 9am-5pm workday.
 
Note for iCalendar DTSTART: The implied "00" seconds here is only due to iCalendar syntax requirements, and not actually meaningful.


=== Date and time parsing ===
=== Date and time parsing ===
For all date time properties (as defined in their respective microformats specifications), the following rules apply in addition to (and in some cases replacing) the above value class pattern parsing rules.
For all date time properties (as defined in their respective microformats specifications), the following rules apply in addition to (and in some cases replacing) the above value class pattern parsing rules.


When a "value" element is found, parse a value from the element as follows:
When a "value element" is found, parse a value from the element as follows:
* if the element is an <code>img</code> or <code>area</code> element, then use the element's <code>alt</code> attribute value.
* if the element is an <code>img</code> or <code>area</code> element, then use the element's <code>alt</code> attribute value.
* if the element is an <code>abbr</code> element, then use the element's <code>title</code> attribute value.
* if the element is a <code>data</code> element, then use the element's <code>value</code> attribute value if present, otherwise its inner-text.
* if the element is an <code>abbr</code> element, then use the element's <code>title</code> attribute value if present, otherwise its inner-text.
* if the element is a <code>del</code>, <code>ins</code>, or <code>time</code> element, then use the element's <code>datetime</code> attribute value if present, otherwise its inner-text.
* for any other element, use its inner-text.
* for any other element, use its inner-text.
* if the value has both a specific ISO8601 date and a specific time, use those and stop looking for "value" elements.
* if the value has a specific ISO8601 date, time, and timezone, use those and stop looking for "value" elements.
* if the value has both a specific ISO8601 date and time, use those
** ignore any further "value" elements that specify the date or time.
* if the value has *only* a specific date, specifically, fits the following ISO8601 date patterns (i.e. as documented in the [http://en.wikipedia.org/wiki/ISO_8601 Wikipedia summary of ISO8601])
* if the value has *only* a specific date, specifically, fits the following ISO8601 date patterns (i.e. as documented in the [http://en.wikipedia.org/wiki/ISO_8601 Wikipedia summary of ISO8601])
** YYYY-MM-DD
** YYYY-MM-DD
Line 148: Line 176:
** HH is the 24 hour "hours" in the time, from 00 to 24, with optional leading 0 for values less than 10.
** HH is the 24 hour "hours" in the time, from 00 to 24, with optional leading 0 for values less than 10.
** MM are the minutes from 00 to 59
** MM are the minutes from 00 to 59
** SS are the optional seconds from 00 to 59 (60 for a leap second). If omitted, infer 00 seconds.
** SS are the optional seconds from 00 to 59 (60 for a leap second). If seconds are NOT provided, DO NOT imply 00 seconds, and instead keep the authored level of specificity.
** XX is the time zone hours offset, from 00 to 12 with optional leading 0 for values less than 10.
** XX is the time zone hours offset, from 00 to 12 with optional leading 0 for values less than 10.
** YY is the time zone minutes offset, from 00 to 59, though in practice only 00, 15, 30, 45 minute offsets are used in global timezones.
** YY is the time zone minutes offset, from 00 to 59, though in practice only 00, 15, 30, 45 minute offsets are used in global timezones.
** Z is the literal 'Z' to indicate GMT.
** Z is the literal 'Z' to indicate GMT.
** For the purposes of the value class pattern, the colons ":" separating the hour, minutes, seconds are required.  
** For the purposes of the value class pattern, the colons ":" separating the hour, minutes, seconds are required.  
** However the colons ":" separating the hours and minutes of any timezone offset are ''optional'' and discouraged in order to make it less likely that a timezone offset will be confused for a time.
** However the colons ":" separating the hours and minutes of any timezone offset are optional and discouraged. If the offset uses XX:YY format, remove the colon so it is XXYY format. Omitting the colon makes it less likely that a timezone offset will be confused for a time.
** Case insensitive { }"am"|{ }"a.m." suffix to treat an HH value of 12 as 00, or a case-insensitive { }"pm"|{ }"p.m." suffix to add 12 to HH value less than 12 - per [http://en.wikipedia.org/wiki/12-hour_clock Wikipedia article on the 12 hour clock]. Note: [[X2V]] has implemented this.
** Case insensitive { }"am"|{ }"a.m." suffix to treat an HH value of 12 as 00, or a case-insensitive { }"pm"|{ }"p.m." suffix to add 12 to HH value less than 12 - per [http://en.wikipedia.org/wiki/12-hour_clock Wikipedia article on the 12 hour clock]. Note: [[X2V]] has implemented this.
*** HH:MM:SSam
*** HH:MM:SSam
Line 163: Line 191:
*** where "am" and "pm" mean "am or a.m." and "pm or p.m."  
*** where "am" and "pm" mean "am or a.m." and "pm or p.m."  
*** when MM is omitted, infer 00 minutes.
*** when MM is omitted, infer 00 minutes.
*** when SS is omitted, DO NOT infer 00 seconds. Instead, keep the authored level of specificity.
** ignore any further "value" elements that specify the time.
** ignore any further "value" elements that specify the time.
* if the value has *only* a specific timezone, parse it for a time zone value that can match any of the following:
* if the value has *only* a specific timezone, parse it for a time zone value that can match any of the following:
Line 177: Line 206:
** ignore any further "value" elements that specify the timezone.
** ignore any further "value" elements that specify the timezone.


If by parsing the "value" element(s), at least a specific date has been found, then the "value" is overall valid, and the parser assembles the overall datetime value by concatenating the specific date, "T" and specific time (if time was specified, with 00 seconds implied if no seconds are provided), and specific timezone (if timezone and a specific time was specified).
If by parsing the "value" element(s), at least a specific date has been found, then the "value" is overall valid, and the parser assembles the overall datetime value by concatenating the specific date ([https://github.com/microformats/microformats2-parsing/issues/27#issuecomment-376004491 PROPOSED]: normalized to YYYY-MM-DD), " " (space character) and specific time (if time was specified, with 00 minutes implied if no minutes are provided), and specific timezone (if timezone and a specific time was specified).
* YYYY-MM-DD - no time specified
* YYYY-MM-DD - no time specified
* YYYY-MM-DDTHH:MM:SS - time specified but no timezone.  This is a floating time.
* YYYY-MM-DD HH:MM or YYYY-MM-DD HH:MM:SS - time specified but no timezone.  This is a floating time.
* YYYY-MM-DDTHH:MM:SS-XXYY or
* YYYY-MM-DD HH:MMZ or YYYY-MM-DD HH:MM:SSZ or
* YYYY-MM-DDTHH:MM:SSZ or
* YYYY-MM-DD HH:MM-XXYY or YYYY-MM-DD HH:MM:SS-XXYY or
* YYYY-MM-DDTHH:MM:SS+XXYY - both time and timezone were specified.
* YYYY-MM-DD HH:MM+XXYY or YYYY-MM-DD HH:MM:SS+XXYY - both time and timezone offset were specified.


=== format specific details ===
=== format specific details ===
Line 188: Line 217:


;<span style="font-size:smaller">short URL for this section</span>
;<span style="font-size:smaller">short URL for this section</span>
:http://tr.im/vcpfso
:http://ufs.cc/w/vcpfso


==== hCalendar dtend implied date ====
==== hCalendar dtend implied date ====
Line 194: Line 223:


Thus it would be convenient if we could imply an [[hCalendar]] event "dtend" date from its "dtstart" date when only the time (and optionally timezone) was specified for its "dtend", e.g.:
Thus it would be convenient if we could imply an [[hCalendar]] event "dtend" date from its "dtstart" date when only the time (and optionally timezone) was specified for its "dtend", e.g.:
<source lang=xml>
<span class="vevent">
The <span class="summary">party</span> will be on
<span class="dtstart">
  <time class="value">2009-06-26</time>, from
  <time class="value">19:00</time></span> to
<span class="dtend"><time class="value">22:00</time></span>.
</span>
</source>
and in HTML4/XHTML1:


<source lang=html4strict>
<source lang=html4strict>
Line 206: Line 247:


To simplify this further for authors, hCalendar processors could treat the specifying of just the time per the value-class-pattern date and time value rules, and thus eliminate the need for the "value" span inside the "dtend" span:
To simplify this further for authors, hCalendar processors could treat the specifying of just the time per the value-class-pattern date and time value rules, and thus eliminate the need for the "value" span inside the "dtend" span:
<source lang=xml>
<span class="vevent">
The <span class="summary">party</span> will be on
<span class="dtstart">
  <time class="value">2009-06-26</time>, from
  <time class="value">19:00</time></span> to
<time class="dtend">22:00</time>.
</span>
</source>
and in HTML4/XHTML1:


<source lang=html4strict>
<source lang=html4strict>
Line 217: Line 270:
</source>
</source>


hCalendar to iCalendar converters should produce the following iCalendar fragment (as part of a valid .ics file) from either of the above two examples:
hCalendar to iCalendar converters should produce the following iCalendar fragment (as part of a valid .ics file) from all of the above four examples:


<source lang=text>
<source lang=text>
Line 227: Line 280:
</source>
</source>


Note: [[X2V]] has implemented dtend implied date from dtstart.
Note that the implied "00" seconds here is only due to iCalendar syntax requirements, and not actually meaningful.
 
Implementations:  
* [[X2V]] has implemented dtend implied date from dtstart.


Examples "in the wild":
Examples "in the wild":
Line 237: Line 293:
# remove any colon ":" separators in the time.
# remove any colon ":" separators in the time.
# add a whole day to any date-only (lacking a specified time) (date inclusive) hCalendar <code>dtend</code> property values in order to generate an (date exclusive) iCalendar <code>DTEND</code> property value with the same meaning, per the resolution to the [[dtend-issue]].
# add a whole day to any date-only (lacking a specified time) (date inclusive) hCalendar <code>dtend</code> property values in order to generate an (date exclusive) iCalendar <code>DTEND</code> property value with the same meaning, per the resolution to the [[dtend-issue]].
# imply 00 seconds if seconds are omitted due to iCalendar artificial precision syntax requirements
# perform datetime math on any +/- relative timezone value, and produce an effective UTC value ending with "Z".
# perform datetime math on any +/- relative timezone value, and produce an effective UTC value ending with "Z".


Line 243: Line 300:


Thus it would be convenient if we could imply an [[hAtom]] entry "updated" date from its "published" date when only the time (and optionally timezone) was specified for its "updated", e.g. for a blog post that was updated the same day:
Thus it would be convenient if we could imply an [[hAtom]] entry "updated" date from its "published" date when only the time (and optionally timezone) was specified for its "updated", e.g. for a blog post that was updated the same day:
<source lang=xml>
<span class="hentry">
<span class="entry-summary">short blog post example</span>
was published on <span class="published">
  <time class="value">2009-08-01</time> at <time class="value">12:06</time></span>
and updated at <span class="updated"><time class="value">12:10</time></span>.
</span>
</source>
and in HTML4/XHTML1:


<source lang=html4strict>
<source lang=html4strict>
Line 254: Line 322:


To simplify this further for authors, hAtom processors could treat the specifying of just the time per the value-class-pattern date and time value rules, and thus eliminate the need for the "value" span inside the "updated" span:
To simplify this further for authors, hAtom processors could treat the specifying of just the time per the value-class-pattern date and time value rules, and thus eliminate the need for the "value" span inside the "updated" span:
<source lang=xml>
<span class="hentry">
<span class="entry-summary">short blog post example</span>
was published on <span class="published">
  <time class="value">2009-08-01</time> at <time class="value">12:06</time></span>
and updated at <time class="updated">12:10</time>.
</span>
</source>
and in HTML4/XHTML1:


<source lang=html4strict>
<source lang=html4strict>
Line 267: Line 346:
microformats implementations which consume [[hAtom]] and generate  
microformats implementations which consume [[hAtom]] and generate  
Atom {{must}} in addition:
Atom {{must}} in addition:
* normalize all date and datetime values to [[RFC3339]].
* normalize all date and datetime values to [[RFC3339]], including:
** imply 00 seconds if seconds are omitted due to Atom artificial precision syntax requirements
 
==== microformats2 parsers implied date ====
Since <span id="microformats2 parsers">[[microformats2#parsers|microformats2 parsers]]</span> are generic, instead of checking for specific properties (as above for hAtom and hCalendar), they must perform the following algorithm to imply dates for dt-* properties:
 
* if a dt-* property has a time but lacks a date
* then it adopts the date of the most recently seen dt-* property with a date in that microformat.
** if no previous dt-* properties have a date,
** then it adopts its date from the next dt-* property with a date seen in that microformat.
** otherwise it simply has a time (and no date).
 
Note: This results in a similar enough implementation/interpretation as the previous vocabulary dependent heuristics for hAtom and hCalendar that a microformats2 parser can produce similar results for h-entry and h-event without having to know about their specific dt-* properties.


=== derivation and tests ===
=== derivation and tests ===
Line 277: Line 368:


==Parsing value from a <code>title</code> attribute==
==Parsing value from a <code>title</code> attribute==
{{warning|you should use the HTML5 <code>&lt;data&gt;</code> element instead of the <code>value-title</code> class name, in particular, use: <source lang=html4strict><data class='dt-start' value='2008'>last year</data></source> instead of <source lang=html4strict><span class='dt-start'><span class='value-title' title='2008'>last year</span></span></source> The <code>value-title</code> feature is under consideration for deprecation.}}
The <code>value-title</code> class name allows the publisher to indicate the data value for a parent property is contained in the <code>title</code> attribute of an element, rather than the inner-text.
The <code>value-title</code> class name allows the publisher to indicate the data value for a parent property is contained in the <code>title</code> attribute of an element, rather than the inner-text.


Line 300: Line 393:
The initial usage of <code>value-title</code> is used to publish alternate, parsable forms of property values in a visible context without the use of the <code>abbr</code> element whose semantics already support interpretation of the 'title' attribute as an expanded, more precise form of the content.  
The initial usage of <code>value-title</code> is used to publish alternate, parsable forms of property values in a visible context without the use of the <code>abbr</code> element whose semantics already support interpretation of the 'title' attribute as an expanded, more precise form of the content.  


Experience has found that there are some cases in microformats where a number of publishers want to include a precisely accurate and parsable value for a property but do not want it to be visible in their page, even as a tooltip.
Experience has found that there are some cases in microformats where a number of publishers want to include a precisely accurate and parsable value for a property but do not want it to be visible in their page, ''even as a tooltip''.


For example, full [[ISO8601]] datetimes may be confusing to readers of the page (as a tooltip or when read aloud by a screen reader), and enumerated values such as the <code>type</code> subproperty of hCard's <code>tel</code> property use US-English terms, which are not part of pages in any other language.
For example, full [[ISO8601]] datetimes may be confusing to readers of the page (as a tooltip or when read aloud by a screen reader), and enumerated values such as the <code>type</code> subproperty of hCard's <code>tel</code> property use US-English terms, which are not part of pages in any other language.


Since both of those scenarios have shown to be obstacles for a number of publishers, for these cases, and these alone, there exists a further extension of value-excerption. This extension allows the parsable form of the property to be published ‘silently’ immediately adjacent with the respective local visible content.
Since both of those scenarios have shown to be obstacles for a number of publishers, for these cases, and these alone, there exists a further extension of value-excerption. This extension allows the parsable form of the property to be published ‘silently’ in an ''empty'' element immediately adjacent with the respective local visible content.


Here is an example, with the required use of a first child element with class name <code>value-title</code>:
Here is an example, with the required use of a first child element with class name <code>value-title</code>:
Line 312: Line 405:
   <span class='type'>
   <span class='type'>
     <span class='value-title' title='cell'> </span>
     <span class='value-title' title='cell'> </span>
      mobile
    mobile
    </span>
  </span>
   <span class='value'>+44 7773 000 000</span>
   <span class='value'>+44 7773 000 000</span>
</p>
</p>
</source>
</source>
'''Note:''' the <code>&lt;span class='value-title' title='cell'> &lt;/span></code> span is deliberately empty (just has a space between the open and close tags) so that it doesn't take up any space and therefore can't show a tooltip.


The <samp>cell</samp> value is parsed for the 'type' subproperty, but <samp>mobile</samp> is presented to the user.
The <samp>cell</samp> value is parsed for the 'type' subproperty, but <samp>mobile</samp> is presented to the user.
Line 337: Line 432:
We conducted [[value-excerption-value-title-test|thorough testing]] of these parsing behaviors to ensure accessibility.
We conducted [[value-excerption-value-title-test|thorough testing]] of these parsing behaviors to ensure accessibility.


''Note: Whilst the <code>value-title</code> element is more gracefully written without whitespace inner-text (or as self-closing <code>&lt;foo /></code> element in XHTML), current tools such as WYSIWYG editors and HTML-Tidy will erroneously discard such elements, resulting in parsable data being thrown away by some tools. As such, <code>&lt;span class='value-title'> &lt;/span></code>, including a single whitespace character between the opening and closing tag, is the required pattern for authors, at this time.''
''Note: Whilst the <code>value-title</code> element is more gracefully written without whitespace inner-text (or as self-closing <code>&lt;foo /></code> element in XHTML), some tools such as WYSIWYG editors and HTML-Tidy will erroneously discard such elements, resulting in parsable data being thrown away by some tools. As such, <code>&lt;span class='value-title'> &lt;/span></code>, including a single whitespace character between the opening and closing tag, may also be used. In some situations, this whitespace may be rendered by the browser, and authors should test their output.''


Parsing this final <code>value-title</code> extension imposes some stricter restrictions on usage. These restrictions exist to reduce the impact of <abbr title="Don't Repeat Yourself">DRY</abbr> violations, reduce the opportunity for sites to spoof data, and encourage best practice for maintaining both forms of data accurately.
Parsing this final <code>value-title</code> extension imposes some stricter restrictions on usage. These restrictions exist to reduce the impact of <abbr title="Don't Repeat Yourself">DRY</abbr> violations, reduce the opportunity for sites to spoof data, and encourage best practice for maintaining both forms of data accurately.
Line 344: Line 439:


* The ‘empty’ value-title element must be the '''first, non-whitespace child''' of the property element. That is, it should follow immediately after the property is declared, before the human-readable form, and without any additional nesting.
* The ‘empty’ value-title element must be the '''first, non-whitespace child''' of the property element. That is, it should follow immediately after the property is declared, before the human-readable form, and without any additional nesting.
* The ‘empty’ value-title element can only be used for specific properties. Microformat specifications must explicitly state which properties may be used with this extension of the value-class-pattern.
* The ‘empty’ value-title element can only be used for specific properties. Future microformat specifications (and updates to existing microformats) must explicitly state which properties may be used with this extension of the value-class-pattern. (Retroactive property support for existing microformats is documented below.)
* Where an ‘empty’ value-title element is to be used as the single property value, it must be the ''only'' such <code>value</code> content. That is, the first instance of a conforming <code>value-title</code> element overrides all other <code>value</code> and <code>value-title</code> siblings and/or cousins.
* Where an ‘empty’ value-title element is to be used as the single property value, it must be the ''only'' such <code>value</code> content. That is, the first instance of a conforming <code>value-title</code> element overrides all other <code>value</code> and <code>value-title</code> siblings and/or cousins.
* Tools written to perform Conformance Testing and/or Validation of microformats ''should'' attempt to compare the machine-data and human legible forms of the property data, and advise authors if the forms do not match.
* Tools written to perform Conformance Testing and/or Validation of microformats ''should'' attempt to compare the machine-data and human-legible forms of the property data, and warn authors if the forms do not match.


=== limited use of value-title ===
=== limited use of value-title ===
{{warning|This issue applies to the preferred <code>&lt;data&gt;</code> element too.}}
Due to the fact that the value-title pattern hides some amount of data which tends to be a machine-specific duplicate of data that is provided in the human readable content, there are two microformats [[principles]] being compromised: '''visibility''' and '''<abbr title="Don't Repeat Yourself">DRY</abbr>'''. Thus the applicability of this pattern is deliberately restricted to properties that have demonstrated through experience a need for it, with no known better alternative.
Due to the fact that the value-title pattern hides some amount of data which tends to be a machine-specific duplicate of data that is provided in the human readable content, there are two microformats [[principles]] being compromised: '''visibility''' and '''<abbr title="Don't Repeat Yourself">DRY</abbr>'''. Thus the applicability of this pattern is deliberately restricted to properties that have demonstrated through experience a need for it, with no known better alternative.


Line 356: Line 453:
# Then consider using the value-class pattern
# Then consider using the value-class pattern
## Including multiple value elements for date and time properties
## Including multiple value elements for date and time properties
# and then only if those methods are insufficient, consider the value-title pattern.
# and then only if those methods are insufficient, consider the value-title pattern (or rather, the <code>&lt;data&gt;</code> element).


This document post-dates other microformat specifications, such that they may not yet indicate which properties permit use of this pattern. In the interim, '''only''' the following types of properties should allow the value-title pattern.
This document post-dates other microformat specifications, such that they may not yet indicate which properties permit use of this pattern. In the interim, '''only''' the following types of properties should allow the value-title pattern.
Line 368: Line 465:


There are some simple reference examples and tests for this pattern on [[value-class-pattern-tests]].
There are some simple reference examples and tests for this pattern on [[value-class-pattern-tests]].
* Note: [[value-class-pattern-tests#to_do_value-title_test_pages|to do value-title test pages]]


In future use, ''specification authors'' may inherit use of <code>value-title</code> by use of ISO8601 date and time formats, or reuse of other microformats, but specifications should _avoid_ introducing new data structures that depend on or encourage this pattern. New specifications are themselves expected to adhere to the principals of visible data and <abbr>DRY</abbr>.
In future use, ''specification authors'' may inherit use of <code>value-title</code> by use of ISO8601 date and time formats, or reuse of other microformats, but specifications should _avoid_ introducing new data structures that depend on or encourage this pattern. New specifications are themselves expected to adhere to the principals of visible data and <abbr>DRY</abbr>.
=== H2VX workaround ===
[[H2VX]] does not yet support the 'value-title' feature of the value class pattern (still waiting for proper [[value-class-pattern-tests#to_do_value-title_test_pages|value-title tests on separate live pages]]). Thus if your page depends on H2VX, you should use the following techniques instead (from [[pbworks]] documentation)
E.g. if the value to be placed in the value-title is both human and machine readable, instead of:
<source lang=html4strict><span class="p-rsvp"><span class="value-title" title="yes">going</span></span></source>
Use an abbr (ok only if the value is human readable/listenable)
<source lang=html4strict><abbr class="p-rsvp" title="yes">going</abbr></source>
Otherwise if the value is only machine readable, or human-unfriendly, instead of the empty span technique:
<source lang=html4strict><span class="p-rsvp"><span class="value-title" title="yes"> </span> going</span></source>
Use an empty abbr:
<source lang=html4strict><abbr class="p-rsvp" title="yes"></abbr> going</source>


== Test cases ==
== Test cases ==
Line 380: Line 491:


<div class='discussion'>
<div class='discussion'>
* '''Is the value-class pattern supported by any of the microformats tools?'''
** '''A: Yes'''. See the [[value-class-pattern#Implementations|implementations]] section.
* '''Why use an 'empty' element? Why not embed data in the class attribute?'''
* '''Why use an 'empty' element? Why not embed data in the class attribute?'''
** The class attribute is inappropriate for embedded data values, as per the HTML4 specification, which states <code>class</code> is for ‘general purposing processing’, which is defined as ‘e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.’. ‘General purpose processing’ does not extend to data itself. Furthermore, this method avoids inventing a new string pattern for embedding data.
** '''A: 'class' is for field names, not data.''' The class attribute is inappropriate for embedded data values, as per the HTML4 specification, which states <code>class</code> is for ‘general purposing processing’, which is defined as ‘e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.’. ‘General purpose processing’ does not extend to data itself. Furthermore, this method avoids inventing a new string pattern for embedding data.
* '''Why use an 'empty' element? Why not make up a new attribute, like ‘data’?'''
* '''Why use an 'empty' element? Why not make up a new attribute, like ‘data’?'''
** Microformats exist and function in ''valid'' HTML4 and XHTML1. Those are the current standards for web development, and microformats exist for use ''now''. In the future, perhaps revisions of HTML will offer up another solution. For now, this method has been tested against browsers, and creates a consistent document structure (where machine-form and human-form data are siblings).
** '''A: New attributes are invalid.''' Microformats exist and function in ''valid'' HTML. Those are the current standards for web development, and microformats exist for use ''now''. In the future, perhaps revisions of HTML will offer up another solution. For now, this method has been tested against browsers, and creates a consistent document structure (where machine-form and human-form data are siblings).
* '''The <code>title</code> attribute should only be used for content!'''
* '''Shouldn't the <code>title</code> attribute only be used for content?'''
** The <code>title</code> attribute ''is'' used for content and is read by microformats parsers. This exists for cases where data cannot be parsed with sufficient precision from just the commonly published, visible information. This pattern allows both forms of content to be included, whilst keeping it invisible to human consumers.
** '''A: 'title' is used for content, machine readable content.''' The <code>title</code> attribute ''is'' used for content and is read by microformats parsers. This exists for cases where data cannot be parsed with sufficient precision from just the commonly published, visible information. This pattern allows both forms of content to be included, whilst keeping it invisible to human consumers.
* '''How should microformats2 parsers handle improperly nested value-class-patterns inside p- properties?''' *:Consider the following markup.
<source lang="html4strict">
<div class="h-card">
  <div class="p-tel">
    <span class="value">0123456789</span>
    <div class="h-card">
      <div cass="p-tel">
        <span class="value">9876543210<span>
      </div>
    </div>
  </div>
</div>
</source>
*:Why might someone write some markup like this? Ask a consulting psychologist. WordPress template authors, the sort of people enamoured with trendy CSS frameworks and so on—there's plenty of scope for crappy markup. The value-class-pattern spec as currently written (specficially §4 of [[value-class-pattern#Basic parsing|Basic parsing]]) instructs implementers to not handle ''nested'' elements with class <kbd>value</kbd>, but in the context of a microformats2 parser, it would seem reasonable for an implementer to assume that the author here did ''not'' intend to make the text content of the second microformats2 object instance part of the value of the first. The question then is what to do with this kind of markup (other than find the author and ask him or her to kindly rewrite it). —[[User:TomMorris|Tom Morris]] 20:02, 7 November 2013 (UTC)
 
</div>
</div>


Line 399: Line 527:


-->
-->
* [http://tantek.com Tantek's site] uses date and time value separation with nested [[HTML5]] &lt;time&gt; elements for the separate date and time values in his hAtom "dtpublished" properties.
* [http://visitmix.com/labs/oomph/2.0/tests/test.html Test Harness For Oomph] This pages uses a whole range of different patterns for both hCard and hCalendar, using both value and value-title, mostly derived from the specification above
* [http://visitmix.com/labs/oomph/2.0/tests/test.html Test Harness For Oomph] This pages uses a whole range of different patterns for both hCard and hCalendar, using both value and value-title, mostly derived from the specification above
* [http://georgebrock.com/ George Brocklehurst's activity stream] and [http://blog.georgebrock.com/ blog] use "value-title" for hAtom <code>published</code> property
* [http://georgebrock.com/ George Brocklehurst's activity stream] and [http://blog.georgebrock.com/ blog] use "value-title" for hAtom <code>published</code> property
Line 405: Line 534:
** "value-title" for hAtom <code>updated</code> property
** "value-title" for hAtom <code>updated</code> property
* [http://microformats.org/ microformats.org] uses:
* [http://microformats.org/ microformats.org] uses:
** "value-title" for hAtom <code>updated</code> property in [[http://microformats.org/ microformats.org blog postss]]]
** "value-title" for hAtom <code>updated</code> property in [http://microformats.org/ microformats.org blog posts]
** date and time value separation for hCalendar <code>dtstart</code> property in [[events|microformats.org recent and upcoming events wiki page]]
** date and time value separation for hCalendar <code>dtstart</code> property in [[events|microformats.org recent and upcoming events wiki page]]


Line 411: Line 540:


== Implementations ==
== Implementations ==
This section is '''informative'''.
This section is '''informative'''.


Line 420: Line 548:


-->
-->
=== consuming and parsing tools ===
* [[Google]] parses <code>value-title</code> as part of their [http://googlewebmastercentral.blogspot.com/2010/01/introducing-new-rich-snippets-format.html support for hCalendar rich snippets], as documented specifically in the [https://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=164506 microformats example for rich snippet events].
* [[Oomph]] Version 2 passes [[value-class-pattern-tests#Date_and_time_values|Date and time values test cases]] and is a thorough implementation of the value class pattern.
* [[Oomph]] Version 2 passes [[value-class-pattern-tests#Date_and_time_values|Date and time values test cases]] and is a thorough implementation of the value class pattern.
* [[X2V]] v0.9.3 and later:
* [[X2V]] v0.9.3 and later:
Line 427: Line 558:
* [[Operator]] has *some* implementation of the value-class-pattern according to Michael Kaply, but precisely how much is implemented, for which properties (property types) and which microformats is not currently known.
* [[Operator]] has *some* implementation of the value-class-pattern according to Michael Kaply, but precisely how much is implemented, for which properties (property types) and which microformats is not currently known.
* [[Optimus]] v0.8 and later implements <code>value-title</code> as [http://twitter.com/DmitryBaranovsk/status/1891253248 announced by Dmitry Baranovskiy].
* [[Optimus]] v0.8 and later implements <code>value-title</code> as [http://twitter.com/DmitryBaranovsk/status/1891253248 announced by Dmitry Baranovskiy].
* ... add your implementation(s) that parse or generate the value-class-pattern here, along with which features you support (hopefully all!) and note any limitations if any.
* HTML::Microformats and its predecessors support <code>value</code> excerpting. HTML::Microformats (though not its predecessors) supports <code>value-title</code>.
 
=== publishing tools ===
* [http://getk2.com/ K2] (WordPress Theme) is using "value-title" for the hAtom published property. [http://code.google.com/p/kaytwo/issues/detail?id=832]
 
== Background ==
This section is '''informative'''.
 
The value class pattern is derived from [[hCard#Value_excerpting|value-excerpting]] in hCard.
 
Sometimes, only a part of an element's content is to be used as the value of a microformat property. This may occur when a property has optional subproperties, such as <code>tel: type</code> and <code>tel: value</code> in [[hCard]]. Other times, the most appropriate structure for a property may include other content.


== Articles ==
== Articles ==
This section is '''informative'''.
Articles and <span id="Blog_Posts">blog posts</span>  discussing the value class pattern, most recent first.
Articles and <span id="Blog_Posts">blog posts</span>  discussing the value class pattern, most recent first.
When this section gets too big, create a separate page like: [[value-class-pattern-articles]]
When this section gets too big, create a separate page like: [[value-class-pattern-articles]]
* <span class="hentry"><span class="published">2009-08-25</span> <span class="entry-summary">MIX Online: <span class="entry-title">[http://visitmix.com/Articles/The-Value-Class-Pattern The Value Class Pattern]</span></span> by <span class="author vcard"><span class="fn">Jeremy Keith</span></span></span>
* <span class="hentry"><span class="published">2009-08-25</span> <span class="entry-summary">MIX Online: <span class="entry-title">[http://visitmix.com/Articles/The-Value-Class-Pattern The Value Class Pattern]</span></span> by <span class="author vcard"><span class="fn">Jeremy Keith</span></span></span>
* [http://ablognotlimited.com/s/106 Getting Semantic With Microformats, Part 8: Value Class Pattern] -- A very thorough writeup by Emily Lewis on the value class pattern
* [http://ablognotlimited.com/articles/getting-semantic-with-microformats-part-8-value-class-pattern Getting Semantic With Microformats, Part 8: Value Class Pattern] -- A very thorough writeup by Emily Lewis on the value class pattern
* [http://adactio.com/journal/1579/ 2009-05-17 Adactio: Microformation]
* [http://adactio.com/journal/1579/ 2009-05-17 Adactio: Microformation]
* [http://forabeautifulweb.com/blog/about/value_class_pattern/ For A Beautiful Web: Value Class Pattern]
* [http://forabeautifulweb.com/blog/about/value_class_pattern/ For A Beautiful Web: Value Class Pattern]
* <span class="hentry"><span class="published">2009-05-12</span> <span class="entry-title">notizblog.org: [http://notizblog.org/2009/05/12/microformats-value-class-pattern/ Microformats: Value Class Pattern]</span> by <span class="author vcard"><span class="fn">Matthias Pfefferle</span></span></span> (german)
* [http://microformats.org/blog/2009/05/12/value-class-pattern/ 2009-05-12 microformats.org: Value Class Pattern]
* [http://microformats.org/blog/2009/05/12/value-class-pattern/ 2009-05-12 microformats.org: Value Class Pattern]
== References ==
This section is '''informative'''.
* [http://www.useit.com/alertbox/9608.html Jakob Nielsen: International Web Usability]


==Related Pages==
==Related Pages==
Line 444: Line 592:
* [[value-excerption-pattern-issues]]
* [[value-excerption-pattern-issues]]
* [[hcard#Value_excerpting|hCard: Value Excepting]]
* [[hcard#Value_excerpting|hCard: Value Excepting]]
* [[value-class-pattern-brainstorming]]
* [[value-excerption-pattern-brainstorming]]
* [[value-excerption-pattern-brainstorming]]
* [[machine-data|Machine Data in Microformats]]
* [[machine-data|Machine Data in Microformats]]


== References ==
== Translations ==
This section is '''informative'''.
This section is '''informative'''.
* [http://www.useit.com/alertbox/9608.html Jakob Nielsen: International Web Usability]
 
Read the value-class-pattern specification in additional <span id="languages">languages</span>:
* [[value-class-pattern-fr|français]]
* [[value-class-pattern-ja|日本語]]
 
[[Category:Draft Specifications]]

Latest revision as of 03:04, 25 June 2022


The value class pattern is a standard set of techniques to markup the value of a microformats property in part of an element, a title attribute, or across multiple elements, and how to parse & normalize those markup techniques.

Editors
Ben Ward
Tantek Çelik
Short URL
http://ufs.cc/w/vcp

Introduction

This section is informative.

Use the value class pattern when you need to markup:

  1. Only part of an element's content as the value of a property
  2. The displayed value written a certain way for design reasons, and a more universal value in the title attribute of an element
  3. Multiple elements that need to be combined to set the value of a property

For these purposes, the special class name value is used to mark-up the relevant data excerpt from larger element content.

Status

This section is informative.

The value-class-pattern is feature complete, ready for use in markup, and supported in implementations such as search engines, parsers, and Firefox Operator. H2VX supports parsing date and time separation but not value-title. See also the blog announcement.

The microformats2-parsing specification normatively references the value-class-pattern, and microformats2 parsers implement it.

Simple Examples

This section is informative.

Here is markup for a home phone number:

vCard fragment:

TEL;TYPE=HOME:+1.415.555.1212

hCard fragment:

<span class="tel">
  <span class="type">Home</span>:
  <span class="value">+1.415.555.1212</span>
</span>

In this case, the value of tel is +1.415.555.1212, not Home: +1.415.555.1212.

Sometimes the value for a microformats property must be split into multiple pieces in the content of the element representing that property. Multiple elements with a class name of "value" (value elements) can be used to extract and concatenate these pieces into a single value for microformats properties which expect simple strings or tel values.

Another example, this time using a localized (British) telephone number:

<span class="tel">
  <span class="type">Home</span>:
  <span class="value">+44</span> (0) <span class="value">1223 123 123</span>
</span>

In this case, the valid data for the telephone number is +441223123123, but the way in which phone number is presented in Britain will include the (0), for local dialling. That is, from anywhere in the world you may dial +441223123123, or from within Britain you may dial 01223123123. Common local publishing interferes with the data, since dialling +4401223123123 is an invalid number.

In the mark-up, two value classes target the part of the telephone number string that makes an international, valid number, whilst allowing conventional presentation.

Another example, adding a place name to a geo co-ordinate:

<p>I'm loitering outside The Bricklayer's Arms
  <span class="geo">
    51° 30' 48.45", -0° 8' 53.23"
    (<span class="value">51.513458;-0.14812</span>)
  </span>
</p>

Whilst the entire string is a geo point, it's only the decimal encoded co-ordinates which must be consumed by a microformats parser, so the value class isolates it from the degrees form, which the publisher includes for completeness.

Basic Parsing

  1. The value class pattern only applies to properties which are simple strings, enumerated values, telephone numbers, and datetimes. The value class pattern does not affect parsing of properties of type email, URL, URI, UID.
  2. Where an element with such a microformat property class name has a descendant with class name value (a "value element") not inside some other property element, parsers should use the following portion of that value element:
    1. if the value element is an img or area element, then use the element's alt attribute value.
    2. if the value element is a data element, then use the element's value attribute value if present, otherwise its inner-text.
    3. if the value element is an abbr element, then use the element's title attribute value if present, otherwise its inner-text.
    4. for any other element, use its inner-text.
  3. Where there are multiple descendants of a property with class name of value (multiple value elements)
    1. if the microformats property expects a simple string, enumerated value, or telephone number, then the values extracted from the value elements should be concatenated without inserting additional characters or white-space.
    2. if the microformats property expects a datetime value, see the Date Time Parsing section.
  4. Descendants with class of value must not be parsed deeper than one level. That is, where an element foo with class value has a descendant bar with class value, the content of foo is taken as the value. Nesting additional elements with class of value cannot be used to further isolate a property's value.

e.g.

 <p class="description">
  <span class="value">
    <em class="value">Puppies Rule!</em>
    <strong>But kittens are better!</strong>
 </span>
</p>

In this example, description has a child ‘value’, and that child has a grandchildvalue’. However, the parsing of value classes stops at the first level, so the data for description is: <em class="value">Puppies Rule!</em><strong>But kittens are better!</strong>, not just Puppies Rule!.


Date and time values

Summary

Some microformats properties expect an ISO8601 datetime value, e.g. hCalendar dtstart and dtend, hAtom published and updated, and all microformats2 dt-* properties.

Authors may use the value class pattern to separately specify the date and the time, which are then combined to specify a single datetime value.

Example, this hCalendar 'dtstart' property with 'value' elements:

<p>The weekly dinner will be on 
    <span class="dtstart">
        <time class="value" datetime="2008-06-24">this Tuesday</time> 
     at <time class="value">18:30</time>
    </span>
</p>

Alternatively, if you're not able to use the HTML5 <time> element:

<p>The weekly dinner will be on 
    <span class="dtstart">
        <abbr class="value" title="2008-06-24">this Tuesday</abbr> 
     at <span class="value">18:30</span>
    </span>
</p>

both produce the following 'dtstart' value:

2008-06-24 18:30

and iCalendar converters produce the following DTSTART:

DTSTART:20080624T183000

Note: The lack of a timezone indicates a "floating" datetime, that is a datetime independent of any particular timezone. Examples of floating datetimes could be an alarm clock you set to ring at 7am, or the common 9am-5pm workday.

Note for iCalendar DTSTART: The implied "00" seconds here is only due to iCalendar syntax requirements, and not actually meaningful.

Date and time parsing

For all date time properties (as defined in their respective microformats specifications), the following rules apply in addition to (and in some cases replacing) the above value class pattern parsing rules.

When a "value element" is found, parse a value from the element as follows:

  • if the element is an img or area element, then use the element's alt attribute value.
  • if the element is a data element, then use the element's value attribute value if present, otherwise its inner-text.
  • if the element is an abbr element, then use the element's title attribute value if present, otherwise its inner-text.
  • if the element is a del, ins, or time element, then use the element's datetime attribute value if present, otherwise its inner-text.
  • for any other element, use its inner-text.
  • if the value has a specific ISO8601 date, time, and timezone, use those and stop looking for "value" elements.
  • if the value has both a specific ISO8601 date and time, use those
    • ignore any further "value" elements that specify the date or time.
  • if the value has *only* a specific date, specifically, fits the following ISO8601 date patterns (i.e. as documented in the Wikipedia summary of ISO8601)
    • YYYY-MM-DD
    • YYYY-DDD
    • then use that as the date value. For the purposes of the value class pattern, the hyphens "-" separating the year, month, day and/or ordinal day are required.
    • ignore any further "value" elements that specify the date.
  • if the value has *only* a specific time (with or without timezone), parse it for a time value that can match any of the following:
    • HH:MM:SS-XX:YY
    • HH:MM:SS+XX:YY
    • HH:MM:SS-XXYY
    • HH:MM:SS+XXYY
    • HH:MM:SSZ
    • HH:MM:SS
    • HH:MM-XX:YY
    • HH:MM+XX:YY
    • HH:MM-XXYY
    • HH:MM+XXYY
    • HH:MMZ
    • HH:MM
    • HH is the 24 hour "hours" in the time, from 00 to 24, with optional leading 0 for values less than 10.
    • MM are the minutes from 00 to 59
    • SS are the optional seconds from 00 to 59 (60 for a leap second). If seconds are NOT provided, DO NOT imply 00 seconds, and instead keep the authored level of specificity.
    • XX is the time zone hours offset, from 00 to 12 with optional leading 0 for values less than 10.
    • YY is the time zone minutes offset, from 00 to 59, though in practice only 00, 15, 30, 45 minute offsets are used in global timezones.
    • Z is the literal 'Z' to indicate GMT.
    • For the purposes of the value class pattern, the colons ":" separating the hour, minutes, seconds are required.
    • However the colons ":" separating the hours and minutes of any timezone offset are optional and discouraged. If the offset uses XX:YY format, remove the colon so it is XXYY format. Omitting the colon makes it less likely that a timezone offset will be confused for a time.
    • Case insensitive { }"am"|{ }"a.m." suffix to treat an HH value of 12 as 00, or a case-insensitive { }"pm"|{ }"p.m." suffix to add 12 to HH value less than 12 - per Wikipedia article on the 12 hour clock. Note: X2V has implemented this.
      • HH:MM:SSam
      • HH:MM:SSpm
      • HH:MMam
      • HH:MMpm
      • HHam
      • HHpm
      • where "am" and "pm" mean "am or a.m." and "pm or p.m."
      • when MM is omitted, infer 00 minutes.
      • when SS is omitted, DO NOT infer 00 seconds. Instead, keep the authored level of specificity.
    • ignore any further "value" elements that specify the time.
  • if the value has *only* a specific timezone, parse it for a time zone value that can match any of the following:
    • -XX:YY
    • +XX:YY
    • -XXYY
    • +XXYY
    • -XX
    • +XX
    • Z
    • XX is the time zone hours offset, from 00 to 12 with optional leading 0 for values less than 10.
    • YY is the time zone minutes offset, from 00 to 59, though in practice only 00, 15, 30, 45 minute offsets are used in global timezones.
    • Z is the literal 'Z' to indicate GMT.
    • ignore any further "value" elements that specify the timezone.

If by parsing the "value" element(s), at least a specific date has been found, then the "value" is overall valid, and the parser assembles the overall datetime value by concatenating the specific date (PROPOSED: normalized to YYYY-MM-DD), " " (space character) and specific time (if time was specified, with 00 minutes implied if no minutes are provided), and specific timezone (if timezone and a specific time was specified).

  • YYYY-MM-DD - no time specified
  • YYYY-MM-DD HH:MM or YYYY-MM-DD HH:MM:SS - time specified but no timezone. This is a floating time.
  • YYYY-MM-DD HH:MMZ or YYYY-MM-DD HH:MM:SSZ or
  • YYYY-MM-DD HH:MM-XXYY or YYYY-MM-DD HH:MM:SS-XXYY or
  • YYYY-MM-DD HH:MM+XXYY or YYYY-MM-DD HH:MM:SS+XXYY - both time and timezone offset were specified.

format specific details

The following are format specific details and optimizations that make use of the value-class-pattern.

short URL for this section
http://ufs.cc/w/vcpfso

hCalendar dtend implied date

Typically events that start and end the same day only display the date of the event once (makes sense per the DRY principle) (real world examples: Upcoming, ... more examples with URLs would help for thoroughness).

Thus it would be convenient if we could imply an hCalendar event "dtend" date from its "dtstart" date when only the time (and optionally timezone) was specified for its "dtend", e.g.:

<span class="vevent">
 The <span class="summary">party</span> will be on 
 <span class="dtstart">
  <time class="value">2009-06-26</time>, from
  <time class="value">19:00</time></span> to 
 <span class="dtend"><time class="value">22:00</time></span>.
</span>

and in HTML4/XHTML1:

<span class="vevent">
 The <span class="summary">party</span> will be on 
 <span class="dtstart">
  <span class="value">2009-06-26</span>, from
  <span class="value">19:00</span></span> to 
 <span class="dtend"><span class="value">22:00</span></span>.
</span>

To simplify this further for authors, hCalendar processors could treat the specifying of just the time per the value-class-pattern date and time value rules, and thus eliminate the need for the "value" span inside the "dtend" span:

<span class="vevent">
 The <span class="summary">party</span> will be on 
 <span class="dtstart">
  <time class="value">2009-06-26</time>, from
  <time class="value">19:00</time></span> to 
 <time class="dtend">22:00</time>.
</span>

and in HTML4/XHTML1:

<span class="vevent">
 The <span class="summary">party</span> will be on 
 <span class="dtstart">
  <span class="value">2009-06-26</span>, from
  <span class="value">19:00</span></span> to 
 <span class="dtend">22:00</span>.
</span>

hCalendar to iCalendar converters should produce the following iCalendar fragment (as part of a valid .ics file) from all of the above four examples:

BEGIN:VEVENT
SUMMARY:party
DTSTART:20090626T190000
DTEND:20090626T220000
END:VEVENT

Note that the implied "00" seconds here is only due to iCalendar syntax requirements, and not actually meaningful.

Implementations:

  • X2V has implemented dtend implied date from dtstart.

Examples "in the wild":

iCalendar generators

microformats implementations which consume hCalendar and generate iCalendar MUST in addition:

  1. remove any dash "-" separators in the date.
  2. remove any colon ":" separators in the time.
  3. add a whole day to any date-only (lacking a specified time) (date inclusive) hCalendar dtend property values in order to generate an (date exclusive) iCalendar DTEND property value with the same meaning, per the resolution to the dtend-issue.
  4. imply 00 seconds if seconds are omitted due to iCalendar artificial precision syntax requirements
  5. perform datetime math on any +/- relative timezone value, and produce an effective UTC value ending with "Z".

hAtom updated implied date

Similarly, in blog posts that indicate both when they were "published" and "updated", the date is usually only displayed once, typically when "published" (real world examples with URLs would help for thoroughness).

Thus it would be convenient if we could imply an hAtom entry "updated" date from its "published" date when only the time (and optionally timezone) was specified for its "updated", e.g. for a blog post that was updated the same day:

<span class="hentry">
 <span class="entry-summary">short blog post example</span>
 was published on <span class="published">
  <time class="value">2009-08-01</time> at <time class="value">12:06</time></span>
 and updated at <span class="updated"><time class="value">12:10</time></span>.
</span>

and in HTML4/XHTML1:

<span class="hentry">
 <span class="entry-summary">short blog post example</span>
 was published on <span class="published">
  <span class="value">2009-08-01</span> at <span class="value">12:06</span></span>
 and updated at <span class="updated"><span class="value">12:10</span></span>.
</span>

To simplify this further for authors, hAtom processors could treat the specifying of just the time per the value-class-pattern date and time value rules, and thus eliminate the need for the "value" span inside the "updated" span:

<span class="hentry">
 <span class="entry-summary">short blog post example</span>
 was published on <span class="published">
  <time class="value">2009-08-01</time> at <time class="value">12:06</time></span>
 and updated at <time class="updated">12:10</time>.
</span>

and in HTML4/XHTML1:

<span class="hentry">
 <span class="entry-summary">short blog post example</span>
 was published on <span class="published">
  <span class="value">2009-08-01</span> at <span class="value">12:06</span></span>
 and updated at <span class="updated">12:10</span>.
</span>

Atom generators

microformats implementations which consume hAtom and generate Atom MUST in addition:

  • normalize all date and datetime values to RFC3339, including:
    • imply 00 seconds if seconds are omitted due to Atom artificial precision syntax requirements

microformats2 parsers implied date

Since microformats2 parsers are generic, instead of checking for specific properties (as above for hAtom and hCalendar), they must perform the following algorithm to imply dates for dt-* properties:

  • if a dt-* property has a time but lacks a date
  • then it adopts the date of the most recently seen dt-* property with a date in that microformat.
    • if no previous dt-* properties have a date,
    • then it adopts its date from the next dt-* property with a date seen in that microformat.
    • otherwise it simply has a time (and no date).

Note: This results in a similar enough implementation/interpretation as the previous vocabulary dependent heuristics for hAtom and hCalendar that a microformats2 parser can produce similar results for h-entry and h-event without having to know about their specific dt-* properties.

derivation and tests

This section is informative.

The handling of date and time values in the value class pattern was originally brainstormed on the value-excerption-pattern-brainstorming page and derived from that analysis and feedback. For the curious, historical details may be found there, along with additional thoughts for extension.

See value-class-date-time-tests for test cases.

Parsing value from a title attribute

⚠️ Warning: you should use the HTML5 <data> element instead of the value-title class name, in particular, use:
<data class='dt-start' value='2008'>last year</data>
instead of
<span class='dt-start'><span class='value-title' title='2008'>last year</span></span>
The value-title feature is under consideration for deprecation.

The value-title class name allows the publisher to indicate the data value for a parent property is contained in the title attribute of an element, rather than the inner-text.

This can be used to provide a synonym within content, or used to quietly publish alternate forms of information for microformats parsing, without affecting the consumption of content.

For example, you can use casual localization with dates:

<p>It was 
 <span class='dtstart'>
  <span class='value-title' title='2008'>last year</span>
 </span>
  that I realised my addiction to cashew nuts would cost this country so dear.
</p>

Parsing rules for value-title are the same as for value above, with the following change:

  • Where a microformats property has a child element with class name of value-title, the content of the title attribute of that element must be parsed, rather than the portion of the element that would be parsed for a class name of value.

Using value-title to publish machine-data

The initial usage of value-title is used to publish alternate, parsable forms of property values in a visible context without the use of the abbr element whose semantics already support interpretation of the 'title' attribute as an expanded, more precise form of the content.

Experience has found that there are some cases in microformats where a number of publishers want to include a precisely accurate and parsable value for a property but do not want it to be visible in their page, even as a tooltip.

For example, full ISO8601 datetimes may be confusing to readers of the page (as a tooltip or when read aloud by a screen reader), and enumerated values such as the type subproperty of hCard's tel property use US-English terms, which are not part of pages in any other language.

Since both of those scenarios have shown to be obstacles for a number of publishers, for these cases, and these alone, there exists a further extension of value-excerption. This extension allows the parsable form of the property to be published ‘silently’ in an empty element immediately adjacent with the respective local visible content.

Here is an example, with the required use of a first child element with class name value-title:

<p class='tel' lang='en-gb'>
  <span class='type'>
    <span class='value-title' title='cell'> </span>
    mobile
  </span>
  <span class='value'>+44 7773 000 000</span>
</p>

Note: the <span class='value-title' title='cell'> </span> span is deliberately empty (just has a space between the open and close tags) so that it doesn't take up any space and therefore can't show a tooltip.

The cell value is parsed for the 'type' subproperty, but mobile is presented to the user.

In the case of dates:

<p class='dtstart'>
  <span class='value-title' title='2009-03-14T16:28-0600'> </span>
  March 14th 2009, around half-past four
</p>

A microformats parser will read the ISO8601 format datetime 2009-03-14T16:28-0600, but users will only see March 14th 2009, around half-past four. Testing has shown that the ISO8601 datetime above does not get exposed to any user at all.

Parsing machine-data value-title

Browsers collapse the value-title span down to a width of 0, effectively providing no visual rendering, whilst keeping the element in the DOM. With no physical dimensions, there is no ‘hover’ state, so no tooltip is revealed. Furthermore, the empty element is not passed to assistive technology layers such as VoiceOver. Screen readers do not read the contents of the title attribute of an empty span element.

We conducted thorough testing of these parsing behaviors to ensure accessibility.

Note: Whilst the value-title element is more gracefully written without whitespace inner-text (or as self-closing <foo /> element in XHTML), some tools such as WYSIWYG editors and HTML-Tidy will erroneously discard such elements, resulting in parsable data being thrown away by some tools. As such, <span class='value-title'> </span>, including a single whitespace character between the opening and closing tag, may also be used. In some situations, this whitespace may be rendered by the browser, and authors should test their output.

Parsing this final value-title extension imposes some stricter restrictions on usage. These restrictions exist to reduce the impact of DRY violations, reduce the opportunity for sites to spoof data, and encourage best practice for maintaining both forms of data accurately.

Where an element with class value-title is to be parsed as data for a property, and that element also contains no non-whitespace content (hereafter referred to as ‘empty’), the following rules apply:

  • The ‘empty’ value-title element must be the first, non-whitespace child of the property element. That is, it should follow immediately after the property is declared, before the human-readable form, and without any additional nesting.
  • The ‘empty’ value-title element can only be used for specific properties. Future microformat specifications (and updates to existing microformats) must explicitly state which properties may be used with this extension of the value-class-pattern. (Retroactive property support for existing microformats is documented below.)
  • Where an ‘empty’ value-title element is to be used as the single property value, it must be the only such value content. That is, the first instance of a conforming value-title element overrides all other value and value-title siblings and/or cousins.
  • Tools written to perform Conformance Testing and/or Validation of microformats should attempt to compare the machine-data and human-legible forms of the property data, and warn authors if the forms do not match.

limited use of value-title

⚠️ Warning: This issue applies to the preferred <data> element too.

Due to the fact that the value-title pattern hides some amount of data which tends to be a machine-specific duplicate of data that is provided in the human readable content, there are two microformats principles being compromised: visibility and DRY. Thus the applicability of this pattern is deliberately restricted to properties that have demonstrated through experience a need for it, with no known better alternative.

In general authors should:

  1. First, try to directly specify microformats property values inline (the most visible, no duplication),
  2. Then consider using the value-class pattern
    1. Including multiple value elements for date and time properties
  3. and then only if those methods are insufficient, consider the value-title pattern (or rather, the <data> element).

This document post-dates other microformat specifications, such that they may not yet indicate which properties permit use of this pattern. In the interim, only the following types of properties should allow the value-title pattern.

  • ISO8601 date, datetime, timezone, and duration values
  • Enumerated values (such as the hCard tel/email/adr 'type' subproperties)
  • Co-ordinates (such as the geo 'latitude' and 'longitude' properties)
  • Telephone number properties (e.g. the hCard 'tel' property)

The machine-data page has documentation of some of the properties of some specs which experience has shown need a solution like the value-title pattern.

There are some simple reference examples and tests for this pattern on value-class-pattern-tests.

In future use, specification authors may inherit use of value-title by use of ISO8601 date and time formats, or reuse of other microformats, but specifications should _avoid_ introducing new data structures that depend on or encourage this pattern. New specifications are themselves expected to adhere to the principals of visible data and DRY.

H2VX workaround

H2VX does not yet support the 'value-title' feature of the value class pattern (still waiting for proper value-title tests on separate live pages). Thus if your page depends on H2VX, you should use the following techniques instead (from pbworks documentation)

E.g. if the value to be placed in the value-title is both human and machine readable, instead of:

<span class="p-rsvp"><span class="value-title" title="yes">going</span></span>

Use an abbr (ok only if the value is human readable/listenable)

<abbr class="p-rsvp" title="yes">going</abbr>

Otherwise if the value is only machine readable, or human-unfriendly, instead of the empty span technique:

<span class="p-rsvp"><span class="value-title" title="yes"> </span> going</span>

Use an empty abbr:

<abbr class="p-rsvp" title="yes"></abbr> going

Test cases

See value-class-pattern-tests.

FAQ

This section is informative.

Frequently asked questions about the value-class-pattern. Once this section grows too big, we'll make a separate wiki page (like value-class-faq).

  • Is the value-class pattern supported by any of the microformats tools?
  • Why use an 'empty' element? Why not embed data in the class attribute?
    • A: 'class' is for field names, not data. The class attribute is inappropriate for embedded data values, as per the HTML4 specification, which states class is for ‘general purposing processing’, which is defined as ‘e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.’. ‘General purpose processing’ does not extend to data itself. Furthermore, this method avoids inventing a new string pattern for embedding data.
  • Why use an 'empty' element? Why not make up a new attribute, like ‘data’?
    • A: New attributes are invalid. Microformats exist and function in valid HTML. Those are the current standards for web development, and microformats exist for use now. In the future, perhaps revisions of HTML will offer up another solution. For now, this method has been tested against browsers, and creates a consistent document structure (where machine-form and human-form data are siblings).
  • Shouldn't the title attribute only be used for content?
    • A: 'title' is used for content, machine readable content. The title attribute is used for content and is read by microformats parsers. This exists for cases where data cannot be parsed with sufficient precision from just the commonly published, visible information. This pattern allows both forms of content to be included, whilst keeping it invisible to human consumers.
  • How should microformats2 parsers handle improperly nested value-class-patterns inside p- properties? *:Consider the following markup.
<div class="h-card">
  <div class="p-tel">
    <span class="value">0123456789</span>
    <div class="h-card">
      <div cass="p-tel">
        <span class="value">9876543210<span>
      </div>
    </div>
  </div>
</div>
  • Why might someone write some markup like this? Ask a consulting psychologist. WordPress template authors, the sort of people enamoured with trendy CSS frameworks and so on—there's plenty of scope for crappy markup. The value-class-pattern spec as currently written (specficially §4 of Basic parsing) instructs implementers to not handle nested elements with class value, but in the context of a microformats2 parser, it would seem reasonable for an implementer to assume that the author here did not intend to make the text content of the second microformats2 object instance part of the value of the first. The question then is what to do with this kind of markup (other than find the author and ask him or her to kindly rewrite it). —Tom Morris 20:02, 7 November 2013 (UTC)

You can also refer to the general Microformats FAQ and principles.

Examples in the wild

This section is informative.

The following sites and pages have started marking up content with the value-class-pattern, and are thus good places to go for examples with real world content to test with implementations (i.e. parsers). If you use the value-class-pattern in your content, feel free to add it to the top of this list. Once the list grows too big, we'll make a separate wiki page (like value-class-examples-in-wild).

Add your site/page(s) that use the value-class-pattern here, along with a brief description of what value-class-pattern features you use, with which microformat(s) and which of its/their properties.

Implementations

This section is informative.

The following implementations have been developed which either generate or parse value-class-pattern property values. If you have an value-class-pattern implementation, feel free to add it to the top of this list. Once the list grows too big, we'll make a separate wiki page (like value-class-implementations).

consuming and parsing tools

publishing tools

  • K2 (WordPress Theme) is using "value-title" for the hAtom published property. [1]

Background

This section is informative.

The value class pattern is derived from value-excerpting in hCard.

Sometimes, only a part of an element's content is to be used as the value of a microformat property. This may occur when a property has optional subproperties, such as tel: type and tel: value in hCard. Other times, the most appropriate structure for a property may include other content.

Articles

This section is informative.

Articles and blog posts discussing the value class pattern, most recent first. When this section gets too big, create a separate page like: value-class-pattern-articles

References

This section is informative.

Related Pages

This section is informative.

Translations

This section is informative.

Read the value-class-pattern specification in additional languages: