You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@apache.org on 2001/04/27 21:58:41 UTC
cvs commit: xml-xalan/java/samples/servlet jspSample.jsp fooparam.xsl
dleslie 01/04/27 12:58:40
Modified: java/samples/servlet fooparam.xsl
Added: java/samples/servlet jspSample.jsp
Log:
1. Added Java Server Page sample submitted by Paul Campbell.
2. Updated fooparam.xml to include the doc text node from the
source document.
Revision Changes Path
1.2 +9 -1 xml-xalan/java/samples/servlet/fooparam.xsl
Index: fooparam.xsl
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/servlet/fooparam.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fooparam.xsl 2001/03/20 17:03:19 1.1
+++ fooparam.xsl 2001/04/27 19:58:39 1.2
@@ -2,6 +2,14 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="param1" select="'default value'"/>
<xsl:template match="doc">
- <html><body><p><xsl:value-of select="$param1"/></p></body></html>
+ <html>
+ <head><title>Stylesheet parameter</title></head>
+ <body>
+ <h2>XML source</h2>
+ <p><xsl:value-of select="."/></p>
+ <h2>Stylesheet parameter</h2>
+ <p>The param1 stylesheet parameter has been set to <xsl:value-of select="$param1"/>.</p>
+ </body>
+ </html>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/java/samples/servlet/jspSample.jsp
Index: jspSample.jsp
===================================================================
<%@ page language="java" contentType="text/html" %>
<%@ page import="javax.xml.transform.*"%>
<%@ page import="javax.xml.transform.stream.*"%>
<html>
<head>
<title>JSP sample passing a parameter to XSL</title>
</head>
<body>
<%
/**
* This JSP uses PMA to set param1 in the
* foo.xsl stylesheet before using the
* stylesheet to transform foo.xml
* and outputing the result.
*
* Invoke the jsp from the appropriate
* context for your servlet/jsp server.
* For example: http://localhost:8080/samples/jspSample.jsp?HellowWorld!&XML=foo.xml&XSL=foo.xsl
* This example assumes that foo.xsl and foo.xml
* are in the same directory.
* Output should be Hello (from foo.xsml) and HelloWorld!
* (value of param1 in foo.xsl).
*@author Paul Campbell seapwc@halcyon.com
*@version $Id: jspSample.jsp,v 1.1 2001/04/27 19:58:40 dleslie Exp $
*/
String paramValue = request.getParameter("PMA");
String xmlFile = request.getParameter("XML");
String xslFile = request.getParameter("XSL");
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer =
tFactory.newTransformer(new StreamSource(xslFile));
transformer.setParameter("param1", paramValue);
transformer.transform(
new StreamSource(xmlFile), new StreamResult(out));
%>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org