value-class-pattern: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(Tidy, update to new wiki mark-up. Remove flow chart.)
Line 1: Line 1:
<h1>Value Excerption Pattern</h1>
<entry-title>Value Excerption Pattern</entry-title>
 
''The value excerption pattern is derived from [[hCard#Value_excerpting|value-excerpting]] in hCard. As such, it is already somewhat supported in parsers. '''However''', the precise parsing behavior is not yet finalized, so the pattern should be used only with extreme caution, and with the awareness that the editing of more precise parsing rules could impact your pages.''
''The value excerption pattern is derived from [[hCard#Value_excerpting|value-excerpting]] in hCard. As such, it is already somewhat supported in parsers. '''However''', the precise parsing behavior is not yet finalized, so the pattern should be used only with extreme caution, and with the awareness that the editing of more precise parsing rules could impact your pages.''
 
__TOC__
{{TOC-right}}
 
<div class="vcard">
<div class="vcard">
; <span class="role">Editor</span>  
; <span class="role">Editor</span>  
Line 20: Line 17:
vCard:
vCard:


<pre><code>TEL;TYPE=HOME:+1.415.555.1212</code></pre>
<source lang=text>TEL;TYPE=HOME:+1.415.555.1212</source>


hCard:
hCard:


<pre><code>
<source lang=html4strict>
  &lt;span class="tel">
  <span class="tel">
   &lt;span class="type">Home&lt;/span>:
   <span class="type">Home</span>:
   &lt;span class="value">+1.415.555.1212&lt;/span>
   <span class="value">+1.415.555.1212</span>
  &lt;/span>
  </span>
</code></pre>
</source>


In this case, the value of <code>tel</code> is <code>+1.415.555.1212</code>, not <code>Home: +1.415.555.1212</code>.
In this case, the value of <code>tel</code> is <code>+1.415.555.1212</code>, not <code>Home: +1.415.555.1212</code>.
Line 35: Line 32:
Another example, this time using <code>price</code> in [[hListing]]:
Another example, this time using <code>price</code> in [[hListing]]:


<pre><code>
<source lang=html4strict>
  &lt;span class="price">
  <p class="price">
     I want to sell for
     I want to sell for
     &lt;span class="value">£15&lt;/span>
     <span class="value">£15</span>
  &lt;/span>
  </p>
</code></pre>
</source>


In this case, <code>price</code> will parse as <code>£15</code>, rather than as the entire sentence.
In this case, <code>price</code> will parse as <code>£15</code>, rather than as the entire sentence.
Line 46: Line 43:
Another example, using <code>dtstart</code> in [[hCalendar]]:
Another example, using <code>dtstart</code> in [[hCalendar]]:


<pre><code>
<source lang=html4strict>
  &lt;span class="dtstart">
  <span class="dtstart">
     Friday 25th May, 6pm
     Friday 25th May, 6pm
     &lt;span class="value">2008-05-25T18:00:00+0100&lt;/span>
     <span class="value">2008-05-25T18:00:00+0100</span>
  &lt;/span>
  </span>
</code></pre>
</source>


Whilst the entire string ‘Friday 25th May <nowiki>[…]</nowiki>’ is semantically the date, it's the ISO 8601 encoded form alone which must be consumed by a microformats parser, so the <code>value</code> class isolates it.
Whilst the entire string ‘Friday 25th May <nowiki>[…]</nowiki>’ is semantically the date, it's the ISO 8601 encoded form alone which must be consumed by a microformats parser, so the <code>value</code> class isolates it.
Line 59: Line 56:
* Where multiple descendants of a property all have a class name of <code>value</code>, they should be concatenated, without inserting additional characters or white-space.
* Where multiple descendants of a property all have a class name of <code>value</code>, they should be concatenated, without inserting additional characters or white-space.
* Where an element <code>foo</code> with class <code>value</code> has a <em>descendant</em> <code>bar</code> with class <code>value</code>, the entire content of <strong><code>foo</code></strong> is taken as the <code>value</code>. Nesting additional elements with class of <code>value</code> cannot be used to further isolate a property's value.
* Where an element <code>foo</code> with class <code>value</code> has a <em>descendant</em> <code>bar</code> with class <code>value</code>, the entire content of <strong><code>foo</code></strong> is taken as the <code>value</code>. Nesting additional elements with class of <code>value</code> cannot be used to further isolate a property's value.
There is a draft flow chart showing the parsing behavior for value-excerption, including proposed empty-node parsing: [http://ben-ward.co.uk/microformats/value-excerption-pattern/ValueExcerptionParseFlowChart.png Value Excerption Parsing Flow Chart] (out of date).


==Related Pages==
==Related Pages==

Revision as of 05:40, 6 January 2009

<entry-title>Value Excerption Pattern</entry-title> The value excerption pattern is derived from value-excerpting in hCard. As such, it is already somewhat supported in parsers. However, the precise parsing behavior is not yet finalized, so the pattern should be used only with extreme caution, and with the awareness that the editing of more precise parsing rules could impact your pages.

Editor
Ben Ward

Sometimes, only a part of an element's content is used as the value of a microformat property. This may occur when a property has optional sub-properties, such as tel in hCard. Other times, the most logical, semantic element for the property class name may include other content.

For these purposes, the special class name value is used to excerpt out the relevant element content.

Simple Examples

Here is an hCard fragment for marking up a home phone number:

vCard:

TEL;TYPE=HOME:+1.415.555.1212

hCard:

 <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.

Another example, this time using price in hListing:

 <p class="price">
    I want to sell for
    <span class="value">£15</span>
 </p>

In this case, price will parse as £15, rather than as the entire sentence.

Another example, using dtstart in hCalendar:

 <span class="dtstart">
    Friday 25th May, 6pm
    <span class="value">2008-05-25T18:00:00+0100</span>
 </span>

Whilst the entire string ‘Friday 25th May […]’ is semantically the date, it's the ISO 8601 encoded form alone which must be consumed by a microformats parser, so the value class isolates it.

Parsing

  • Where an element with a microformat property class name has an descendant with class name value, parsers should read the inner-text of the value element only, ignoring other text node descendants.
  • Where multiple descendants of a property all have a class name of value, they should be concatenated, without inserting additional characters or white-space.
  • Where an element foo with class value has a descendant bar with class value, the entire 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.

Related Pages