Dynamic Web Sites with XML, XSLT and JSP (3/4) - exploring XML
Dynamic Web Sites with XML, XSLT and JSP
Example
The link between the JSP and the XSLT stylesheet is the data. We defined a phonebook format in XML like so, and saved it under xslt/xml/book.xml:
<book> <phone> <name>Police</name> <number>110</number> </phone> <phone> <name>Fire Brigade</name> <number>112</number> </phone> </book>
The following minimalist JSP will be used as a data source under xslt/book.jsp:
<%@taglib uri="https://jakarta.apache.org/taglibs/xsl-1.0" prefix="xsl"%> <html> <head><title>Phone Book</title></head> <body> <xsl:InsertWithXSL xml="/xml/book.xml" xsl="/xml/book.xsl" /> </body> </html>
The first line references the xsl taglib, and the xsl:InsertWithXSL directive invokes the XSLT processor and gets replaced with the resulting application of book.xsl on book.xml.
After the programmer's contributions comes the designer's work.
Produced by Michael Claßen
URL: https://www.webreference.com/xml/column37/3.html
Created: Aug 15, 2001
Revised: Aug 15, 2001