hForms – Semantische Formulare

Warum sollte nur die Ausgabe ((X)HTML) semantisch anreichern und die Eingabe vernachlässigen?

Beim spielen mit dem hCard-Mappers und der Firefox-Microformats-API kam mir die Idee, auch Formulare semantisch auszuzeichnen…

In dem Artikel Use the new microformats API in your Firefox 3.0 Extensions beschreibt Rob Crowther wie man mit Hilfe der Firefox-Microformats-API eine hCard speichert um sie zum Ausfüllen verschiedener Formulare weiterverwenden zu können.

Das Problem: Das Prinzip funktioniert leider nur bei Formularen die dem festgelegten Aufbau entsprechen. Im Fall des Beispiels wäre das:

<h1>hCardFormFiller Target Form</h1>
<form action="#" method="post">
    <label>Name: <input type="text" id="name" /></label><br />
    <label>Email: <input type="text" id="email" /></label><br />
    <label>Home page: <input type="text" id="homepage" /></label><br />
    <label>Street Address: <input type="text" id="address1" /></label><br />
    <label>City: <input type="text" id="address2" /></label><br />
    <label>Region: <input type="text" id="city" /></label><br />
    <label>Postcode: <input type="text" id="postcode" /></label><br />
    <input type="submit" />
</form>Code-Sprache: HTML, XML (xml)

Warum nicht gleich das Formular als hCard-From aufbauen?

<form action="#" method="post" id="vcard" >
  <fieldset id="fn">
    <legend>Name</legend>
    <label for="given-name">Vorname:</label>
      <input type="text" id="given-name" />
    <label for="family-name">Nachname:</label>
      <input type="text" id="family-name" />
  </fieldset>
  <label for="email">Email:</label>
    <input type="text" id="email" />
  <label for="url">Homepage:</label>
    <input type="text" id="url" />
  <fieldset id="adr">
    <legend>Adresse</legend>
    <label for="street-address">Straße:</label>
      <input type="text" id="street-address" />
    <label for="locality">Stadt:</label>
      <input type="text" id="locality" />
    <label for="region">Region:</label>
      <input type="text" id="region" />
    <label for="postal-code">Postleitzahl:</label>
      <input type="text" id="postal-code" />
  </fieldset>
  <input type="submit" />
</form>Code-Sprache: HTML, XML (xml)

Das Einheitliche Format für Ein- (Formular) und Ausgabe (Microformats) hätte zur Folge, dass keine aufwendigen Mapper (wie z.B. hCard-Mapper) mehr nötig wären um ein Formular per hCard auszufüllen…

Schöne neue Welt 🙂

Matthias Pfefferle
Matthias Pfefferle
@pfefferle@notiz.blog

Ich bin Webworker und arbeite als „Open Web Lead“ @ Automattic. Ich blogge, podcaste und schreibe eine Kolumne über das open, independent und federated social Web. Mehr über mich.

772 Beiträge
850 Folgende
Fediverse Reactions

2 Kommentare

  1. Als ich den Mapper geschrieben habe, hatte ich kurzzeitig auch überlegt, das Mapping direkt an die Formularfelder zu heften. Ich finde das rel Attribut eigentlich ganz praktisch für diesen Zweck. Statt die gesamte hCard dann als hForm abzubilden, hätte man einfach rel=“hcard:given-name“ oder sowas in der Art schreiben können.

  2. Das Problem ist nur, dass <input />-Tags eigentlich kein rel-Attribut haben… Aber prinzipiell hast du recht, id="vcard:given-name" oder id="vcard:adr:region" wären auch ne schicke Variante (wusste bisher gar nicht dass der Doppelpunkt in class– und id-Attributen erlaubt ist).

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.