Академический Документы
Профессиональный Документы
Культура Документы
While SGML has a long history of use in specific user communities (Humanities, Government
documentation), its use as XML "On The Web" is still relatively rare. Support for integrated authoring
and browsing ala HTML is simply not there yet. IE 4.0 does contain hooks for XML viewing using
plug-ins. Both Netscape and Microsoft plan much greater support in later browser versions. For now
though, if you want to write and view XML documents, the available solutions might best be
described as "clunky"1. In this lab, you'll get to try one such solution and experience that 'clunkiness'
first hand.
Assumptions
I am assuming that you all know HTML and are literate users of Windows machines and associated
applications. In particular, I expect that you know how to use Notepad/Wordpad, Netscape/IE, and
perform standard desktop manipulations like copying files and folders.
Goals
The goals of this exercise are for you to
• Practice writing XML,
• Use a non-validating XML parser to verify that the XML code you write is well-formed,
• Gain experience generating HTML using an XML source file and a provided style sheet,
• Experience the separation of structure from formatting, and
• Have fun!
Preliminaries
We must do some set-up first. The course folder is called XML on the G drive of your machine
(G:\XML). Your home folder will be a folder called "XML" on the C Drive inside the TEMP folder
(C:\TEMP\XML).
Go to the TEMP folder on your C Drive. If the XML folder exists delete it (put it in the Recycle
Bin).
Create a new folder called XML. This is your home folder -- C:\TEMP\XML
Using Windows Explorer, go to the course folder and copy the "examples" folder to your home
folder.
Open a DOS command window.
In the DOS window go to the folder you just copied
C:
cd \TEMP\XML\examples
List the contents of this folder, so you can see what files are there (of course you can do this from
the Windows desktop as well)
DIR
1
To some degree, "clunky" makes sense. XML alone is about structure not formatting/display.
If you really want to know what's going on with the above command, ask the instructor. Anyway,
since this example is already "well-formed", you should get output something like the following:
Hello Tim
Lark V1.0 final beta Copyright (c) 1997-98 Tim Bray.
All rights reserved; the right to use these class files for any purpose
is hereby granted to everyone.
Parsing...
Done.
Translation: Lark says the file parses cleanly - no error messages are given - its well-formed!
Lark has found at least two errors, though there may be more.
Recall the "rules" of well-formedness. Minimally, your XML markup should
• respect case-sensitivity
• have ending tags for all starting tags
• have no overlapping elements
Using Notepad or some other editor of your choosing, fix cd.xml so that it is well-formed. You
will have to repeatedly use Lark as shown above in order to check the XML.
C:\TEMP\XML\examples\microsoft.xml
If successful, the file microsoft.html will have been created. Go ahead and load this file in your
web browser to see what the combination of your markup and the supplied style sheet has yielded.
Further Reading
Books
The following books have been helpful in the preparation of this material.
1. "XML : A Primer." by Simon St. Laurent, MIS Press, 1998. Available from Amazon Books.
2. "The XML Handbook" by Charles F. Goldfarb, Paul Prescod, Prentice-Hall, 1998. Available from
Amazon Books.
3. "XML : Extensible Markup Language", by Elliotte Rusty Harold, IDG Books WorldWide, Inc.,
1998. Available from Amazon Books
Online
This course's XML page: http://ils.unc.edu/viles/xml/
Microsoft's XML page. http://www.microsoft.com/xml/default.asp
World Wide Web Consortium's Web Page: http://www.w3.org/XML/
Junglee's XML Reference List: http://www.junglee.com/tech/xml_sparchive.html
Oasis.org's XML Resource, maintained by Robin Clover: http://www.oasis-open.org/cover/xml.html