It uses a xsl stylesheet that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">
<xsl

utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:include href="header.xslt"/>
<xsl:template match="/EasementHistory">
<html>
<head>
<xsl:call-template name="header"/>
<title>Change history </title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="1355" height="286">
<!-- MSTableType="layout" -->
<tr>
<td valign="top" colspan="3" height="39">
<!-- MSCellType="ContentHead" -->
</td>
</tr>
<tr>
<td>
<xsl:text disable-output-escaping="yes">
</xsl:text>
</td>
<td valign="top">
<table class="table_standard">
<tbody>
<tr>
<td style="width:10%;"/>
<td>
<table class="table_standard">
<tbody>
<tr>
<td>
<h2> History Tracking of Easements</h2>
</td>
</tr>
<tr></tr>
<tr>
<td>
<xsl:choose>
<xsl:when test="count(/EasementHistory/History/Change) > 0">
<table class="table_standard">
<thead>
<tr>
<!--<th style="width=10%" />
<th>
</th> -->
<th style="width=100%" colspan="5"><span align="center" style= "color:#888888"> Job# : <xsl:value-of select="/EasementHistory/JobNbr"/></span>
</th>
<th/>
</tr>
<tr>
<th style="width=100%" colspan="5"></th>
</tr>
<tr class="odd_col_head" >
<th height="35" style=" width:11%">| Date |</th>
<th style="width:11%">| Field |</th>
<th style="width:33%">| Old value |</th>
<th style="width:33%">| New value | </th>
<th style="width:12%">| Change made by | </th>
</tr>
</thead>
<tbody>
<xsl:for-each select="/EasementHistory/History/Change">
<tr>
<xsl:if test="position mod 2 = 1">
<xsl:attribute name="class">data_row</xsl:attribute>
</xsl:if>
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="class">odd_col</xsl:attribute>
</xsl:if>
<td style="width:11%">
<xsl:value-of select="Date"/>
</td>
<td style= "width:11%">
<xsl:value-of select="Field"/>
</td>
<td style="width:31%">
<textarea rows="4" cols="40" readonly="readonly">
<xsl:if test="position mod 2 = 1">
<xsl:attribute name="class">data_row</xsl:attribute>
</xsl:if>
<xsl:if test="position mod 2 = 0">
<xsl:attribute name="class">odd_col</xsl:attribute>
</xsl:if>
<xsl:value-of select="OldValue"/>
</textarea>
</td>
<td style="width:31%">
<textarea rows="4" cols="40" readonly="readonly">
<xsl:if test="position mod 2 = 1">
<xsl:attribute name="class">data_row</xsl:attribute>
</xsl:if>
<xsl:if test="position mod 2 = 0">
<xsl:attribute name="class">odd_col</xsl:attribute>
</xsl:if>
<xsl:value-of select="NewValue"/>
</textarea>
</td>
<td style="width:15%">
<textarea rows="4" cols="25" readonly="readonly">
<xsl:if test="position mod 2 = 1">
<xsl:attribute name="class">data_row</xsl:attribute>
</xsl:if>
<xsl:if test="position mod 2 = 0">
<xsl:attribute name="class">odd_col</xsl:attribute>
</xsl:if>
<xsl:value-of select="ChangedBy"/>
</textarea>
</td>
</tr>
</xsl:for-each>
<tr><th height="25" colspan="5" width="100%"></th></tr>
<tr>
<td width="100%" colspan="5" align="center">
<input type="button"
onclick: self.close;return false;" value="Close"/>
</td>
</tr>
</tbody>
</table>
</xsl:when>
<xsl

therwise>
<table class="table_standard">
<tbody>
<tr class="odd_col_head">
<th>There were no edits made to this easement</th>
</tr>
<tr><th height="25"></th></tr>
<tr>
<td align="center">
<input type="button" onclick: self.close;return false;" value="Close"/>
</td>
</tr>
</tbody>
</table>
</xsl

