• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

what is the Error Ajith

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The sort parameter "param2" should be initialized to a non-empty value. Check your stylesheet.
HTH
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Sharang Thorat
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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.
regards
sharang
 
What's that smell? Hey, sniff this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic