This tutorial will guide you through setting up Tomcat and Cocoon to serve XML pages, then you will create a DTD, XML file and three XSL stylesheets so that you can view your data in your desktop browser, a cell phone browser and a pdf file.
To begin create a file called homer.xml and open it in a text editor. The first line of the xml file is the XML declaration:
Every xml and xsl document should begin with the XML declaration. This declares that this is an xml document and which version of xml you are using.
Tags of the form <?...?> are processing instructions (PI). Processing instructions are instructions that are passed to the application that will be using the xml document. The first word after the <? is called the target which is the application that the instructions will be passed to. The rest of the PI contains the instructions to be passed to the target. In this case the target is the xml application and we are telling it that we are using xml version 1.0.
The next is our document type declaration. This is where we associate our xml file with the dtd we created. All declarations use the tag <!...>. The document type declaration looks like:
<!DOCTYPE contact SYSTEM "contact.dtd">
Next we want to add a PI for cocoon so that Cocoon knows that we want it to perform stylesheet transformations for us:
Finally we can populate our file with data. At this point filling in the data is pretty simple, just add data values between the tags: