XML Worksheet #1

XML became a W3C Recommendation on February 10, 1998. It has been amazing to see how many languages have promulgated as XML-based standards with different user groups. In class we got a sense of how XML markup rules differed from the more loosely defined HTML markup rules. We converted a valid HTML document to become valid with the stricter XHTML language:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
   <head>

      <title>Bill Smiggins Inc.</title>
   </head>
   <body>
      <h1>Bill Smiggins Inc.</h1>
      <img src=logo.gif align=right alt="company logo">

      <h2>About our Company...</h2>
      <p>This Web site provides clients, customers,
      interested parties and our staff with all of the
      information that they could want on our products,
      services, success and failures.</p>
      <hr>
      <h3>Products</h3>

      <p align="center">We are probably the largest
      supplier of custom widgets, thingummybobs, and bits
      and pieces in North America.
      <hr width="50%">
   </body>
</html>
Converted to:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Bill Smiggins Inc.</title>
   </head>
   <body>
      <h1>Bill Smiggins Inc.</h1>
      <p><img src="logo.gif" style="align:right" alt="company logo"/></p>
      <h2>About our Company...</h2>
      <p>This Web site provides clients, customers,
      interested parties and our staff with all of the
      information that they could want on our products,
      services, success and failures.</p>
      <hr/>
      <h3>Products</h3>
      <p style="align:center">We are probably the largest
      supplier of custom widgets, thingummybobs, and bits
      and pieces in North America.</p>
      <hr/>
   </body>
</html>
Upon making the changes, both our HTML and XHTML documents passed the W3C Validator.

We then attempted to create our own XML markup of a VCARD which was valid according to the VCARD format outside of XML-encoding. I use VCARDs to manage addresses for our organizational partners at The Ocean Project. Here is an example of a valid VCARD (.vcf file) for a partner who gave us just the minimal required information:

BEGIN:VCARD
VERSION:2.1
N:Jennifer DiLorenzo;
FN:Jennifer DiLorenzo
ORG:Urban Coast Institute;TOP Partners
TITLE:
EMAIL;type=INTERNET;type=WORK;type=pref:jdiloren@monmouth.edu
TEL;WORK;VOICE
TEL;WORK;FAX
ADR;WORK;ENCODING=QUOTED-PRINTABLE;;;;
LABEL:Monmouth University 400 Cedar Avenue West Long Branch, NJ 07764-1898;WORK;ENCODING=QUOTED-PRINTABLE
REV:20080401T145132Z
END:VCARD
In class we encoded the same information using the basic syntax rules of XML? My attempt was:
<?xml version="1.0"?>

<!DOCTYPE vcard [
	...
]>

<vcard version="2.1">
    <n>Jennifer DiLorenzo</n>
    <fn>Jennifer DiLorenzo</fn>
    <org status="partner">Urban Coast Institute</org>
    <title></title>
    <email type="internet" location="work">jdiloren@monmouth.edu</email>
    <tel type="voice" location="work"></tel>
    <tel type="fax" location="work"></tel>
    <address type="label" encoding="QUOTED-PRINTABLE" location="work">
        <street1>Monmouth University</street1>
        <street2>400 Cedar Avenue West</street2>
        <city>Long Branch</city>
        <state>NJ</state>
        <zip type="99999-9999">07764-1898</zip>
    </address>
    <address type="printable" location="work">
    </address>
    <revision>20080401T145132Z</revision>
</vcard>
which passes W3C validation. You should now create a DTD for this attempt (or else create a DTD for your attempt which in that case include your attempt in the workbook).

Take a look at the VCard XML standard suggested by the W3C. I present the example from that document here:

The following is a complete example of an RDF personal vCard.

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:v="http://www.w3.org/2006/vcard/ns#">
           
  <v:VCard rdf:about = "http://example.com/me/corky" >
    <v:fn>Corky Crystal</v:fn>
    <v:nickname>Corks</v:nickname>
    <v:tel>
      <rdf:Description>  
        <rdf:value>+61 7 5555 5555</rdf:value>
        <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Home"/>
        <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Voice"/>
      </rdf:Description>  
    </v:tel>
    <v:email rdf:resource="mailto:corky@example.com"/>
    <v:adr>
      <rdf:Description>  
        <v:street-address>111 Lake Drive</v:street-address>
        <v:locality>WonderCity</v:locality>
        <v:postal-code>5555</v:postal-code>
        <v:country-name>Australia</v:country-name>
        <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Home"/>
      </rdf:Description>  
    </v:adr>
  </v:VCard>
</rdf:RDF>

Note that there is also a version that includes geo-coding for addresses.

What do you think about their recommendation? _______________________________________________________ _______________________________________________________

If you need the practice, create another DTD for this VCARD version above to validate this example as well. If useful, run your XML and DTD through the validator to cement your understanding.

You will be creating your own DTDs for the data language you design (as well as an XML Schema-based validator)

Research the structures used for postal addresses in the US, Japan and Brazil. Can you modify at least one DTD that you've created so that it supports (and can validate) all of those forms of international addresses?

A fellow by the name of Dawson attempted to create a DTD for a VCARD XML-based language back in early 1999. You can see his attempt here. What do you think of his attempt?