Hi
thru following
jsp page i am passing two parameters to xsl
<%@ page language="java" contentType="text/html; charset=UTF-8"
import = "java.util.*,wt.httpgw.*,rs.jsp.bean.*,org.apache.xpath.*,javax.xml.transform.*,javax.xml.transform.stream.*,rs.desc.*,rs.jsp.util.*,org.apache.xalan.processor.*,org.apache.xalan.x slt.*,java.io.*,rs.jsp.helper.*,wt.util.WTMessage,wt.httpgw.EncodingConverter" %>
<jsp:useBean id="wtcontext" class="wt.httpgw.WTContextBean" scope="session"/>
<jsp:setProperty name="wtcontext" property="request" value="<%=request%>"/>
<%
String sort_val = request.getParameter("SORT_ON");
String sort_order = request.getParameter("SORT_ORDER");
System.out.println("TO BE SORTED ON PARAM ID :" + sort_val);
System.out.println("ORDER OF SORTING :" + sort_order);
String file_path = "C:\\ptc\\Windchill\\codebase\\rs\\jsp\\jsp";
File xmlfile = new File(file_path.concat("\\temp.xml"));
File stylesheet = new File(file_path.concat("\\rsdstylesheet.xsl"));
FileInputStream in = new FileInputStream(xmlfile);
FileInputStream xslfile = new FileInputStream(stylesheet);
TransformerFactory tFactory = TransformerFactory.newInstance();
System.out.println("the factory class is " + (tFactory.getClass()).getName());
Transformer transformer = null;
try{
transformer = tFactory.newTransformer(new StreamSource(file_path.concat("\\rsdstylesheet.xsl")));
}catch(Exception e){
e.printStackTrace();
}
System.out.println("The transformer class is " + (transformer.getClass()).getName());
transformer.setParameter("param1",sort_val);
transformer.setParameter("param2",sort_order);
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
try{
processor.process(new XSLTInputSource(in),new XSLTInputSource(xslfile),new XSLTResultTarget(out));
}catch (Exception e)
{
System.out.println("******************************************");
e.printStackTrace();
}
%>
xsl style sheet is
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl :param name="param1" select="'default value'"/>
<xsl :param name="param2" />
<xsl:template match="/REPORT">
<html>
<head>
<link rel="stylesheet" href="../../../WTDefault.css" type="text/css"/>
<title>Report </title>
</head>
<body>
<BR/>
<BR/>
<TABLE border="0" width="100%">
<TR class = "t1-bg-col-head">
<xsl:apply-templates select="HEADER" />
</TR>
<xsl:for-each select="ROW">
<xsl:sort order="{$param2}" select="COLUMN[position() = $param1 ]"/>
<TR>
<xsl:if test="position() mod 2 =0"><xsl:call-template name="EVEN" /></xsl:if>
<xsl:if test="position() mod 2 !=0" ><xsl:call-template name="ODD"/></xsl:if>
</TR>
</xsl:for-each>
<!-- xsl:apply-templates select="ROW" / -->
</TABLE>
</body>
</html>
</xsl:template>
<xsl:template match="HEADER">
<TD class="t1-bg-col-head"><font class="t1-bg-col-head"><xsl:value-of select="."/></font></TD>
</xsl:template>
<xsl:template match="ROW">
<xsl:if test="position() mod 2 =0"><xsl:call-template name="EVEN" /></xsl:if>
<xsl:if test="position() mod 2 !=0" ><xsl:call-template name="ODD"/></xsl:if>
</xsl:template>
<xsl:template match="COLUMN">
<TD><xsl:value-of select="."/></TD>
</xsl:template>
<xsl:template name="EVEN">
<TR bgcolor="#CCCCCC"><xsl:apply-templates select="COLUMN"/></TR>
</xsl:template>
<xsl:template name="ODD">
<TR bgcolor="#AAAAAA"><xsl:apply-templates select="COLUMN"/></TR>
</xsl:template>
</xsl:stylesheet>
the error i am getting is runtimeException as the ElemTemplateElement error:attribute " order has illegal value
whats wrong here please help is needed.
regards
sharang
[ Ajith disabled smilies ]
[This message has been edited by Ajith Kallambella (edited August 08, 2001).]