-jeff
On Wednesday, June 4, 2003, at 07:44 AM, Kris Schneider wrote:
Nope, your XSL should stay the same. The only functional difference of the code
I posted is that it doesn't do the "doc.trim().length() > 0" test. The JSTL
"empty" operator will test for an empty string, but it won't implicitly trim it
first.
Quoting Jeff Kyser <[EMAIL PROTECTED]>:
And none of the markup in the xsl file would have to change? I must say, I do like the tag-based approach better than the scriptlet. I just couldn't get past the problem using the xsl/xerces libraries before.
thanks, might have to give that a shot :)
-jeff
On Wednesday, June 4, 2003, at 07:21 AM, Kris Schneider wrote:
Perhaps JSTL can help make that a bit cleaner:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %> <%@ taglib prefix="nested" uri="http://jakarta.apache.org/struts/tags-nested" %> <%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<html:form action="/cart/ShoppingCartAction"> <html:hidden property="method" value="process"/> <nested:define id="doc" property="xmlDoc" type="java.lang.String"/> <c:if test="${not empty doc}"> <c:import var="xslt" url="/xsl/PrintShoppingCart.xsl"/> <x:transform xml="${doc}" xslt="${xslt}"/> </c:if> </html:form>
Quoting Jeff Kyser <[EMAIL PROTECTED]>:
Thanks Simon.
One of the first difficulties I encountered was with the xsl transform
itself. I posted this (below) earlier, and didn't get any bites. See
<EARLIER POST>...</EARLIER POST> below. I kept getting
handlePageException in PageContextImpl in later versions of
Tomcat/Resin and could only make the following work instead.
(It of course worked fine under Tomcat 4.1.10 and Struts 1.0 and
whatever else is in the production environment, but I needed to
upgrade...
And that (new stuff) started to look a lot like code that did not
belong on a JSP,
hence my question...
-jeff
(what I have working now)
<html:form action="/cart/ShoppingCartAction?method=process"> <nested:define id="doc" property="xmlDoc" type="java.lang.String"/>
<% String xslFile = getServletContext().getRealPath("") + "/xsl/PrintShoppingCart.xsl"; if (doc != null && doc.trim().length() > 0) { TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile)); transformer.transform(new StreamSource(new StringReader(doc)), new StreamResult(out)); } %> </html:form>
<EARLIER POST> Sorry, as I know this is off-topic, but been banging on it most of the day and can't find much on the web either.
Have experienced the same basic problem on:
Tomcat 4.1.24 Resin 2.1.6,8,9
Can take an XML document, apply an XSL stylesheet to it using command-line java tool:
java org.apache.xalan.xslt.Process -IN foo.xml -XSL foo.xsl -OUT foo.html
that works great.
Now, I take the same libraries - xalan.jar, xml-apis.jar, put them in
my web app, and when I hit the jsp that does the same thing, I get:
----- Root Cause -----
javax.servlet.ServletException: org/apache/xalan/xslt/XSLTInputSource
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageCo nt
ex
tImpl.java:536)
at
org.apache.jsp.BrowseCatalog_jsp._jspService(BrowseCatalog_jsp.java: 13
0)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
Now, from what I can tell, XSLTInputSource is deprecated from an earlier version of xalan.jar
So, I take the xalan.jar file from a Tomcat 4.1.10 install that *does*
work, and
I get another lovely exception, failing to find
org.apache.xalan.xslt.Process.getDefaultLiaison.
(or something like that...)
Can't seem to isolate this.
anybody seen this, or have any suggestions?
TIA,
-jeff </EARLIER_POST>
-------------------------------------------------------------------- -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-- Kris Schneider <mailto:[EMAIL PROTECTED]> D.O.Tech <http://www.dotech.com/>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Kris Schneider <mailto:[EMAIL PROTECTED]> D.O.Tech <http://www.dotech.com/>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]