You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Rick Bullotta <ri...@lighthammer.com> on 2001/10/02 19:48:00 UTC

Xalan 2.2 D11 - Change in xalan:evaluate - Bug?

Xalan 2.2 D11 does not seem to (reliably) recognize variable references in
an expression passed to xalan:evaluate.  Has there been a significant change
in this extension function that we should be aware of?

- Rick


Re: XSLTC: help - Error when trying to compile servlets - longish w/ code samples

Posted by Tom Amiro <To...@Sun.COM>.
Hi Rob,

Here's an example of an XSLTC servlet using TrAX that 
may help you figure things out.

Tom

> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.util.Enumeration;
> import java.net.URL;
> 
> import org.xml.sax.*;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.TransformerConfigurationException;
> import javax.xml.transform.Templates;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.Source;
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.transform.stream.StreamResult;
> 
> public final class XSLTCTraxServlet extends HttpServlet {
> 
>     private static Templates templates = null;
>     private static TransformerFactory tFactory = null;
> 
>     public void init(ServletConfig config) throws ServletException {
> 
> 	super.init(config);
> 
> 	System.setProperty("javax.xml.transform.TransformerFactory",
> 			   "org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
> 
> 	tFactory = TransformerFactory.newInstance();
> 	String xsl = "search.xsl";
> 	Source xslSource = null;
> 
> 	try {
> 	    System.out.println("in the try");
> 	    // Get the stylesheet.
> 	    if (xsl != null && xsl.length()> 0)
> 		xslSource = new StreamSource(xsl);
> 	    if (xslSource != null) { // Now do we have a stylesheet?
> 		// if yes, create template for reuse
> 		System.out.println("xslSource is " + xslSource);
> 		System.out.println("tFactory is " + tFactory);
> 		templates = tFactory.newTemplates(xslSource);
> 		System.out.println("template is " + templates);
> 	    }
> 	    else {
> 		System.out.println("No Stylesheet!");
> 	    }
> 	}
> 	catch (TransformerConfigurationException e) {
> 	    System.out.println("can't make templates, " + e.getMessage());
> 	    e.printStackTrace(System.err);
> 	}
> 	catch (Exception e) {
> 	    e.printStackTrace(System.out);    
> 	}
>     } //end of init
> 
> 
>     public void doPost (HttpServletRequest request,
> 			HttpServletResponse response)
> 	throws ServletException, IOException {
> 
> 	// The servlet returns HTML; charset is UTF8.
> 	// See ApplyXSLT.getContentType() to get output properties from <xsl:output>.
> 	response.setContentType("text/html; charset=UTF-8"); 
> 	PrintWriter out = response.getWriter();
> 	Source xmlSource = null;
> 	String xml = "http://glrr.east:8080/calendar/calendar.xml";
> 	try {
> 	    if (xml != null && xml.length()> 0) {
> 		xmlSource = new StreamSource(new URL(xml).openStream());
> 	    }
> 	    else {
> 		out.write("No XML Input Document!");
> 	    }
> 	    long start = System.currentTimeMillis();
> 	    Transformer transformer = null;
> 	    System.out.println("in doPost, templates is " + templates);
> 	    transformer = templates.newTransformer();
> 	    setParameters(transformer, request); // Set stylesheet params.
> 	    // Perform the transformation.
> 	    transformer.transform(xmlSource, new StreamResult(out));
> 	    long stop = System.currentTimeMillis();
> 	    out.println("<!-- transformed in "+
> 			(stop-start)+"ms -->");
> 	}
> 	catch (Exception e) {
> 	    e.printStackTrace(out);    
> 	}
> 	out.close();
>     } // end of doPost
>   
>     // Get parameters from the request URL.
>     String getRequestParam(HttpServletRequest request, String param) {
> 	if (request != null) { 
> 	    String paramVal = request.getParameter(param); 
> 	    return paramVal;
> 	}
> 	return null;
>     }
>   
>     // Set stylesheet parameters from the request URL.
>     void setParameters(Transformer transformer, HttpServletRequest request) {
> 	Enumeration paramNames = request.getParameterNames();
> 	while (paramNames.hasMoreElements()) {
> 	    String name = (String) paramNames.nextElement();
> 	    String other;
> 	    try {
> 		String value = request.getParameter(name);
> 		if (!(name.equals("style") || name.equals("source") || name.equals("action") || name.equals("class"))) {
> 		    if(name.equals("states")){
> 			value = "";
> 			String [] values = request.getParameterValues("states");
> 			value = values[0];
> 			for (int i = 1; i < values.length; i++){
> 			    value = value + " " + values[i];
> 			}
> 		    } else {
> 			value = request.getParameter(name);
> 		    } // set country to ocountry so stylesheet only deals with country
> 		    if(name.equals("country") && value.equals("Other")){
> 			other = request.getParameter("ocountry");
> 			value = new String(other);
> 		    }
> 		    if(name.equals("town") && (value.length() < 2)){
> 			value = new String("");
> 		    }
> 		    if(name.equals("zip") && (value.length() < 2)){
> 			value = new String("");
> 		    }
> 		    if(name.equals("ldist") && (value != null)){
> 			String lval = request.getParameter("ldist");
> 			String ulval = request.getParameter("lunits");
> 			double ldistance = Double.parseDouble(lval) * Double.parseDouble(ulval);
> 			value = new String(Double.toString(ldistance));
> 		    }
> 		    if(name.equals("gdist") && (value != null)){
> 			String gval = request.getParameter("gdist");
> 			String ugval = request.getParameter("gunits");
> 			double ldistance = Double.parseDouble(gval) * Double.parseDouble(ugval);
> 			value = new String(Double.toString(ldistance));
> 		    }
> 		    if(value != null && value.length() >= 1){
> 			transformer.setParameter(name, value);
> 		    }
> 		}// end of if not style, source, action or class
> 	    }
> 
> 	    catch (Exception e) { }
> 
> 	}
>     }
> }

RE: Templates object created but still TransformerConfigurationException

Posted by Robert Koberg <ro...@koberg.com>.
I did not mention this, but I did change the filename to use and underscore
char instead of a dash, but I still get the same error. THat is why I was
wondering about WEB-INF.

best,
-Rob

> -----Original Message-----
> From: Robert Koberg [mailto:rob@koberg.com]
> Sent: Friday, October 05, 2001 12:22 PM
> To: xalan-dev@xml.apache.org
> Cc: xsltc-team@east.sun.com
> Subject: RE: Templates object created but still
> TransformerConfigurationException
>
>
> When I set the template I use the full path to the file:
> file:/home/gudgeon/sites/master/WEB-INF/tool/site_chooser.xsl
> // /WEB-INF/tool/site_chooser.xsl
> String value = (String) CONTEXT.getInitParameter("site_chooser");
> xsl = CONTEXT.getResource(value).toString();
>
> Since I am not in the same directory as the servlet will the base name use
> the entire URI? If this is the case, it is a MAJOR problem
> because I cannot
> rename WEB-INF.  Is this the case?
>
> WEB-INF in a j2ee servlet container is a protected directory.
> ANything below
> will be blocked by an http request.  So I keep all my XML content and XSL
> stylesheets under there.
>
> Note: this works fine when I don't use templates.
>
> best,
> -Rob
>
>
> > -----Original Message-----
> > From: Tom Amiro [mailto:Tom.Amiro@sun.com]
> > Sent: Friday, October 05, 2001 12:05 PM
> > To: Robert Koberg
> > Cc: Tom.Amiro@sun.com; xalan-dev@xml.apache.org; xsltc-team@east.sun.com
> > Subject: Re: Templates object created but still
> > TransformerConfigurationException
> >
> >
> > Hi Robert,
> >
> > Thanks for sending the files. I know what the problem is and
> > you can work around it for now. The stylesheet has a hypen
> > in the name (site-chooser.xsl). The generated class file
> > and auxilliary files get the basename site_chooser. So
> > the class is not being found. For now could you name
> > your stylesheets without any hyphens in them?
> >
> > I know realize that this problem is a duplicate of
> > bug 2399 on "ClassLoaders for WAS Often Fail on compiled
> > classes". I'll add some info to that bug.
> >
> > Tom
> >
>


RE: Templates object created but still TransformerConfigurationException

Posted by Robert Koberg <ro...@koberg.com>.
When I set the template I use the full path to the file:
file:/home/gudgeon/sites/master/WEB-INF/tool/site_chooser.xsl
// /WEB-INF/tool/site_chooser.xsl
String value = (String) CONTEXT.getInitParameter("site_chooser");
xsl = CONTEXT.getResource(value).toString();

Since I am not in the same directory as the servlet will the base name use
the entire URI? If this is the case, it is a MAJOR problem because I cannot
rename WEB-INF.  Is this the case?

WEB-INF in a j2ee servlet container is a protected directory. ANything below
will be blocked by an http request.  So I keep all my XML content and XSL
stylesheets under there.

Note: this works fine when I don't use templates.

best,
-Rob


> -----Original Message-----
> From: Tom Amiro [mailto:Tom.Amiro@sun.com]
> Sent: Friday, October 05, 2001 12:05 PM
> To: Robert Koberg
> Cc: Tom.Amiro@sun.com; xalan-dev@xml.apache.org; xsltc-team@east.sun.com
> Subject: Re: Templates object created but still
> TransformerConfigurationException
>
>
> Hi Robert,
>
> Thanks for sending the files. I know what the problem is and
> you can work around it for now. The stylesheet has a hypen
> in the name (site-chooser.xsl). The generated class file
> and auxilliary files get the basename site_chooser. So
> the class is not being found. For now could you name
> your stylesheets without any hyphens in them?
>
> I know realize that this problem is a duplicate of
> bug 2399 on "ClassLoaders for WAS Often Fail on compiled
> classes". I'll add some info to that bug.
>
> Tom
>


Re: Templates object created but still TransformerConfigurationException

Posted by Tom Amiro <To...@sun.com>.
Hi Robert,

Thanks for sending the files. I know what the problem is and 
you can work around it for now. The stylesheet has a hypen
in the name (site-chooser.xsl). The generated class file 
and auxilliary files get the basename site_chooser. So 
the class is not being found. For now could you name 
your stylesheets without any hyphens in them?

I know realize that this problem is a duplicate of 
bug 2399 on "ClassLoaders for WAS Often Fail on compiled 
classes". I'll add some info to that bug.

Tom

Templates object created but still TransformerConfigurationException

Posted by Robert Koberg <ro...@koberg.com>.
I have tried Tom's example but I am still having problems. I am attaching my
file for Tom (if anybody else is willing to take a look I would be more than
happy to send it!). The template is created as it shows in the console
output. I explicitly set the system properties for the factories like this:
System.setProperty("javax.xml.transform.TransformerFactory",
	"org.apache.xalan.xsltc.trax.TransformerFactoryImpl");

System.setProperty("javax.xml.parsers.SAXParserFactory",
      "org.apache.xerces.jaxp.SAXParserImpl");

The ERROR that is thrown says there is a TransformerConfigurationException
and that the template does not contain a valid translet class definition.
What do I do to fix this?

TIA,
-Rob
---------------------------

My CONSOLE says that the template is created:

xsl: file:/home/gudgeon/sites/master/WEB-INF/tool/site-chooser.xsl
in the try
xslSource is javax.xml.transform.stream.StreamSource@52c4d9
tFactory is org.apache.xalan.xsltc.trax.TransformerFactoryImpl@72380
template is org.apache.xalan.xsltc.trax.TemplatesImpl@7725c4
in doPost, templates is org.apache.xalan.xsltc.trax.TemplatesImpl@7725c4
---------------------------

But I get this error in the browser (any ideas???):

javax.xml.transform.TransformerConfigurationException: This template does
not contain a valid translet class definition.
	at
org.apache.xalan.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImpl.java:
199)
	at com.koberg.makecontent.MasterLogin.doPost(MasterLogin.java:114)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
	at
