Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to create an home page using xsl and jsp with header,footer and navbar written in separate files?

Reply
Thread Tools

How to create an home page using xsl and jsp with header,footer and navbar written in separate files?

 
 
Elena
Guest
Posts: n/a
 
      05-03-2007
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 xmlnssl="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 xmlnssl="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}"/>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to include a html navbar when using framesets Rahul HTML 7 06-18-2010 06:21 PM
How to create an home page using xsl and jsp with header,footer and navbar written in separate files? Elena Java 0 05-03-2007 08:52 PM
Using separate classpaths for separate classes? Frank Fredstone Java 1 06-27-2006 06:46 AM
How to make a CSS navbar that colors the page you're on Paul Furman HTML 2 02-17-2004 06:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57