[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jennifer Hochgesang Sent: Friday, 11 January 2002 10:14 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|