com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:8
2)
	at com.caucho.server.http.Invocation.service(Invocation.java:277)
	at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
	at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
	at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
	at java.lang.Thread.run(Thread.java:484)

Re: XSLTC Xalan samples

Posted by Tom Amiro <To...@Sun.COM>.
Sorry I didn't think of this before, but the exception 

>de/fub/bytecode/generic/InstructionConstants
>java.lang.NoClassDefFoundError: de/fub/bytecode/generic/InstructionConstants

implies you don't have BCEL.jar in your CLASSPATH. 

I'm using Tomcat and have the following classpath, which lets me run both Xalan and XSLTC 
servlets.

setenv CLASSPATH 
.:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/crimson.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/jaxp.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/xerces.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/xsltc.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/xalan.jar:/usr/local/tomcat/webapps/calendar/WEB_INF/classes/calendar:/usr/local/tomcat/webapps/calendar/WEB-INF/classes::/usr/local/tomcat/webapps/calendar/WEB-INF/lib/runtime.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/BCEL.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/java_cup.jar:/usr/local/tomcat/webapps/calendar/WEB-INF/lib/JLex.jar:/usr/local/tomcat/lib/ant.jar:/usr/local/tomcat/lib/jasper.jar:/usr/local/tomcat/lib/jaxp.jar:/usr/local/tomcat/lib/parser.jar:/usr/local/tomcat/lib/servlet.jar:/usr/local/tomcat/lib/test:/usr/local/tomcat/lib/webserver.jar:/usr/local/j2sdk/lib/tools.jar:/usr/local/j2sdk/lib/dt.jar

