[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] unable to pass parameters from jsp


Subject: [xsl] unable to pass parameters from jsp
From: Aseef Jamaluddin <j_aseef@xxxxxxxxx>
Date: Mon, 1 Apr 2002 02:59:33 -0800 (PST)

I am still doing my beginers in xml. I am trying to
pass a parameter from a jsp page which can be accessed
from my style sheet. Please find below the jsp code,
xml and xsl files i am using. I am not getting the
parameter value as expected. What could be wrong, in
anycase is it possible to pass a parameter as i have
explained. If so please advise on the proper way of
doing it.

<%@ page
import="javax.xml.transform.TransformerFactory,
javax.xml.transform.Transformer,
javax.xml.transform.stream.StreamSource,
javax.xml.transform.stream.StreamResult,
javax.xml.transform.TransformerException,
javax.xml.transform.TransformerConfigurationException,
javax.servlet.jsp.JspWriter,
javax.servlet.jsp.PageContext,

// Imported java classes
java.io.FileOutputStream,
java.io.FileNotFoundException,
java.io.IOException,
java.io.OutputStream,
java.io.InputStream,
java.io.ByteArrayOutputStream,
java.io.ByteArrayInputStream,
org.xml.sax.InputSource" 
%>

<%
String url="c:/tomcat/webapps/examples/jsp/xslt/";
StreamResult sr=new
StreamResult(response.getWriter());
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource(url + "atemp1.xsl"));
transformer.setParameter("firstParam","firstParamValue");
transformer.transform(new StreamSource(url +
"atemp1.xml"), sr);
%>
<br/>
hello world

------------------------------------------

<?xml version="1.0" ?>
<custdet>custdettag</custdet>

------------------------------------------
<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:template match="/">
<xsl:param name="firstParam"/>
<xsl:value-of select="firstParam"/>

<xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

--------------------------------------------
The output i am getting is 

<?xml version="1.0" encoding="UTF-8"?>
custdettag
<br/>
hello world

Thanks in advance
Aseef.J

__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - send holiday greetings for Easter, Passover
http://greetings.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords