You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Ben Sifuentes <bs...@cysive.com> on 2000/12/14 04:44:27 UTC

JSP and Xalan & Xerces

Wel'll I've tried all the examples defined by the XSL TAGLIB binary
distribution.
With no success. Could one of the Xalan & Xerces developers please help?

Using this example:

<%@taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0"
    prefix="xsltlib" %>
<%
    StringBuffer b = new StringBuffer();
    b.append("<errorMsg>");
    b.append("<text>Invalid UserID,try again</text>");
    b.append("</errorMsg>");
%>

<xsltlib:apply xsl="file:///D:/tomcat/webapps/airbank/xsl/errorWML.xsl">
<%=b.toString()%>
</xsltlib:apply>


I get the following error:

avax.servlet.jsp.JspException: Missing resource
'file:///D:/tomcat/webapps/airbank/xsl/errorWML.xsl'
	at org.apache.taglibs.xsl.ApplyTag.getInputSource(ApplyTag.java:320)
	at org.apache.taglibs.xsl.ApplyTag.doEndTag(ApplyTag.java:262)
	at
_0002fsample_0002ejspsample_jsp_0._jspService(_0002fsample_0002ejspsample_js
p_0.java, Compiled Code)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled
Code)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:156)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Unknown Source)

Now if I change the following lines:

<xsltlib:apply xsl="file:///D:/tomcat/webapps/airbank/xsl/errorWML.xsl">
<%=b.toString()%>
</xsltlib:apply>

to

<xsltlib:apply xml="/xsl/error.xml xsl="xsl/errorWML.xsl"/>

It seems to get further than previous and receives the following error when
running:

java.lang.NullPointerException
	at
org.apache.xalan.xslt.StylesheetRoot.makeSAXSerializer(StylesheetRoot.java:5
20)
	at org.apache.xalan.xslt.StylesheetRoot.process(StylesheetRoot.java,
Compiled Code)
	at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java,
Compiled Code)
	at org.apache.taglibs.xsl.ApplyTag.doEndTag(ApplyTag.java:272)
	at
_0002fsample_0002ejspsample_jsp_0._jspService(_0002fsample_0002ejspsample_js
p_0.java, Compiled Code)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java, Compiled
Code)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:156)
	at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
	at java.lang.Thread.run(Unknown Source)


I really need help here. I've run into a brick wall here and have run out of
ideas.

If I'm posting to wrong newgroup or if there would be a better place to
direct my question please advise.

Thanks,
-Ben


Re: JSP and Xalan & Xerces

Posted by Gary L Peskin <ga...@firstech.com>.
Ben Sifuentes wrote:
> If I'm posting to wrong newgroup or if there would be a better place to
> direct my question please advise.

I think you might do better on the taglibs-user mailing list. 
Nevertheless, I'll take a stab at it.  Bear in mind that I'm not a
Tomcat user so if I sound like an idiot, please excuse me and feel free
to ignore my advice.

> Wel'll I've tried all the examples defined by the XSL TAGLIB binary
> distribution.
> With no success. Could one of the Xalan & Xerces developers please help?
> 
> Using this example:
> 
> <%@taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0"
>     prefix="xsltlib" %>
> <%
>     StringBuffer b = new StringBuffer();
>     b.append("<errorMsg>");
>     b.append("<text>Invalid UserID,try again</text>");
>     b.append("</errorMsg>");
> %>
> 
> <xsltlib:apply xsl="file:///D:/tomcat/webapps/airbank/xsl/errorWML.xsl">
> <%=b.toString()%>
> </xsltlib:apply>
> 
> I get the following error:
> 
> javax.servlet.jsp.JspException: Missing resource
> 'file:///D:/tomcat/webapps/airbank/xsl/errorWML.xsl'
>         at org.apache.taglibs.xsl.ApplyTag.getInputSource(ApplyTag.java:320)

This error is caused by 

  context.getResourceAsStream(resource)

returning a null value.  This happens when the method cannot locate the
resource.  The javadoc for the ServletContext class (which is the class
for context) indicates "The path must begin with a "/" and is
interpreted as relative to the current context root."  So, it seems like
the servlet cannot locate the xsl value that you specified since you
specified a full URL which is why this error is being returned.

> Now if I change the following lines:
> 
> <xsltlib:apply xsl="file:///D:/tomcat/webapps/airbank/xsl/errorWML.xsl">
> <%=b.toString()%>
> </xsltlib:apply>
> 
> to
> 
> <xsltlib:apply xml="/xsl/error.xml xsl="xsl/errorWML.xsl"/>

Presumably you mean here: 

  <xsltlib:apply xml="/xsl/error.xml xsl="/xsl/errorWML.xsl"/>

That is, with the leading "/" in the xsl attribute value as discussed
above.  Is this correct?

> It seems to get further than previous and receives the following error when
> running:
> 
> java.lang.NullPointerException
>         at
> org.apache.xalan.xslt.StylesheetRoot.makeSAXSerializer(StylesheetRoot.java:5
> 20)

I'm sort of at a loss here.  A preliminary look at the code indicates
that it wasn't able to generate a Serializer for this format.  Do you
have any output encoding specified in your stylesheet?

What I would suggest here is to first eliminate any problems with the
xml and xsl by running your transformation from the command line. 
Verify that it works there.  If it does, then your problem is probably
not with Xalan but with the taglib implementation of the apply tag.

In order to debug this, I think you'll either need a debugger that can
examine the XSLTResultTarget that is being passed to the Xalan
XSLTProcessor.process() method or you'll need to be able to modify the
source of ApplyTag.java and put in a bunch of System.err.print()
statements just before the call so that we can see exactly what's
happening.  Can you rebuild the ApplyTag from the source so that we can
insert debugging type print statements?

At any rate, I'd start with trying the transformation from the command
line and making sure it works there.

HTH,
Gary