Tom

RE: XSLTC Xalan samples

Posted by Robert Koberg <ro...@koberg.com>.
Hi, Thanks for answering!

I am using xalan-j_2_1_0 (the latest stable build, which I should have
mentioned...) and when I look in the xsltc.jar I see the path I am using -
so that can't be it. Or should I be using the beta code? I haven't been
having problems with SAX, so I think those lines are OK. I made a simple
example to hopefully narrow it down but I still get the same message (which
is useless to me, unfortunately).

Here is the simple servlet:

package com.koberg.makecontent;

import java.io.*;
import java.util.*;
import java.net.URL;

import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.xalan.xsltc.compiler.*;
import org.apache.xalan.xsltc.compiler.util.*;
import org.apache.xalan.xsltc.util.getopt.*;

public class Test extends HttpServlet {

   public void init() throws ServletException {
      newTransformer();
   }

   public void newTransformer() {
      XSLTC xsltc = new XSLTC();
   }
}
------------------------------------------------
This still gives the error:

[2001/10/02 13:37:28] com.koberg.makecontent.Test: init
[2001/10/02 13:37:28] de/fub/bytecode/generic/InstructionConstants
java.lang.NoClassDefFoundError: de/fub/bytecode/generic/InstructionConstants
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
	at org.apache.xalan.xsltc.compiler.XSLTC.<init>(XSLTC.java:138)
	at com.koberg.makecontent.Test.newTransformer(Test.java:21)
	at com.koberg.makecontent.Test.init(Test.java:17)
	at javax.servlet.GenericServlet.init(GenericServlet.java:82)
	at com.caucho.server.http.Application.createServlet(Application.java:2212)
	at com.caucho.server.http.Application.loadServlet(Application.java:2169)
	at com.caucho.server.http.Application.initServlets(Application.java:1404)
	at com.caucho.server.http.Application.init(Application.java:1359)
	at com.caucho.server.http.VirtualHost.init(VirtualHost.java:456)
	at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:480)
	at com.caucho.server.http.ServletServer.init(ServletServer.java:386)
	at com.caucho.server.http.ServletServer.<init>(ServletServer.java:214)
	at com.caucho.server.http.ResinServer.init(ResinServer.java:279)
	at com.caucho.server.http.ResinServer.main(ResinServer.java:852)
	at com.caucho.server.http.HttpServer.main(HttpServer.java:93)
