Tamino and Xalan

I want to transform TaminoResult using XSL into HTML.
My code look like the following (it is a jsp running on Tomcat):

TransformerFactory tfactory = TransformerFactory.newInstance();
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);

DocumentBuilder docBuilder = dfactory.newDocumentBuilder();

File xslFile = new File(getServletContext().getRealPath(“/”) + “test.xsl”);
Document xslDoc = docBuilder.parse(xslFile);
DOMSource xslSource = new DOMSource(xslDoc);
xslSource.setSystemId(xslFile.toString());

Templates templates = tfactory.newTemplates(xslSource);
Transformer transformer = templates.newTransformer();

// Get xml from tamino
TaminoClient tamino = new TaminoClient(taminourl);
tamino.setPageSize(0);
tamino.startSession();
TaminoResult tr = tamino.query(“Project”);

if (tr != null){
if (tr.hasMoreElements()) {
Document result = tr.getDocument();
DOMSource xmlSource = new DOMSource(result);
transformer.transform(xmlSource, new StreamResult(out));
} else {
out.println(“No Project Available”);
}

tamino.endSession();


The code above give me the following error when the page is called:

Error: 500
Location: /gwms/ProcessReport.jsp
Internal Servlet Error:

javax.servlet.ServletException
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:508)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)

Root cause:
java.lang.AbstractMethodError
at org.apache.xml.dtm.ref.dom2dtm.DOM2DTM.addNode(DOM2DTM.java:231)
at org.apache.xml.dtm.ref.dom2dtm.DOM2DTM.(DOM2DTM.java:150)
at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:185)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:585)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1037)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1015)
at _0002fProcessReport_0002ejspProcessReport_jsp_56._jspService(_0002fProcessReport_0002ejspProcessReport_jsp_56.java:194)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)


Can anybody help?

Thank you,

Antony

[This message was edited by Antony on 16 Aug 2001 at 06:54.]

Hi Antony,

I have had the same AbstractMethodError and I think it is caused by Tamino returning a DOM1 Document but xalan expecting a DOM2 Document.

There is at least one other way to do this (I don’t know if this will help in your case).

If you install the Jakarta Taglib for XSL into Tomcat, you can process a Tamino response with the jsp code below.

HTH
Bill

code:
  
<%@ page language=“java” contentType=“text/html” %>
<%@taglib uri=“http://jakarta.apache.org/taglibs/xsl-1.0” prefix=“xsl” %>

<jsp:useBean id=“xml_in” class=“org.apache.xalan.xslt.XSLTInputSource”/>
<jsp:useBean id=“xsl_in” class=“org.apache.xalan.xslt.XSLTInputSource”/>

<%
xml_in.setSystemId(“http://natserv2/tamino/RealEstate/Property/Property?_XQL=Property[@PropertyType=‘House’]");<BR>xsl_in.setSystemId("http://localhost:8080/xsl-examples/kitdemoHTML.xsl”);
%>

<xsl:apply nameXml=“xml_in” nameXsl=“xsl_in” />


Hi

I’ve tested a similar example which generates servlet from XSL transformation. Under Tomcat (in JBuilder 4.0 environment) this example didn’t work. Under Apache JServ it works correctly.

Best regards

Leszek

This might sound crazy but when you are getting a DOM from the Tamino API and when you want to process it using Xalan java 1, …I experienced that the fastest way to do it is to go back to a XML serialization in a buffer first!

Indeed, DOM resulting from Tamino API is not optimized for Xalan(-1) and it is a lot more efficient to let Xalan re-build himself a Xalan-optimized DOM (in which I believe integer hash-codes are used a lot).

I believe Xalan 2 should be able to work correctely on any DOM but going through a buffer is worth a try.

Anyway, the best solution would be to have a Tamino API that accepts customization of DOM parser implementation.


Software AG Belgium, Professional Services Division

Anyway, the best solution would be to have a Tamino API that accepts customization of DOM parser implementation.

If you need a version of the Java DOM API with switchable SAX1/DOM1 SAX2/DOM2 I can post one .
It should appear in the downlaod section some time.
But the cuurent plan is not to maintain this

Or you must use the new API which as far as I can see doesn’t have a SAX1/DOM1 accessor yet

Hi,

How about the usage of XT.jar provided by Tamino 2.3.1.4 Is there any example whereby we can use the XT from Jclark to do the transformation?

example a DOM to HTML with an XSL.

regards

cheers !