OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exception when using Xalan in Servlet to produce an html-response:org.w3c.dom.Node: method getLocalName()Ljava/lang/String; not found



Hi
I use newest xalan and jaxp-version and tried to transform xml to html in a servlet.
 
This exception occured:
java.lang.NoSuchMethodError: org.w3c.dom.Node: method getLocalName()Ljava/lang/String; not found
        at org.apache.xalan.templates.TemplateList.getHead(TemplateList.java:471)
        at org.apache.xalan.templates.TemplateList.getTemplate(TemplateList.java, Compiled Code)
        at org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java, Compiled Code)
        at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:193)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java, Compiled Code)
        at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2097)
        at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2029)
        at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java, Compiled Code)
        at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
        at java.lang.Thread.run(Thread.java:479)
 
 
That's the code:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 
    PrintWriter out = new PrintWriter (response.getOutputStream());
    // The servlet returns HTML.
    response.setContentType("text/html");
    out.write("props " + System.getProperties());
    try
    { 
      TransformerFactory tFactory = org.apache.xalan.processor.TransformerFactoryImpl.newInstance();
      // Get the XML input document and the stylesheet.
      Source xmlSource = new StreamSource(new URL("file:c:/foo.xml").openStream());
      Source xslSource = new StreamSource(new URL("file:c:/foo.xsl").openStream());
      // Generate the transformer.
      Transformer transformer = tFactory.newTransformer(xslSource);
      // Perform the transformation, sending the output to the response.
      transformer.transform(xmlSource, new StreamResult(out));
    }
    catch (Exception e)
    {
      out.write(e.getMessage());
      e.printStackTrace(out);   
    }
    out.close();
  }
 
As I have problems in using xerces instead of xalan, I tried to refer to the implementation classes directly.
foo.xml and foo.xsl are examples of the xalan-distribution and they do exist in this directory.
 
I use Tomcat 3.2.1 and Apache.
Any ideas what might have gone wrong??
 
That's the minimalistic exapmle, think that must be O.K:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="doc">
<result>Das Ergebnis</result>
    <out><xsl:value-of select="."/></out>
  </xsl:template>
</xsl:stylesheet>
 
Thanks for your help!
Inga