This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Java code example of transforming via SAX with JAXP 1.1?


This may be what you need...

Go to your WebSpere Test Environment Control Center and check that the Xalan
code is checked off in the "Select projects to include" window.  Then for
kicks, enter the exact path to the unzipped xalan directory to the "extra
class path" box just below.

Also, I found that I had to add the following lines to your main method to
pick up the correct properties...

	java.util.Properties p = System.getProperties();
	p.put(
		"javax.xml.parsers.SAXParserFactory",
		"org.apache.xerces.jaxp.SAXParserFactoryImpl");
	p.put(
		"javax.xml.parsers.DocumentBuilderFactory",
		"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
	p.put(
		"javax.xml.transform.TransformerFactory",
		"org.apache.xalan.processor.TransformerFactoryImpl");

This may be wrong for you impl so please don't skewer me. :~)


-->  -----Original Message-----
-->  From: KUMAR NINGASHETTY [mailto:kningashetty@deltafunding.com]
-->  Sent: Wednesday, June 19, 2002 1:51 PM
-->  To: xsl-list@lists.mulberrytech.com
-->  Subject: Re: [xsl] Java code example of transforming via 
-->  SAX with JAXP
-->  1.1?
-->  
-->  
-->  
-->  Hello James or Akila ...
-->        I am using almost similar Servlet code for Server 
-->  Side Transformation ...and when i run the Servlet using 
-->  browser i get this following 
-->        runtime Exception ... This is under Websphere Studio 
-->  4 env . Is it something to do with using latest xalan and 
-->  xerces version which i 
-->       already tried ...
-->       I am assuming this something to do with xalan and 
-->  xerces versioning prblem and hence i am posting here 
-->  ...Any pointers appreciated ..
-->  
-->  
-->  
-->  java.lang.NoClassDefFoundError: javax/xml/transform/FactoryFinder 
-->       at 
-->  javax.xml.transform.TransformerFactory.newInstance(Transfor
-->  merFactory.java:139) 
-->       at 
-->  com.proj1.servlets.Proj1Controller.doGet(Proj1Controller.java:68) 
-->       at 
-->  javax.servlet.http.HttpServlet.service(HttpServlet.java:740) 
-->       at 
-->  javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 
-->       at 
-->  com.ibm.servlet.engine.webapp.StrictServletInstance.doServi
-->  ce(ServletManager.java:827) 
-->       at 
-->  com.ibm.servlet.engine.webapp.StrictLifecycleServlet._servi
-->  ce(StrictLifecycleServlet.java:167) 
-->       at 
-->  com.ibm.servlet.engine.webapp.IdleServletState.service(Stri
-->  ctLifecycleServlet.java:297) 
-->       at 
-->  com.ibm.servlet.engine.webapp.StrictLifecycleServlet.servic
-->  e(StrictLifecycleServlet.java:110) 
-->       at 
-->  com.ibm.servlet.engine.webapp.ServletInstance.service(Servl
-->  etManager.java:472) 
-->       at 
-->  com.ibm.servlet.engine.webapp.ValidServletReferenceState.di
-->  spatch(ServletManager.java:1012) 
-->       at 
-->  com.ibm.servlet.engine.webapp.ServletInstanceReference.disp
-->  atch(ServletManager.java:913) 
-->       at 
-->  com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handl
-->  eWebAppDispatch(WebAppRequestDispatcher.java:523) 
-->       at 
-->  com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispa
-->  tch(WebAppRequestDispatcher.java:282) 
-->       at 
-->  com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forwa
-->  rd(WebAppRequestDispatcher.java:112) 
-->       at 
-->  com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppIn
-->  voker.java:91) 
-->       at 
-->  com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHo
-->  ok(WebAppInvoker.java:184) 
-->       at 
-->  com.ibm.servlet.engine.invocation.CachedInvocation.handleIn
-->  vocation(CachedInvocation.java:67) 
-->       at 
-->  com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatch
-->  ByURI(ServletRequestProcessor.java:122) 
-->       at 
-->  com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.se
-->  rvice(OSEListener.java:315) 
-->       at 
-->  com.ibm.servlet.engine.http11.HttpConnection.handleRequest(
-->  HttpConnection.java:60) 
-->       at 
-->  com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpCon
-->  nection.java:323) 
-->       at 
-->  com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252) 
-->       at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122) 
-->       
-->  
-->  Thanks in Advance 
-->  - kumar
-->  
-->  
-->  
-->  >>> james.fuller@o-idev.com 06/19/02 02:41PM >>>
-->  many apologies,
-->  
-->  omit the
-->  
-->  PrintErrorListener factoryerror = new PrintErrorListener();
-->  
-->  line, which is a common bit of code which assists in 
-->  handling error stuff
-->  
-->  ----- Original Message -----
-->  From: "James Fuller" <james.fuller@o-idev.com>
-->  To: <xsl-list@lists.mulberrytech.com>
-->  Sent: Wednesday, June 19, 2002 7:14 PM
-->  Subject: Re: [xsl] Java code example of transforming via 
-->  SAX with JAXP 1.1?
-->  
-->  
-->  > import javax.xml.transform.*;
-->  > import javax.xml.transform.sax.*;
-->  > import javax.xml.transform.dom.*;
-->  > import javax.xml.transform.stream.*;
-->  > import javax.xml.parsers.*;
-->  >
-->  > public static void transform2result(String strXML, 
-->  String strXSL, Response
-->  > response)
-->  >             throws TransformerException, 
-->  TransformerConfigurationException
-->  >                      {
-->  >            try{
-->  >             File source = new File(strXML);
-->  >             File style = new File(strXSL);
-->  >
-->  >             TransformerFactory factory = 
-->  TransformerFactory.newInstance();
-->  >             // Set the error listener of the factory
-->  >             PrintErrorListener factoryerror = new 
-->  PrintErrorListener();
-->  >
-->  >             factoryerror.response = response;
-->  >             Transformer t = factory.newTransformer(new
-->  StreamSource(style));
-->  >             transformerror.response = response;
-->  >             t.setErrorListener(transformerror);
-->  >             t.transform(new StreamSource(source),new
-->  > StreamResult(System.out));
-->  >
-->  >
-->  >            }catch(Exception e){
-->  >            }
-->  >
-->  >     }
-->  >
-->  > a bit OT this,
-->  >
-->  > something like this will do, notice I am piping the 
-->  output to System.out u
-->  > can write to a file
-->  >
-->  > also u may need to setup ErrorListeners to handle error 
-->  processing.
-->  >
-->  > cheers, jim fuller
-->  >
-->  > ----- Original Message -----
-->  > From: "Richard Bondi" <rbondi@ergito.com>
-->  > To: <XSL-List@lists.mulberrytech.com>
-->  > Sent: Wednesday, June 19, 2002 6:50 PM
-->  > Subject: [xsl] Java code example of transforming via SAX 
-->  with JAXP 1.1?
-->  >
-->  >
-->  > > Could someone please send me a java example of how to 
-->  transform some xml
-->  > > that is being parsed via a JAXP 1.1. SAXParser? Just 
-->  something simple
-->  that
-->  > > parses test.xml, transforms it with test.xsl, and outputs it to
-->  System.out
-->  > > or to a Result object.
-->  > >
-->  > >
-->  > > FYI: I've tried to figure this out from two O'Reilly 
-->  Books, "Java &
-->  XSLT"
-->  > > and "Java & XML". The latter doesn't cover it, and the 
-->  former only
-->  covers
-->  > > how to transform by leaving JAXP, i.e. by getting an 
-->  XMLReader (not to
-->  > > mention an inexplicable 7 page digression on how to parse
-->  comma-separated
-->  > > files that frustratingly occurs in the middle of this).
-->  > >
-->  > > Please email directly to me as well as to the list.
-->  > >
-->  > > Many thanks,
-->  > > Richard Bondi
-->  > >
-->  > >
-->  > >  XSL-List info and archive:  
-->  http://www.mulberrytech.com/xsl/xsl-list 
-->  >
-->  >
-->  >  XSL-List info and archive:  
-->  http://www.mulberrytech.com/xsl/xsl-list 
-->  
-->  
-->   XSL-List info and archive:  
-->  http://www.mulberrytech.com/xsl/xsl-list 
-->  
-->  
-->   XSL-List info and archive:  
-->  http://www.mulberrytech.com/xsl/xsl-list
-->  

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]