You can use the jsp tags. If change the extension from *.xsl to *.jsp and
then use the jsp as you would an xsl e.g.
<%@ page language="java"
import="com.stuff.yourStuff,
com.stuff.yourSchema"
errorPage="error.jsp" %>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:for-each select="<%=yourSchema.someElementTag%>">
<table width="100%">
<tr>
<td>
<input id="whatever" type="text"
value="<%=yourStuff.someValue%>">
<xsl:if test="@<%= yourSchema.someAttributeTag
%>[.!='']">
<xsl:attribute
name="readonly">true</xsl:attribute>
</xsl:if>
</input>
</td>
</tr>
</table>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
We have done this many times.
Joe
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Kesav Kumar
Sent: Thursday, 19 April 2001 5:58 AM
To: Orion-Interest
Subject: RE: JSP Tags in an XSL Template?
You can't use the jsp tags inside the xsl stylesheet. You can pass
parameters to the XSL.
Declare <xsl:param> at the top of your xsl and while calling the
transformation you can pass values to the top level params. If you are
using apache's xalan here is the way to pass values.
In your xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="linkURL" />
<xsl:template match="module">
<link>
<xsl:attribute name="href">
<xsl:value-of select="$linkURL"
disable-output-escaping="yes"/>
<xsl:attribute name="rel">stylesheet</xsl:attribute>
</link>
</xsl:template>
In your java code write the following. The following code is according to
the Xalan1.1. You can see the xalan2 javadoc for the appropriate way of
transformation. In xalan2 the setting of the parameters are in Transformer
class.
public static void Transform(String xmlSourceURL, String xslURL, String
outputURL)
throws java.io.IOException,
java.net.MalformedURLException,
org.xml.sax.SAXException
{
// Use XSLTProcessorFactory to instantiate an XSLTProcessor.
org.apache.xalan.xslt.XSLTProcessor processor =
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
// Set the stylesheet parameters
processor.setStylesheetParam("linkURL", new
org.apache.xalan.xpath.XString("http://xxxlco.com/skldjf"))
// Create the 3 objects the XSLTProcessor needs to perform the
transformation.
org.apache.xalan.xslt.XSLTInputSource xmlSource =
new org.apache.xalan.xslt.XSLTInputSource
("foo.xml");
org.apache.xalan.xslt.XSLTInputSource xslSheet =
new org.apache.xalan.xslt.XSLTInputSource
("foo.xsl");
org.apache.xalan.xslt.XSLTResultTarget xmlResult =
new org.apache.xalan.xslt.XSLTResultTarget
("foo.out");
// Perform the transformation.
processor.process(xmlSource, xslSheet, xmlResult);
}
Kesav Kumar
Software Engineer
Voquette, Inc.
650 356 3740
mailto:[EMAIL PROTECTED]
http://www.voquette.com
Voquette...Delivering Sound Information
-----Original Message-----
From: Dave Ford [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 18, 2001 9:47 AM
To: Orion-Interest
Subject: JSP Tags in an XSL Template?
Is there anyway to embed jsp tags in an xsl template? For example:
<xsl:template match="module">
<link>
<xsl:attribute name="href">
<%= request.getContextPath()%>/StyleSheets/style.css</xsl:attribute>
<xsl:attribute name="rel">stylesheet</xsl:attribute>
</link>
</xsl:template>
If not, is there a better way to add "parameters" to xsl template as I'm
attemting above with the context path?
Thanks,
Dave Ford
Smart Soft - The Java Training Company
http://www.smart-soft.com