[2001/10/02 13:37:28] can't load servlet `Test'



> -----Original Message-----
> From: Tom Amiro [mailto:Tom.Amiro@Sun.COM]
> Sent: Tuesday, October 02, 2001 1:47 PM
> To: xalan-dev@xml.apache.org
> Subject: Re: XSLTC Xalan samples
>
>
>
>
> Robert Koberg wrote:
> >
> > I am trying to get some of the translet examples to work but I
> keep getting
> > an error(as in my previous post about XSLTC today):
> >
> > java.lang.NoClassDefFoundError:
> de/fub/bytecode/generic/InstructionConstants
> > etc...
> >
> > Can anybody tell me what is causing this? Or tell me just how to fix the
> > problem?
> >
> > My jdk1.3/jre/lib/jaxp.properties has the following:
> >
> javax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.runt
> ime.Transf
> > ormerFactoryImpl
>
> There was a change in the location of the TransformerFactoryImpl. It is
> under org.apache.xalan.xsltc.trax.TransformerFactoryImpl.
>
>
> >
> javax.xml.parsers.DocumentBuilderFactory=javax.xml.parsers.Documen
> tBuilderFa
> > ctory
> > javax.xml.parsers.SAXParserFactory=javax.xml.parsers.SAXParserFactory
>
> The above line doesn look right. I think it should be
>
>
> javax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserImpl
>
> or
>
>
> javax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserImpl
>
> /tom
> >
> > -- Please help!!!
> >
> > thanks,
> > -Rob
>


