Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: elena.bellodi@-------.-----.--
To: NULL
Date: 5/3/2007 1:41:00 PM

Hi!
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">
        <xsl:output 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="/">
        <xsl:output 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}"/>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent