File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes what is the Error  Ajith Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "what is the Error  Ajith" Watch "what is the Error  Ajith" New topic

what is the Error Ajith

Sharang Thorat

Joined: Dec 07, 2000
Posts: 21
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.*,*,rs.desc.*,rs.jsp.util.*,org.apache.xalan.processor.*,org.apache.xalan.x slt.*,*,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;

transformer = tFactory.newTransformer(new StreamSource(file_path.concat("\\rsdstylesheet.xsl")));
}catch(Exception e){

System.out.println("The transformer class is " + (transformer.getClass()).getName());


XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

processor.process(new XSLTInputSource(in),new XSLTInputSource(xslfile),new XSLTResultTarget(out));
}catch (Exception e)


xsl style sheet is
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl :param name="param1" select="'default value'"/>
<xsl :param name="param2" />
<xsl:template match="/REPORT">
<link rel="stylesheet" href="../../../WTDefault.css" type="text/css"/>
<title>Report </title>
<TABLE border="0" width="100%">
<TR class = "t1-bg-col-head">
<xsl:apply-templates select="HEADER" />


<xsl:for-each select="ROW">
<xsl:sort order="{$param2}" select="COLUMN[position() = $param1 ]"/>
<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:apply-templates select="ROW" / -->

<xsl:template match="HEADER">
<TD class="t1-bg-col-head"><font class="t1-bg-col-head"><xsl:value-of select="."/></font></TD>
<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 match="COLUMN">
<TD><xsl:value-of select="."/></TD>

<xsl:template name="EVEN">
<TR bgcolor="#CCCCCC"><xsl:apply-templates select="COLUMN"/></TR>

<xsl:template name="ODD">
<TR bgcolor="#AAAAAA"><xsl:apply-templates select="COLUMN"/></TR>


the error i am getting is runtimeException as the ElemTemplateElement error:attribute " order has illegal value
whats wrong here please help is needed.
[ Ajith disabled smilies ]
[This message has been edited by Ajith Kallambella (edited August 08, 2001).]
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
The sort parameter "param2" should be initialized to a non-empty value. Check your stylesheet.
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Sharang Thorat

Joined: Dec 07, 2000
Posts: 21
even after giving the default value the error pesists.
consider a tag where in i am using param2
<xsl:sort select="some expr" order="{$param2}" />
it fails to extract the proper value of param2 parameter which
i have passed it always takes the default value.
I agree. Here's the link:
subject: what is the Error Ajith