File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

what is the Error Ajith

Sharang Thorat
Greenhorn

Joined: Dec 07, 2000
Posts: 21
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).]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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.


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

Joined: Dec 07, 2000
Posts: 21
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the Error Ajith