Re: XSLTC Xalan samples

Posted by Tom Amiro <To...@Sun.COM>.

Robert Koberg wrote:
> 
> I am trying to get some of the translet examples to work but I keep getting
> an error(as in my previous post about XSLTC today):
> 
> java.lang.NoClassDefFoundError: de/fub/bytecode/generic/InstructionConstants
> etc...
> 
> Can anybody tell me what is causing this? Or tell me just how to fix the
> problem?
> 
> My jdk1.3/jre/lib/jaxp.properties has the following:
> javax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.runtime.Transf
> ormerFactoryImpl

There was a change in the location of the TransformerFactoryImpl. It is 
under org.apache.xalan.xsltc.trax.TransformerFactoryImpl.


> javax.xml.parsers.DocumentBuilderFactory=javax.xml.parsers.DocumentBuilderFa
> ctory
> javax.xml.parsers.SAXParserFactory=javax.xml.parsers.SAXParserFactory

The above line doesn look right. I think it should be 

	javax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserImpl

or 

	javax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserImpl

/tom
> 
> -- Please help!!!
> 
> thanks,
> -Rob

XSLTC Xalan samples

Posted by Robert Koberg <ro...@koberg.com>.
I am trying to get some of the translet examples to work but I keep getting
an error(as in my previous post about XSLTC today):

java.lang.NoClassDefFoundError: de/fub/bytecode/generic/InstructionConstants
etc...

Can anybody tell me what is causing this? Or tell me just how to fix the
problem?

My jdk1.3/jre/lib/jaxp.properties has the following:
javax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.runtime.Transf
ormerFactoryImpl
javax.xml.parsers.DocumentBuilderFactory=javax.xml.parsers.DocumentBuilderFa
ctory
javax.xml.parsers.SAXParserFactory=javax.xml.parsers.SAXParserFactory

-- Please help!!!

thanks,
-Rob


RE: XSLTC: help - Error when trying to compile servlets - longish w/ code samples

Posted by Robert Koberg <ro...@koberg.com>.
I noticed I did not modify the second newTransformer (the one that creates
templates) correctly for the email. THe correct method is (sorry):

public void newTransformer(String id, URL xsl)
		throws TransformerConfigurationException {

      File xslt_file = new File(xsl.toString());
      long xsl_last_mod = xslt_file.lastModified();

      Templates entry = (Templates) CONTEXT.getAttribute(id);

      if (entry == null) {
         Source xsl_source = new StreamSource(xslt_file);
         TransformerFactory transfact = TransformerFactory.newInstance();
         Templates templates = transfact.newTemplates(xsl_source);
System.out.println(id + " Templates Obj: " + templates);

         CONTEXT.setAttribute(id, templates);

      }
   }

