XML, DTD, XSL Exercise


  1. XML and XSL.

  2. The following personal.dtd contains the document type declaration of personal XML document:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!ELEMENT personnel (person)+>
    <!ELEMENT person (name,email*,url*,link?)>
    <!ATTLIST person id ID #REQUIRED>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    <!ELEMENT name (#PCDATA|family|given)*>
    <!ELEMENT email (#PCDATA)>
    <!ELEMENT url EMPTY>
    <!ATTLIST url href CDATA #REQUIRED>
    <!ELEMENT link EMPTY>
    <!ATTLIST link
      manager IDREF #IMPLIED
      subordinates IDREFS #IMPLIED>
    The following personalbad.xml  is an example of a personal XML document:
    <?xml version="1.0"?>
    <!DOCTYPE personnel SYSTEM "personal.dtd">
    <personnel>
      <person id="Big.Boss" >
        <name><family>Boss</family> <given>Big</given></name>
        <email>chief@foo.com</email>
        <url href="http://www.foo.com/~chief"/>
        <link subordinates="one.worker"/>
      </person>
      <person id="one.worker" >
        <email>worker1@foo.com</email>
        <name><family>Workman</family> <given>John</given></name>
        <link mananger="Big.Boss"/>
        <url href="http://www.foo.com/~workman"/>
      </person>
    </personnel>

    You can use the IBM Visual XML Tools   to help out this exercise or
    execute of an IBM Java-based  XML Parser  on the personalbad.xml which indicates the following two errors:

    wetterhorn>cd ~cs301/public_html/xml/xmlj4_2_0_6
    wetterhorn>java -cp xml4j.jar;xml4jSamples.jar sax.SAXWriter -p com.ibm.xml.parsers.ValidatingSAXParser personalbad.xml
    [Error] personalbad.xml:13:20: Attribute, "mananger", is not declared in element, "link".
    [Error] personalbad.xml:15:12: Element "<person>" contains incomplete content for the rule, "(name,email*,url*,link?)".

    You can also use checkxml.sh shell script  for checking the xml document.
    wetterhonr>checkxml.sh personalbad.xml
     

    1. What are wrong with the second person record?.
    2. Create an XSL document that sorts the personnel .xml file based on the family name, and displays the family name, given name, and email of the personnel records as an HTML file.