JSP: Transforming the XML - Page 23
November 18, 2002
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.
ASP: Transforming the XML - Page 22
Practical XML for the Web
|