> -----Original Message-----
> From: Robert Koberg [mailto:rob@koberg.com]
> Sent: Tuesday, October 02, 2001 12:23 PM
> To: xalan-dev@xml.apache.org
> Subject: XSLTC: help - Error when trying to compile servlets - longish
> w/ code samples
>
>
> Hello!
>
> I am trying to compile multiple stylesheets at web-appserver-startup.  I
> have tried a couple of ways.
> -------------------------------------
> First way
> -------------------------------------
> The most simple sets the URL to an XSL resource and then sends it to:
>
> public void newTransformer(URL xsl) {
>       XSLTC xsltc = new XSLTC();
> 	xsltc.init();
> 	xsltc.compile(xsl);
>    }
>
> Doing this causes an Error in the compilation of the Init Servlet
> [Error 1 -
> below]. I have the jaxp.properties file with the following entries:
> javax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.runt
> ime.Transf
> ormerFactoryImpl
> javax.xml.parsers.DocumentBuilderFactory=javax.xml.parsers.Documen
> tBuilderFa
> ctory
> javax.xml.parsers.SAXParserFactory=javax.xml.parsers.SAXParserFactory
> -------------------------------------
> Second way
> -------------------------------------
> If I try another way to compile the XSL, the System output says the
> ...xsltc.TransletTemplate@xxxxxs were created:
>
> public void newTransformer(String id, URL xsl) {
>
>       File xslt_file = new File(xsl);
>       long xsl_last_mod = xslt_file.lastModified();
>       // CONTEXT = global ServletContext var - basically a Hashtable
>       Templates entry = (Templates) CONTEXT.getAttribute(id);
>
>       if (entry == null) {
>          Source xsl_source = new StreamSource(xslt_file);
>          TransformerFactory transfact = TransformerFactory.newInstance();
>          Templates templates = transfact.newTemplates(xsl_source);
> System.out.println(id + " Templates Obj: " + templates);
>          // global ServletContext var - basically a Hashtable
>          CONTEXT.setAttribute(id, templates);
>
>       }
>    }
>
> When I try to access the compiled XSL with the method directly
> below I get a
> different error sent to the browser (500). They seem to be the same error
> [Error 2 - below].
>
> public void doTransform(String source_uri,
> 				Templates style,
> 				Hashtable params,
> 				PrintWriter out)
>     throws FileNotFoundException, TransformerException  {
>
>       try {
>
>          Transformer transformer = style.newTransformer();
>          transformer.transform ((Source) new InputSource(source_uri),
> 					new StreamResult(out));
>
>       } catch (Exception e) {
>          out.write(e.getMessage());
>          e.printStackTrace(out);
>       }
>    }
>
>
> ----------------------------------------------
> Please help. I don't understand what I am doing wrong.
>
> Thanks!
> -Rob
> ----------------------------------------------
> ERRORS
> ===== ERROR 1 =================
> [2001/10/02 12:01:19] de/fub/bytecode/generic/InstructionConstants
> java.lang.NoClassDefFoundError:
> de/fub/bytecode/generic/InstructionConstants
> 	at java.lang.ClassLoader.defineClass0(Native Method)
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> 	at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> 	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> 	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> 	at java.lang.ClassLoader.defineClass0(Native Method)
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> 	at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> 	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> 	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> 	at org.apache.xalan.xsltc.compiler.XSLTC.<init>(XSLTC.java:138)
> 	at
> com.koberg.makecontent.InitMasterApp.newTransformer(InitMasterApp.java:60)
> 	at com.koberg.makecontent.InitMasterApp.init(InitMasterApp.java:43)
> 	at javax.servlet.GenericServlet.init(GenericServlet.java:82)
> 	at
> com.caucho.server.http.Application.createServlet(Application.java:2212)
> 	at
> com.caucho.server.http.Application.loadServlet(Application.java:2169)
> 	at
> com.caucho.server.http.Application.initServlets(Application.java:1404)
> 	at com.caucho.server.http.Application.init(Application.java:1359)
> 	at com.caucho.server.http.VirtualHost.init(VirtualHost.java:456)
> 	at
> com.caucho.server.http.ServletServer.initHosts(ServletServer.java:480)
> 	at com.caucho.server.http.ServletServer.init(ServletServer.java:386)
> 	at
> com.caucho.server.http.ServletServer.<init>(ServletServer.java:214)
> 	at com.caucho.server.http.ResinServer.init(ResinServer.java:279)
> 	at com.caucho.server.http.ResinServer.main(ResinServer.java:852)
> 	at com.caucho.server.http.HttpServer.main(HttpServer.java:93)
> ----------------------------------------
> ========= ERROR 2 ===========
> java.lang.NoClassDefFoundError:
> de/fub/bytecode/generic/InstructionConstants
> 	at java.lang.ClassLoader.defineClass0(Native Method)
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> 	at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> 	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> 	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> 	at java.lang.ClassLoader.defineClass0(Native Method)
> 	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> 	at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
> 	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> 	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> 	at org.apache.xalan.xsltc.compiler.XSLTC.<init>(XSLTC.java:138)
> 	at
> org.apache.xalan.xsltc.runtime.TransletTemplates.newTransformer(Tr
ansletTemp
> lates.java:92)
> 	at
> com.koberg.makecontent.MCTransformer.doTransform(MCTransformer.java:29)
> 	at com.koberg.makecontent.MasterLogin.doPost(MasterLogin.java:58)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
> 	at
> com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServ
let.java:8
> 2)
> 	at com.caucho.server.http.Invocation.service(Invocation.java:272)
> 	at
> com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:128)
> 	at
> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
> 	at
> com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
> 	at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
> 	at java.lang.Thread.run(Thread.java:484)
>


XSLTC: help - Error when trying to compile servlets - longish w/ code samples

Posted by Robert Koberg <ro...@koberg.com>.
Hello!

I am trying to compile multiple stylesheets at web-appserver-startup.  I
have tried a couple of ways.
-------------------------------------
First way
-------------------------------------
The most simple sets the URL to an XSL resource and then sends it to:

public void newTransformer(URL xsl) {
      XSLTC xsltc = new XSLTC();
	xsltc.init();
	xsltc.compile(xsl);
   }

Doing this causes an Error in the compilation of the Init Servlet [Error 1 -
below]. I have the jaxp.properties file with the following entries:
javax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.runtime.Transf
ormerFactoryImpl
javax.xml.parsers.DocumentBuilderFactory=javax.xml.parsers.DocumentBuilderFa
ctory
javax.xml.parsers.SAXParserFactory=javax.xml.parsers.SAXParserFactory
-------------------------------------
Second way
-------------------------------------
If I try another way to compile the XSL, the System output says the
...xsltc.TransletTemplate@xxxxxs were created:

public void newTransformer(String id, URL xsl) {

      File xslt_file = new File(xsl);
      long xsl_last_mod = xslt_file.lastModified();
      // CONTEXT = global ServletContext var - basically a Hashtable
      Templates entry = (Templates) CONTEXT.getAttribute(id);

      if (entry == null) {
         Source xsl_source = new StreamSource(xslt_file);
         TransformerFactory transfact = TransformerFactory.newInstance();
         Templates templates = transfact.newTemplates(xsl_source);
System.out.println(id + " Templates Obj: " + templates);
         // global ServletContext var - basically a Hashtable
         CONTEXT.setAttribute(id, templates);

      }
   }

When I try to access the compiled XSL with the method directly below I get a
different error sent to the browser (500). They seem to be the same error
[Error 2 - below].

public void doTransform(String source_uri,
				Templates style,
				Hashtable params,
				PrintWriter out)
    throws FileNotFoundException, TransformerException  {

      try {

         Transformer transformer = style.newTransformer();
         transformer.transform ((Source) new InputSource(source_uri),
					new StreamResult(out));

      } catch (Exception e) {
         out.write(e.getMessage());
         e.printStackTrace(out);
      }
   }


----------------------------------------------
Please help. I don't understand what I am doing wrong.

Thanks!
-Rob
----------------------------------------------
ERRORS
===== ERROR 1 =================
[2001/10/02 12:01:19] de/fub/bytecode/generic/InstructionConstants
java.lang.NoClassDefFoundError: de/fub/bytecode/generic/InstructionConstants
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
	at org.apache.xalan.xsltc.compiler.XSLTC.<init>(XSLTC.java:138)
	at
com.koberg.makecontent.InitMasterApp.newTransformer(InitMasterApp.java:60)
	at com.koberg.makecontent.InitMasterApp.init(InitMasterApp.java:43)
	at javax.servlet.GenericServlet.init(GenericServlet.java:82)
	at com.caucho.server.http.Application.createServlet(Application.java:2212)
	at com.caucho.server.http.Application.loadServlet(Application.java:2169)
	at com.caucho.server.http.Application.initServlets(Application.java:1404)
	at com.caucho.server.http.Application.init(Application.java:1359)
	at com.caucho.server.http.VirtualHost.init(VirtualHost.java:456)
	at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:480)
	at com.caucho.server.http.ServletServer.init(ServletServer.java:386)
	at com.caucho.server.http.ServletServer.<init>(ServletServer.java:214)
	at com.caucho.server.http.ResinServer.init(ResinServer.java:279)
	at com.caucho.server.http.ResinServer.main(ResinServer.java:852)
	at com.caucho.server.http.HttpServer.main(HttpServer.java:93)
----------------------------------------
========= ERROR 2 ===========
java.lang.NoClassDefFoundError: de/fub/bytecode/generic/InstructionConstants
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
	at org.apache.xalan.xsltc.compiler.XSLTC.<init>(XSLTC.java:138)
	at
org.apache.xalan.xsltc.runtime.TransletTemplates.newTransformer(TransletTemp
lates.java:92)
	at com.koberg.makecontent.MCTransformer.doTransform(MCTransformer.java:29)
	at com.koberg.makecontent.MasterLogin.doPost(MasterLogin.java:58)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
	at
