May 22, 2000
|
|
Web Development:
Cocoon: Sanity For Web-Site Management
Java servlet offers the ability to transform XML-encoded Web content into multiple formats and separates the management components of a Web site to help developers separate content management, presentation, and programming logic
By Jason Levitt
| Related links: |
|
|
| And from our sister publications: |
|
|
| TechEncyclopedia |
|
Send Us Your Feedback |
anaging Web content has become a huge undertaking for the many IT professionals and content specialists running company Web sites. A new standard called Cocoon is emerging that will let developers re-architect Web sites to deliver scalable, dynamic content. Cocoon, part of the Apache Extensible Markup Language Project (xml.apache.org), will also give developers a way to cleanly separate management of Web content, presentation, and programming logic.Cocoon's developers hope to change the way that Web information is created, rendered, and served. The standard takes into account that Web content, style, and logic are created by different individuals or work groups. Cocoon will allow the three areas--content, style, and logic--to be designed, created, and managed separately. This division should ease the job of managing Web content and increase the ability to reuse work. The Cocoon model divides Web development into three areas: XML creation, processing, and rendering.
Cocoon is essentially a Java servlet that transforms XML-encoded Web content using Extensible Stylesheet Language technology. Cocoon is an open-source project that makes use of many new standards, such as Document Object Model Level 2, Simple API for XML 2.0, XML, XSL, and XSL Transformations. It's implemented completely in XML and Java.
Cocoon 2.0, currently in alpha release, is the version that larger sites will want to deploy. But the current version, 1.72, is mature and quite usable for testing and smaller projects; it offers a clean migration path to version 2.0.
Cocoon's two major benefits for Web sites are its ability to transform XML-encoded Web content into multiple formats and its ability to separate manageable components of a Web site.
For sites that need to serve up content in multiple formats, Cocoon can be used as a back-end management tool to generate static Web pages from XML source files. Web-site pages can be stored as XML files and then transformed using Cocoon's XSL style sheets into the appropriate format. For sites that need to serve up Web content to many types of devices, this capability alone makes Cocoon worthwhile.
Cocoon can also act as an application server, detecting the type of client from the HTTP request header, transforming the XML source file on-the-fly into the appropriate format, and sending it back to the user (see diagram, below).
If more-sophisticated application-server processing is needed, Cocoon offers a new, powerful application-server technology called XML Server Pages that lets developers add programming logic--in this case Java, but other languages are possible--to XML pages. Properly maintained XSP pages allow a clean division between Web content, output format, and programming logic.
Because of this division, using XSP as the basis for dynamically generated Web content offers management benefits over all other application server technologies, even its closest relative, Java Server Pages (see sidebar, "XML Server Pages Vs. Java Server Pages").
Merely using Cocoon doesn't guarantee that a Web site will be easy to manage. Careful coding is required to divide the Web-site content into distinct elements. Cocoon and its underlying standards make this possible.
A carefully constructed Web site using Cocoon's XSP lets content, output formatting rules, and programming logic reside in separate files that don't directly depend on each other for interpretation. This means that changes can be made to each area without breaking others. In large companies, the upshot is that programmers won't be hassling Web designers when they change embedded programming logic. Also, content managers don't have to worry so much about the decisions Web designers make regarding Web-page formatting.
The raw Web-site content for Cocoon is usually XML files. Content creators can be database developers who design conduits for moving data from the database into XML files, or data encoders who simply translate data into XML files. Web designers are concerned with XSL style-sheet files.
XSL files can describe many possible transformations on XML files, but for Web designers, the translations they'll be concerned with are those that turn XML into HTML other formats for browser clients.
If you decide to use XSP and take advantage of Java (or other language) code in Web pages, you must be careful to present programming logic in modules. XSP allows procedural code to be inserted into XML source files, mixing content and program logic, just as with Java Server Pages, Microsoft's Active Server Pages, and more traditional application-server development platforms.
However, careful development of XSP applications allows all program logic to be defined in XSL logic sheets, which are files containing Java (or some other programming language) and special XSP elements that tell how to apply the Java results to an XML file.
There are no commercial products with Cocoon's power and modularity--but, then, Cocoon uses the latest standards and open-source technology to move systems forward quickly. The Cocoon contingent doesn't have to provide on-demand technical support, so it's much easier to move ahead with standards that may not be completely ratified. I suspect there will be new, updated commercial products using Cocoon technology by year's end.
Some commercial products offer some of Cocoon's capabilities, but not XSP. Caucho Technology's Resin, Inso's Dynabase, Interleaf's BladeRunner, and Post Point Software's XBuilder all offer some XML and XSL translation capability.
Creating Web sites using Cocoon isn't easy. It's harder to create XML/ XSL content than it is to use HTML from the beginning of a project. But the long-term benefits of encoding content in XML and using XSL style sheets to translate it into other formats make Cocoon a clear choice for today's large, data-driven Web sites.
Back to Labs
Send Us Your Feedback
Top of the Page
Hebrew Senior Life seeking Network Analyst in Dedham, MA
True Circuits seeking Mixed-Signal IC Layout Engineer in Los Altos, CA
BP seeking Desktop Strategy and Planning Manager in Houston, TX
ITT seeking Senior Staff Engineer, Systems in Fort Wayne, IN
Agilent Technologies seeking Marketing Manager in Melbourne, AU
For more great jobs, career-related news, features and services, please visit our Career Center.