Sample Configuration

  <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="MicroformatsSection" type="Microformats.ConfigurationSections.MicroformatConfigSection, Microformat.net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=56e50f59d03f15a7"/>
  </configSections>
  <MicroformatsSection>
    <Microformats>
      <Microformat name="tag" type="rel-tag" rootType="rel" root="tag" dataType="System.Uri" />
      <Microformat name="hCard" type="hCard" rootType="class" root="vcard" dataType="System.String">
        <Fields>
          <Field name="fn" rootType="class" dataType="System.String" plurality="Singular" />
          <Field name="n" rootType="class" dataType="System.String" plurality="Singular" >
            <Fields>
              <Field name="honorific-suffix" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="honorific-prefix" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="given-name" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="family-name" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="additional-name" rootType="class" dataType="System.String" plurality="Singular" />
            </Fields>
          </Field>
          <Field name="tel" rootType="class" dataType="System.String" plurality="Singular" >
            <Fields>
              <Field name="type" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="value" rootType="class" dataType="System.String" plurality="Singular" />              
            </Fields>
          </Field>
          <Field name="bday" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="nickname" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="title" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="role" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="geo" rootType="class" dataType="Microformat" plurality="Singular"/>
          <Field name="org" rootType="class" dataType="System.String" plurality="Singular">
            <Fields>
              <Field name="organization-name" rootType="class" dataType="System.String" plurality="Singular"/>
              <Field name="organization-unit" rootType="class" dataType="System.String" plurality="Singular"/>                        
            </Fields>
          </Field>
          <Field name="url" rootType="class" dataType="System.Uri" plurality="Singular"/>
          <Field name="note" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="uid" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="email" rootType="class" dataType="System.Uri" plurality="Singular"/>
          <Field name="photo" rootType="class" dataType="System.Uri" plurality="Singular"/>
          <Field name="logo" rootType="class" dataType="System.Uri" plurality="Singular"/>
          <Field name="adr" rootType="class" dataType="Microformat" plurality="Plural"/>
        </Fields>
      </Microformat>
      <Microformat name="name" type="adr" rootType="class" root="adr" dataType="System.String">
        <Fields>
          <Field name="type" rootType="class" dataType="System.String" plurality="Plural"/>
          <Field name="post-office-box" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="extended-address" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="street-address" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="locality" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="region" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="postal-code" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="country-name" rootType="class" dataType="System.String" plurality="Singular"/>
        </Fields>
      </Microformat>
      <Microformat name="geo" type="geo" rootType="class" root="geo" dataType="System.String">
        <Fields>
          <Field name="longitude" rootType="class" dataType="System.String" plurality="Singular"/>
          <Field name="latitude" rootType="class" dataType="System.String" plurality="Singular"/>          
        </Fields>
      </Microformat>
    </Microformats>
  </MicroformatsSection>
</configuration>

Section Configuration

TODO

Microformats Collection Element

The MicroformatCollectionElement is a container of MicroformatElements. Each MicroformatElement contains the definition of the Microformat the you wish to parse.

Microformat Element

The MicroformatElement defines the structure of a Microformat. This configuration is used by the parser so that it can determine the data that it should take from an input stream or Ignore.

The MicroformatElement contains a collection of fields contained by a FieldCollectionElement.

Fields Collection Element

The FieldCollectionElement is a container of FieldElements. Each FieldElement contains the definition of the value data that the framework should parse.

Field Element

The FieldElement defines what data the parser should look for in the input stream. Take the following field declaration as an example <Field name="bday" rootType="class" dataType="System.String" plurality="Singular"/>.

The name attribute is the exact representation of the attibute value that the parser looks for in the input stream (i.e. If an html element is as follows: <li class="bday">03-06-1960</li> the parser will include the data in the associated Microformat).

The rootType attribute defines the attribute that the parser will look for the specified name value on an sgml element ((i.e. If an html element is as follows: <li class="bday">03-06-1960</li> the parser will search the class attibute for the field defined by the name).

The dataType attribute tells the parser how to read the values out of the input stream.
Current dataType values are:
  • Microformat - defines a nested microformat
  • System.String - the parser will treat data as a string
  • System.Uri - the parser will treat data as a Uri

The plurality attribute informs the parser how to treat data.
Warning: specifiying a pluraity of Singular does not yet ignore multiple instances of the field

Nested Elements

Each FieldElement can contain a nested collection of field elements via a FieldCollectionElement. This is exemplified by the "n" element in the hCard definintion:
 <Field name="n" rootType="class" dataType="System.String" plurality="Singular" >
            <Fields>
              <Field name="honorific-suffix" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="honorific-prefix" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="given-name" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="family-name" rootType="class" dataType="System.String" plurality="Singular" />
              <Field name="additional-name" rootType="class" dataType="System.String" plurality="Singular" />
            </Fields>
          </Field>


The "n" element says to the parser that all the fields beneath can only be parsed if they are nested underneath the n element in the input stream:
This would parse:
<html>
<body>
<span class="vcard"><span class="fn n"><span class="given-name">Paul</span><span class="family-name">Kinlan</span></span></span>
</body>
<html>

This wont parse:
<html>
<body>
<span class="vcard"><span class="fn n">Paul Kinlan</span><span class="given-name">Paul</span><span class="family-name">Kinlan</span></span>
</body>
<html>

Notice the differences above, in the second example the given-name and family name are outside the "n" elements tree.

Nested Microformats

Each Microformat configuration can point to another configured microformat. A nested microformat must be configured, before it is refernced inside another microformat. For example, take the hCard Microformat, it contains two nested microformats, GEO (Geographic Reference points) and ADR (Address information). They are configured referenced in the hCard as a field with a dataType of "Microformat" (<Field name="adr" rootType="class" dataType="Microformat" plurality="Plural"/>). The framework will reconise that it needs to then find the Microformat called ADR and then resolve all the ADR fields into the hCard format.
Warning: It is possible to create an infinite loop of nested formats, with both Microformats refering to each other.

Last edited Sep 14, 2007 at 10:44 AM by Kinlan, version 13

Comments

No comments yet.