CSE 271: User Interface Design: Social and Technical Issues
XML Homework
Below are three files, which should be named bib.xml, bib.dtd, and bib.xsl, respectively. If you load all three into the same directory and point a MicroSoft Internet Explorer version 5 (IE) browser at the XML file, you will see the result formatted according to the XSL file. The DTD file is not actually necessary, but if present, the validity of the XML file is checked against its declarations. Note that Netscape Navigator does not yet support XML. (All three files are also in this directory.)

Your homework assignment is as follows:

  1. Modify the XSL (and maybe the XML) file so that books are displayed in a style like that of the following
    Lamport, Leslie. LaTeX: A Document Preparation System (Addison-Wesley 1986).
    and journal articles are displayed in a style like that of the following
    Marr, David. Visual information processing, Phil. Trans. Roy. Soc. B, 290, pp.199-218, 1980.
  2. Add two books and two journals to the XML file, where two of the new items have some information missing.
     
  3. Define a new type of bibliography item for PhD theses in XSL, add two such items to the XML file, and add the appropriate declarations to the DTD code.

The XML File
Note that one item is repeated, and that the use of spaces is not entirely uniform. <?xml version="1.0" encoding="ISO-8859-1" ?> <?xml-stylesheet type="text/xsl" href="bib.xsl"?> <!DOCTYPE bib SYSTEM "bib.dtd"> <bib> <book> <author>Leslie Lamport</author> <title>LaTeX: A Document Preparation System </title> <year>1986</year> <publisher>Addison-Wesley</publisher> </book> <article> <author>David Marr</author> <title>Visual information processing</title> <year>1980</year> <volumn>290</volumn> <page> <from>199</from> <to>218</to> </page> <journal>Phil. Trans. Roy. Soc. B</journal> </article> <article> <author>R. K. Clifton </author> <title>Breakdown of echo suppression in the precedence effect</title> <year>1987</year> <volumn>82</volumn> <page> <from>1834</from> <to>1835</to> </page> <journal>J. Acoust. Soc. Am. </journal> </article> <book> <author>David Marr</author> <title>Vision</title> <year>1982</year> <address> NY </address> <publisher>Freeman</publisher> </book> <article> <author>David Marr</author> <title>Visual information processing</title> <year>1980</year> <volumn>290</volumn> <page> <from>199</from> <to>218</to> </page> <journal> Phil. Trans. Roy. Soc. B</journal> </article> </bib>
The DTD Code
<?xml version="1.0" ?> <!ELEMENT bib ( (book | article)+)> <!ELEMENT book ( author, title, year, (address)?, publisher )> <!ELEMENT article ( author, title, year, volumn, page, journal) > <!ELEMENT page (from, to)> <!ELEMENT author (#PCDATA)> <!ELEMENT title (#PCDATA)> <!ELEMENT year (#PCDATA)> <!ELEMENT address (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT to (#PCDATA)> <!ELEMENT journal (#PCDATA)> <!ELEMENT volumn (#PCDATA)>
The XSL Code
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" result-ns="http://www.w3.org/TR/REC-html"> <xsl:template match="/"> <html> <head> <title>Bibliography</title> </head> <body background="antiquewhite"> <center><h2>Bibliography</h2><hr width="90%"/></center> <ul> <xsl:for-each select="bib/book"> <p/><li> <xsl:value-of select="author"/>, <b><xsl:value-of select="title"/></b>, <xsl:value-of select="publisher"/> <xsl:value-of select="address"/>, <xsl:value-of select="year"/>. </li> </xsl:for-each> <xsl:for-each select="bib/article"> <p/><li> <xsl:value-of select="author"/>, <b><xsl:value-of select="title"/></b>, <em><xsl:value-of select="journal"/></em>, <xsl:value-of select="volumn"/>, pages<xsl:apply-templates select="page"/> <xsl:value-of select="year"/>. </li> </xsl:for-each> </ul> </body> </html> </xsl:template> <xsl:template match="page"> <xsl:value-of select="from"/>-<xsl:value-of select="to"/>, </xsl:template> </xsl:stylesheet>
To CSE 271 homework page
To CSE 271 homepage
To my homepage
Version of 25 February 2000.