Print

Print


Hi Folks,

From my readings on XML it appears that there are two methods for defining
an element's metadata: using NOTATIONs and using ATTLIST.

For example, suppose that we have an element, elevation.  We would like to
define as metadata its datatype and units:

- ------------------------------------------------------------
<!ELEMENT elevation (#PCDATA)>
<!ATTLIST elevation
            datatype (int | float | double | boolean) #REQUIRED
            units (feet | meters | centimeters | inches) #REQUIRED>

...

<elevation datatype="int" units="meters">1200</elevation>
- ------------------------------------------------------------

alternatively,

- ------------------------------------------------------------
<!NOTATION IsoInt PUBLIC  ISO Integer 64 >
<!NOTATION IsoFloat PUBLIC  ISO Float >
<!NOTATION IsoDbl PUBLIC  ISO Double >
<!NOTATION IsoBool PUBLIC  ISO Boolean >

<!ELEMENT elevation (#PCDATA)>
<!ATTLIST elevation
         datatype NOTATION (IsoInt | IsoFloat | IsoDbl | IsoBool) #REQUIRED
         units NOTATION (IsoFeet | IsoMeters | IsoCm | IsoIn) #REQUIRED>

...

<elevation datatype="IsoInt" units="IsoMeters>1200</elevation>
- ------------------------------------------------------------

Is one way preferred over another?  What are the advantages/disadvantages
of the two approaches?

One disadvantage that I see to both of the above approaches is that they
both limit the values of the attributes to just those specified in the
enumeration list - suppose that my instance document want to use a
different datatype or unit, for example "Real" and "Kilometers"?

This might argue for using CDATA as the datatype of the attributes:

<!ELEMENT elevation (#PCDATA)>
<!ATTLIST elevation
            type CDATA #REQUIRED
            units CDATA #REQUIRED>

  ...

<elevation type="int" units="meters">1200</elevation>

However, this has the disadvantage of being too flexible - it makes it more
difficult to write an application since it doesn't know what to expect.

I would be interested in hearing what thoughts people might have on this.

/Roger