Heal Your Church WebSite


Teaching, rebuking, correcting & training in righteous web design.

WMDI: Mad Scientist Experiments v.01

I’ve been remiss in my participatin regading the The Weblog MetaData Initiative: Next Step: HTML [meta] Experiment. Even after NZ mentions me by name! At Dean’s suggestion, I’ve gone ahead and taken a rather quick-and-dirty approach to our encoding problem. I’ve developed a specification which shows how to encode our general schema’s metadata using only HTML [meta] tags. Along the way, I’ve also “Dublin Core-ized” our data schema, and tried to use DC tags wherever possible and appropriate.

But because some of you are not programmers, and because some of you don’t have a clue what I’m talking about, I’m going to offer two ‘baby-steps’ parsers that show how to take a WMDI encoded page and display the various tags. Even if you’re not into the WMDI, you may find these parsing mechanism useful:

First in Perl (console version)

#!/usr/bin/perl

use LWP::Simple;

$url = “http://www.truthlaidbear.com/001388.html”;
$text = get($url);
unless (defined $text)
     { die(“ERROR * Cannot Load $url – $!”) }

use HTML::TokeParser;

$parser=HTML::TokeParser->new(\$text);
while (my $token=$parser->get_tag(“meta”))
{
     print $token->[1]{name}.” -> “.$token->[1]{content}.”\n”
          if $token->[1]{name} =~ m/^(DC|WMDI)\./i;
}

Now PHP

<?
$url = “http://www.truthlaidbear.com/001388.html”;

$metatags = @get_meta_tags(“$url”,1);
if (!$metatags) $metatags=@get_meta_tags(“$url/”,1);

while (list($name, $contents) = each($metatags))
{
     if (eregi(“^(dc|wmdi)_”, $name)) {
          $tags = split(“_”, $name);
          $type = array_shift($tags);
          $tag = join(“.”, $tags);
          echo “$type: <b>$tag</b> – $contents\n<br />”;
     }
}
?>

There, now that wasn’t so painful was it?

2 Comments

  1. Looks interesting! OOPS — the scripts take metatags starting with DC or WMDI, however, the WMDI spec v0.1, 10/20/02 has one Blog attribute which would be missed: pics-label

    How about installing these scripts on a server so we can exercise them?

    Thanks,
    oscar.rhudy@computer.org

  2. Yeah, I had posted a tutorial on how to add the meta data to b2 weblogs, using a php include call. Basically you have a text file that holds all your metadata and then just call:

    <?php include(“b2-include/wmdi.php”); ?&#62

    That inputs everything you need. A more indepth explanation is here: http://personal.concepthause.com/wmdi.php

    Enjoy

    Chris