value-class-pattern: Difference between revisions
(Added parsing rules in response to closed value-nesting-in-value issue.) |
m (Clarified self as page editor.) |
||
Line 1: | Line 1: | ||
=Value Excerption Pattern= | =Value Excerption Pattern= | ||
''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 behaviour is not yet finalised, 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-right}} | {{TOC-right}} | ||
<div class="vcard"> | |||
; <span class="role">Editor</span> | |||
: <span class="fn">[[User:BenWard|Ben Ward]]</span> | |||
</div> | |||
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 <code>tel</code> in [[hCard]]. Other times, the most logical, semantic element for the property class name may include other content. | 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 <code>tel</code> in [[hCard]]. Other times, the most logical, semantic element for the property class name may include other content. |
Revision as of 18:20, 6 June 2008
Value Excerption Pattern
The value excerption pattern is derived from value-excerpting in hCard. As such, it is already somewhat supported in parsers. However, the precise parsing behaviour is not yet finalised, 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:
<code>TEL;TYPE=HOME:+1.415.555.1212</code>
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:
<span class="price">
I want to sell for
<span class="value">£15</span>
</span>
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 thevalue
element only, ignoring other text node descendants. - Where multiple descendants of a property all have a class name of
value
, they should be concatenated, separated by a single piece of white-space (unicode 0020). - Where an element
foo
with classvalue
has a descendantbar
with classvalue
, the entire content offoo
is taken as thevalue
. Nesting additional elements with class ofvalue
cannot be used to further isolate the value.