Using a Publishing Framework

Using a good publishing framework like Cocoon doesn’t require any special instruction; it is not a complex application that users must learn to adapt to. In fact, all the uses of Cocoon are based on simple URLs entered into a standard web browser. Generating dynamic HTML from XML, viewing XML transformed into PDF files, and even seeing VRML applications generated from XML is simply a matter of typing the URL to the desired XML file into your browser and watching Cocoon and the power of XML take action.

Viewing XML Converted to HTML

Now that our framework is in place and correctly handling requests that end in .xml, we can begin to see it publish our XML files. Cocoon comes with several sample XML files and associated XSL stylesheets in the project’s samples/ subdirectory. However, we have our own XML and XSL from earlier chapters, so let’s transform the partial XML table of contents for our book with the XSL stylesheet we built in Chapter 6. The XML file should be named contents.xml (and is also available from the book’s web site). Locate where you saved this file, and copy it into the servlet engine’s document root. On a default installation of Tomcat, this is under <TOMCAT_ROOT>/webapps/ROOT/. The document refers to the stylesheet XSL/JavaXML.html.xsl. Create the XSL directory in your web document root, and copy the stylesheet we built in Chapter 6 into that directory. You should make sure that the DTD referred to in the XML document is commented ...

Get Java and XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.