Introduction to Server-Side XML

It sets the scene for server-side XML, and shows what you can do with it, by way of a parallel example done in ASP, PHP, and JSP (we have only included the first of the example sections here). The three chapters that follow this one in the book are case studies, which go into using XML with the three server-side languages mentioned above in much more detail.

This sample is taken from Chapter 8 "Introduction to Server-Side XML" of the glasshaus title "Practical XML for the Web".

JSP: Transforming the XML

Here we'll use the XTags tag library from Jakarta, which can be downloaded freely from the Jakarta web site (http://jakarta.apache.org). The XTags library is a set of simple tags that give web designers access to powerful XML processing actions without any Java programming knowledge. Using this tag library, the JSP that transforms cd_list.xml using cd_list.xsl is extremely simple (cd_list.jsp):

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">

<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>

<xtags:parse uri="cd_list.xml" id="cdList"/>

<xtags:style xsl="cd_list.xsl" document="<%= cdList %>"/>

The following line declares that we'll be using the XTags tag library, with the "xtags" prefix:

<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0" prefix="xtags" %>

The next line parses the XML document specified in the uri attribute (an external XML document can also be specified by using the url attribute and supplying the full URL to the document), and the final line transforms the document using the XSL stylesheet specified in the xsl attribute, and prints out the result.

George Petrov

George PetrovGeorge Petrov is a renowned software writer and developer whose extensive skills brought numerous extensions, articles and knowledge to the DMXzone- the online community for professional Adobe Dreamweaver users. The most popular for its over high-quality Dreamweaver extensions and templates.

George is also the founder of Wappler.io - the most Advanced Web & App Builder

See All Postings From George Petrov >>

Comments

Be the first to write a comment

You must me logged in to write a comment.