[uf-discuss] Automatic conversion of XML to microformat and vice versa; recommendation for handling XML attributes?

Costello, Roger L. costello at mitre.org
Sun Aug 27 06:31:37 PDT 2006


Hi Folks,

Microformat newbie here, so please bear with me if my questions are
misguided.

That said, from the reading I have done on microformats, I am really
excited about it!

I am converting an XML document to a microformat.  I want to design the
microformat in a fashion such that I will be able to convert the
microformat back to the original XML.  I want the micrformat to retain
all the semantics of the XML, plus have a nice visual presentation,
i.e.,

       microformat = XML semantics + appealing visual presentation

Leaf nodes in the XML document I map to an XHTML <dl> element, e.g.,

      <aircraft_altitude>12000</aircraft_altitude>

I map to this microformat:

      <dl class="aircraft_altitude">
            <dt>Aircraft Altitude</dt>
            <dd>12000</dd>
      </dl> 

Some things to note:
1. The XML tag is mapped to the value of the <dl> class attribute.
2. The microformat contains both the tag semantics and provides as a
nice visual presentation.
3. Using the approach exemplified here, any XML leaf node can be
automatically converted into the microformat form, and vice versa.

Question #1
Do you agree with using <dl> for XML leaf nodes?  If not, do you
recommend something else?

I am having problems with mapping XML leaf nodes that have attributes,
e.g.,

      <aircraft_altitude units="meters">12000</aircraft_altitude>

I am not sure how to map this into a microformat.  Here is one
approach:

      <dl class="aircraft_altitude">
            <dt>Aircraft Altitude</dt>
            <dd>12000 <span class="units">meters</span></dd>
      </dl>

With this approach the microformat has retained all the semantics of
the original XML - both the semantics of the XML tag, as well as the
semantics of the XML attribute.  Conversion from XML to microformat,
and from microformat to XML is easily accomplished.

Question #2
What do you think of this approach of using <span> to capture
attribute/value pairs?

Let's make the problem still harder.  Suppose the XML tag has two
attributes:

      <aircraft_altitude units="meters"
reference="AGL">12000</aircraft_altitude>

AGL = Above Ground Level, i.e., the aircraft is at an altitude of 12000
meters above ground.

Proceeding in the same fashion, the microformat would be:

      <dl class="aircraft_altitude">
            <dt>Aircraft Altitude</dt>
            <dd>12000 <span class="units">meters</span>
                              <span class="reference">AGL</span></dd>
      </dl>

Question #3
What do you think of using multiple <span>s, one for each
attribute/value pair?

Now, switching examples, consider this XML leaf node:

      <commentary xml:space ="preserve">This is a
commentary</commentary>

Continuing in the same fashion as above, this XML leaf node would map
to this microformat:

      <dl class="commentary">
            <dt>Commentary</dt>
            <dd>This is a commentary <span
class="xml:space">preserve</span></dd>
      </dl>

However, for this XML leaf node I don't want the attribute value to
have a visual presence.  I must confess, I am out of ideas on how to
handle this.  Do you have a recommendation?

/Roger


More information about the microformats-discuss mailing list