therwise>
</xsl:choose>
</td>
</tr>
</tbody>
</table>
</td>
<td style="width:15%"/>
</tr>
</tbody>
</table>
</td>
<td height="221">
<xsl:text disable-output-escaping="yes">
</xsl:text>
</td>
</tr>
<tr>
<td width="72">
<xsl:text disable-output-escaping="yes">
</xsl:text>
</td>
<td width="910">
<xsl:text disable-output-escaping="yes">
</xsl:text>
</td>
<td height="26" width="73">
<xsl:text disable-output-escaping="yes">
</xsl:text>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
It gets serveral variables and xml from the database and returns this to the
jsp page.
The jsp that look like this:
jsp page:
+"�?<%= com.mud.util.database.HistoryInfo.getXMLEasementHistory(request_id,"xslt/EasementHistory.xslt") %>
Here is the old procedure that returns the xml from the database:
//Displaying the easement history//
public static StringBuffer getXMLEasementHistory(int request_id,
String xslt) throws NamingException, SQLException{
System.out.println("HistoryCheck_3");
String sql = "select req_id, job_nbr,request_nbr from pe_request where req_id ="+request_id;
StringBuffer xml = new StringBuffer();
Connection con = DBConn.getConnection();
if((con == null) || (con.isClosed())){
Context initContext = new InitialContext();
Context envCtx = (Context)initContext.lookup("java:/comp/env");
String dbuser = (String)envCtx.lookup("user");
String dbpass = (String)envCtx.lookup("password");
String url = (String)envCtx.lookup("ConnectDB");
DBConn dbcon = new DBConn(dbuser,dbpass,url);
con = DBConn.getConnection();
}
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
String job_nbr = "";
String request_nbr="";
while(rs.next()){
job_nbr = rs.getString("job_nbr");
request_nbr=rs.getString("request_nbr");
}
xml.append("�?<?xml-stylesheet type=\"text/xsl\" href=\""+xslt+ "\"?>\n");
xml.append("�?<EasementHistory>");
xml.append("�?<ReqId>"+request_id+"�?</ReqId>");
xml.append("�?<JobNbr>"+job_nbr+", Request# - "+request_nbr+"�?</JobNbr>");
java.text.SimpleDateFormat datetime_format = new java.text.SimpleDateFormat("MM/dd/yyyy");
xml.append("�?<History>");
sql = "SELECT field_name, old_value, new_value, updated_by , date_of_update FROM pe_HISTORY WHERE easement_id is not null and req_id = "+request_id+"order by date_of_update";
rs = stmt.executeQuery(sql);
while(rs.next()){
xml.append("�?<Change>");
xml.append("�?<Field>" + rs.getString("field_name")+
"�?</Field>");
String old_val=null;
if(rs.getString("old_value")==null)
old_val=" ";
else
old_val=rs.getString("old_value");
xml.append("�?<OldValue>" +old_val+
" �?</OldValue>");
xml.append("�?<NewValue>" + rs.getString("new_value")+
"�?</NewValue>");
xml.append("�?<ChangedBy>" + rs.getString("updated_by")+
"�?</ChangedBy>");
xml.append("�?<Date>" + datetime_format.format(new java.util.Date(rs.getDate("date_of_update").getTime()))+
"�?</Date>");
xml.append("�?</Change>");
}
xml.append("�?</History>");
xml.append("�?</EasementHistory>");
return xml;
} logger.error("Exception in getFormParamInfo");
throw ce;
}catch(Exception e){
logger.error("Exception in getFormParamInfo", e);
throw new EASException("EAS_EXEC_001");
}finally{
easDBUtil.closeDBResources(con, pstmt, null, rs);
}
return xml;
}
So, what I have done so far in the new application is create a procedure in my dao that returns the xml with the variables. I have added the xslt (changed to xsl) to my application changing the path to the xsl in the xml to match. I have then created a .jsp page that displays the xml as a variable.
Here is my new procedure:
public StringBuffer getEasementHistory(String xslt, int reqId, String jobNbr, String reqNbr)throws EASException{
StringBuffer xml = new StringBuffer();
EASDBUtil easDBUtil = new EASDBUtil(logger);
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
xml.append("�?<?xml-stylesheet type=\"text/xsl\" href=\""+xslt+ "\"?>\n");
xml.append("�?<EasementHistory>");
xml.append("�?<ReqId>"+reqId+"�?</ReqId>");
xml.append("�?<JobNbr>"+jobNbr+", Request# - "+reqNbr+"�?</JobNbr>");
java.text.SimpleDateFormat datetime_format = new java.text.SimpleDateFormat("MM/dd/yyyy");
xml.append("�?<History>");
con = easDBUtil.getConnection();
pstmt = con.prepareStatement(EASDBConstants.GET_HISTORY);
pstmt.setInt(1,reqId);
rs = pstmt.executeQuery();
if(rs != null){
while(rs.next()){
xml.append("�?<Change>");
xml.append("�?<Field>" + rs.getString("field_name")+
"�?</Field>");
String old_val=null;
if(rs.getString("old_value")==null)
old_val=" ";
else
old_val=rs.getString("old_value");
xml.append("�?<OldValue>" +old_val+
" �?</OldValue>");
xml.append("�?<NewValue>" + rs.getString("new_value")+
"�?</NewValue>");
xml.append("�?<ChangedBy>" + rs.getString("updated_by")+
"�?</ChangedBy>");
xml.append("�?<Date>" + datetime_format.format(new java.util.Date(rs.getDate("date_of_update").getTime()))+
"�?</Date>");
xml.append("�?</Change>");
}
xml.append("�?</History>");
xml.append("�?</EasementHistory>");
}
}catch(EASException ce){
logger.error("Exception in getFormParamInfo");
throw ce;
}catch(Exception e){
logger.error("Exception in getFormParamInfo", e);
throw new EASException("EAS_EXEC_001");
}finally{
easDBUtil.closeDBResources(con, pstmt, null, rs);
}
return xml;
}
My struts action looks like this:
<action name="QueryEditEasements" class="com.mud.eas.action.EASQueryEditEasementsA">
<result>/pages/queryEditEasementsPage.jsp</result>
<result name="SUCCESS1">/pages/multipleEasementsPage.jsp</result>
<result type="xslt" name="SUCCESS2">pages/historyPage.jsp</result>
</action>
Thanks for your help.
[ June 25, 2008: Message edited by: Katie Doody ]
[ June 25, 2008: Message edited by: Katie Doody ]