com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:8
2)
	at com.caucho.server.http.Invocation.service(Invocation.java:272)
	at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:128)
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:216)
	at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
	at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
	at java.lang.Thread.run(Thread.java:484)


RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?

Posted by Rick Bullotta <ri...@lighthammer.com>.
Ignore last posting!  You can already tell why...<g>  Cut and paste strikes
again...the evaluate issue still exists, though.

-----Original Message-----
From: Rick Bullotta [mailto:rick.bullotta@lighthammer.com]
Sent: Tuesday, October 02, 2001 2:27 PM
To: xalan-dev@xml.apache.org
Subject: RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?


As a followup, the issue appears elsewhere, for example, given the following
XML document:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Rowsets DateCreated="2001-10-02 12:59:13" EndDate="2001-10-02 12:59:13"
StartDate="2001-10-02 11:59:13" Version="9.0">
	<Rowset>

.....


RE: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?

Posted by Rick Bullotta <ri...@lighthammer.com>.
As a followup, the issue appears elsewhere, for example, given the following
XML document:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Rowsets DateCreated="2001-10-02 12:59:13" EndDate="2001-10-02 12:59:13"
StartDate="2001-10-02 11:59:13" Version="9.0">
	<Rowset>
		<Columns>
			<Column Description="LotID" MaxRange="1.0" MinRange="0.0" Name="LotID"
SQLDataType="12" SourceColumn="LotID"/>
			<Column Description="MaterialName" MaxRange="1.0" MinRange="0.0"
Name="MaterialName" SQLDataType="12" SourceColumn="MaterialName"/>
			<Column Description="Location" MaxRange="1.0" MinRange="0.0"
Name="Location" SQLDataType="12" SourceColumn="Location"/>
			<Column Description="QueuedQty" MaxRange="1.0" MinRange="0.0"
Name="QueuedQty" SQLDataType="6" SourceColumn="QueuedQty"/>
			<Column Description="StartedQty" MaxRange="1.0" MinRange="0.0"
Name="StartedQty" SQLDataType="6" SourceColumn="StartedQty"/>
			<Column Description="HoldStatus" MaxRange="1.0" MinRange="0.0"
Name="HoldStatus" SQLDataType="1" SourceColumn="HoldStatus"/>
			<Column Description="QuarantineStatus" MaxRange="1.0" MinRange="0.0"
Name="QuarantineStatus" SQLDataType="1" SourceColumn="QuarantineStatus"/>
		</Columns>
		<Row>
			<LotID>RM0002017</LotID>
			<MaterialName>Base</MaterialName>
			<Location>Raw Materials</Location>
			<QueuedQty>10000.00</QueuedQty>
			<StartedQty>0.00</StartedQty>
			<HoldStatus>RELEASED       </HoldStatus>
			<QuarantineStatus>ACTIVE         </QuarantineStatus>
		</Row>
		<Row>
			<LotID>RM0002018</LotID>
			<MaterialName>Base</MaterialName>
			<Location>Raw Materials</Location>
			<QueuedQty>10000.00</QueuedQty>
			<StartedQty>0.00</StartedQty>
			<HoldStatus>RELEASED       </HoldStatus>
			<QuarantineStatus>ACTIVE         </QuarantineStatus>
		</Row>
	</Rowset>
</Rowsets>

In this case, ColType evaluates properly:

<xsl:variable name="ColType"><xsl:value-of
select="/Rowsets/Rowset[1]/Columns/Column[@Name='QueuedQty']/@SQLDataType"/>
</xsl:variable>

In this case, it does not:

<xsl:variable name="ColToMatch">'QueuedQty'</xsl:variable>
<xsl:variable name="ColType"><xsl:value-of
select="/Rowsets/Rowset[1]/Columns/Column[@Name=$ColToMatch]/@SQLDataType"/>
</xsl:variable>

Regards,

Rick Bullotta
Lighthammer

-----Original Message-----
From: Rick Bullotta [mailto:rick.bullotta@lighthammer.com]
Sent: Tuesday, October 02, 2001 1:48 PM
To: xalan-dev@xml.apache.org
Subject: Xalan 2.2 D11 - Change in xalan:evaluate - Bug?


Xalan 2.2 D11 does not seem to (reliably) recognize variable references in
an expression passed to xalan:evaluate.  Has there been a significant change
in this extension function that we should be aware of?

- Rick