This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Converting XML document to HTML from within JSP


Hi All,

Has anybody been successfull in Converting an XML document to HTML from
within JSP.
The following code does not produce any results, and there are no
compilation errors. I am using resin (jsp 1.1) as my App server and jdk 1.3.
The Source XML File and XSL File are correct as I have succeeded in the
conversion to HTML via its java class equivalent.

Your help would be greatly appreciated.

<%@page import="javax.xml.transform.stream.*,javax.xml.transform.dom.*,
javax.xml.transform.*,java.io.*" %>

<%

//First create a Source object from  the xml file

StreamSource xmlSource=new StreamSource(new File("D:/stocks.xml"));

//Create a Result object.Associate this Result with a File , URL, or any
OutputStream or a Writer object.The
//constructor has five forms,one default and four taking different
arguments.Check documentation for more details.

StreamResult  htmlResult=new StreamResult(out);

//Create a Source object for the XSL style sheet

StreamSource xslSource=new StreamSource(new File("D:/stocks.xsl"));

//Create a TransformerFactory object

TransformerFactory tf=TransformerFactory.newInstance();

//Create a Transformer Object.Pass the XSL Source object in the constructor.

Transformer transformer=tf.newTransformer(xslSource);

//Complete the transformation

transformer.transform(xmlSource,htmlResult);

//In this case, since we have associated the Result object with the implicit
out object,
//when the transform() method returns, the output will be written to the
client.
out.println("end");
%>

-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Jennifer
Hochgesang
Sent: Friday, 11 January 2002 10:14
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] xsl:variable


Is it possible to set a variable and use it to grab data from another xml
file?

Here's what I attempted with much failure-

 <xsl:template match="/">
<xsl:variable name="expert1id"
select="sco/core/expert/expert1/id"></xsl:variable>

then.....



<script language="JavaScript">

var expert1layer="<xsl:apply-templates
select="document(/sco/loadexperts/$expert1id/text" />";



</script>

</head>


Thanks-
Jennifer















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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]