E
Elena
I'm doing a little web site with Netbeans using jsp and xsl. I've
realized 3 xsl files (header,navbar,footer) containing a template with
attribute name to visualize the 3 components, and index.xsl which
should include the preceding files. Templates make an html
transformation.
I have also 4 jsp files (header.jsp,footer,navbar,index) containing
data (taken from a database in MSAccess using javabeans) organized
through xml tag. I'm trying to include header,navbar and footer (xsl)
inside index.xsl,which displays the initial page seen by user, using
<xsl:import> for the 3 components and <xsl:call-template name= > to
apply the 3 template inside the template of index.xsl. I'm still green
so I don't know if this solution is correct (at the moment it doesn't
work:"impossible to compile the stylesheet"), or is there another
better solution to realize header, navbar, footer in different files
and make all work?
I add some examples of files about which I'm working. they are very
simple files just to see if my solution worked.
FOOTER.JSP
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<c:set var="xmlDocument" scope="page">
<PAGE></PAGE>
</c:set>
<c:set var="xslUrl"><%="/xsl/footer.xsl"%></c:set>
<c:import var="xslDocument" url="${xslUrl}" scope="page"/>
<x:transform xml="${xmlDocument}" xslt="${xslDocument}"/>
FOOTER.XSL
<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:template name= "foot">
<xslutput method="html" indent="yes"/>
<html>
<head>
<title>Footer</title>
</head>
<body>
<table width="100%" align="center" cellspacing="0"
cellpadding="0">
<tr><td align="center"><img src="/Bank/Images/
hr.jpg" /></td></tr>
</table>
<table class="foot" align="center" cellspacing="0"
cellpadding="0">
<tr>
<td><img src="/Bank/Images/Bank logo.jpg"
height="40"/></td>
<td><p> Bank Project</p></td>
<td ><img src="/Bank/Images/Bank logo.jpg"
height="40"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Xsl and jsp files for navbar and header are analogous, only names of
template change.
My solution for INDEX.XSL.
<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:import href="header.xsl"/>
<xsl:import href="navbar.xsl"/>
<xsl:import href="footer.xsl"/>
<xsl:template match="/">
<xslutput method="html" indent="yes"/>
<html>
<xsl:call-template name="head"/>
<xsl:call-template name="nb"/>
<body>
<table width="100%" height="100%" align="center"
cellspacing="0" cellpadding="0">
<tr>
<td width="25%" align="center">Main page</
td>
<td width="50%" align="center">Main page</
td>
<td width="25%" align="center">Main page</
td>
</tr>
</table>
<body>
<xsl:call-template name="foot"/>
</html>
</xsl:template>
</xsl:stylesheet>
INDEX.JSP
<%@ page info="Pagina iniziale" %>
<%@ page contentType="text/html" %>
<%@ page session="false" %>
<%@ page buffer="30kb" %>
<%@ page errorPage="/ErrorPage.jsp" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<c:set var="xmlDocument" scope="page">
<PAGE></PAGE>
</c:set>
<c:set var="xslUrl"><%="/xsl/index.xsl"%></c:set>
<c:import var="xslDocument" url="${xslUrl}" scope="page"/>
<x:transform xml="${xmlDocument}" xslt="${xslDocument}"/>
realized 3 xsl files (header,navbar,footer) containing a template with
attribute name to visualize the 3 components, and index.xsl which
should include the preceding files. Templates make an html
transformation.
I have also 4 jsp files (header.jsp,footer,navbar,index) containing
data (taken from a database in MSAccess using javabeans) organized
through xml tag. I'm trying to include header,navbar and footer (xsl)
inside index.xsl,which displays the initial page seen by user, using
<xsl:import> for the 3 components and <xsl:call-template name= > to
apply the 3 template inside the template of index.xsl. I'm still green
so I don't know if this solution is correct (at the moment it doesn't
work:"impossible to compile the stylesheet"), or is there another
better solution to realize header, navbar, footer in different files
and make all work?
I add some examples of files about which I'm working. they are very
simple files just to see if my solution worked.
FOOTER.JSP
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<c:set var="xmlDocument" scope="page">
<PAGE></PAGE>
</c:set>
<c:set var="xslUrl"><%="/xsl/footer.xsl"%></c:set>
<c:import var="xslDocument" url="${xslUrl}" scope="page"/>
<x:transform xml="${xmlDocument}" xslt="${xslDocument}"/>
FOOTER.XSL
<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:template name= "foot">
<xslutput method="html" indent="yes"/>
<html>
<head>
<title>Footer</title>
</head>
<body>
<table width="100%" align="center" cellspacing="0"
cellpadding="0">
<tr><td align="center"><img src="/Bank/Images/
hr.jpg" /></td></tr>
</table>
<table class="foot" align="center" cellspacing="0"
cellpadding="0">
<tr>
<td><img src="/Bank/Images/Bank logo.jpg"
height="40"/></td>
<td><p> Bank Project</p></td>
<td ><img src="/Bank/Images/Bank logo.jpg"
height="40"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Xsl and jsp files for navbar and header are analogous, only names of
template change.
My solution for INDEX.XSL.
<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:import href="header.xsl"/>
<xsl:import href="navbar.xsl"/>
<xsl:import href="footer.xsl"/>
<xsl:template match="/">
<xslutput method="html" indent="yes"/>
<html>
<xsl:call-template name="head"/>
<xsl:call-template name="nb"/>
<body>
<table width="100%" height="100%" align="center"
cellspacing="0" cellpadding="0">
<tr>
<td width="25%" align="center">Main page</
td>
<td width="50%" align="center">Main page</
td>
<td width="25%" align="center">Main page</
td>
</tr>
</table>
<body>
<xsl:call-template name="foot"/>
</html>
</xsl:template>
</xsl:stylesheet>
INDEX.JSP
<%@ page info="Pagina iniziale" %>
<%@ page contentType="text/html" %>
<%@ page session="false" %>
<%@ page buffer="30kb" %>
<%@ page errorPage="/ErrorPage.jsp" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<c:set var="xmlDocument" scope="page">
<PAGE></PAGE>
</c:set>
<c:set var="xslUrl"><%="/xsl/index.xsl"%></c:set>
<c:import var="xslDocument" url="${xslUrl}" scope="page"/>
<x:transform xml="${xmlDocument}" xslt="${xslDocument}"/>