You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Marcos Aurélio Alves <aa...@w3vd.com.br> on 2001/02/13 16:06:24 UTC

Xalan on a servlet

Hi,

	I've got Xerces 3.1.1, Xalan-J 2.0, JDK1.3, Apache 3.1.12-25 and Jakarta
Tomcat 3.2.1-1 installed on my machine (RedHat 7.0).

	When I run something simple like this:

--------------------
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import java.io.*;

import javax.xml.transform.*;
import javax.xml.transform.stream.*;

public class transform
{
	public static void main(String[] args)
  {
		try
		{
			String outputType = "html";
			TransformerFactory tfactory = TransformerFactory.newInstance();

			Transformer transformer = tfactory.newTransformer(new
StreamSource(args[1]));

			transformer.setOutputProperty(OutputKeys.METHOD, outputType);

			transformer.transform(new StreamSource(args[0]), new
StreamResult(System.out));
		}
		catch (Exception e)
		{
			e.printStackTrace(System.out);
		}
  }
}
--------------------

	I've got no problem at all. It applies the .xsl doc to the .xml doc I
specified and outputs the result. But when i try to do the same thing from a
servlet...

---------------------
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

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

import java.io.*;

public class transform extends HttpServlet
{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
	{
		ServletContext servletContext = getServletContext();
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();

		try
		{
			String outputType = "html";
			TransformerFactory tfactory = TransformerFactory.newInstance();

			Transformer transformer = tfactory.newTransformer(new
StreamSource(servletContext.getRealPath("/xsl/foo.xsl")));

			transformer.setOutputProperty(OutputKeys.METHOD, outputType);

			transformer.transform(new
StreamSource(servletContext.getRealPath("/xml/foo.xml")), new
StreamResult((Writer) out));
		}
		catch (Exception e)
		{
			e.printStackTrace(out);
		}
	}
}
----------------

	I always get this error message:
javax.xml.transform.TransformerConfigurationException: Namespace not
supported by SAXParser

	Important: I'm using the same .xml and .xsl files in both programs...

	Does anyone know where I did wrong or where I can get more information on
this problem?


	Thanks...



Marcos Aurélio Alves
--------------------


RES: Xalan on a servlet

Posted by Marcos Aurélio Alves <aa...@w3vd.com.br>.
Hi François,

	It works!!!


	Thank you very much...


Marcos Aurélio Alves




-----Mensagem original-----
De: François Gauvin [mailto:fgauvin@wantedtech.com]
Enviada em: terça-feira, 13 de fevereiro de 2001 12:35
Para: xalan-dev@xml.apache.org
Assunto: RE: Xalan on a servlet


Hi,

You have to delete jasper.jar and jaxp.jar on the lib directory of your web
server.
Those files are in conflict with the parser in xalan.

François Gauvin
francois.gauvin@wantedtech.com
Wanted Technologies
HTML/JSP programmer


RE: Xalan on a servlet

Posted by François Gauvin <fg...@wantedtech.com>.
Hi,

You have to delete jasper.jar and jaxp.jar on the lib directory of your web
server.
Those files are in conflict with the parser in xalan.

François Gauvin
francois.gauvin@wantedtech.com
Wanted Technologies
HTML/JSP programmer

-----Original Message-----
From: Marcos Aurélio Alves [mailto:aamarcos@w3vd.com.br]
Sent: Tuesday, February 13, 2001 10:06 AM
To: xalan-dev@xml.apache.org
Subject: Xalan on a servlet

Hi,

        I've got Xerces 3.1.1, Xalan-J 2.0, JDK1.3, Apache 3.1.12-25 and
Jakarta
Tomcat 3.2.1-1 installed on my machine (RedHat 7.0).

        When I run something simple like this:

--------------------
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import java.io.*;

import javax.xml.transform.*;
import javax.xml.transform.stream.*;

public class transform
{
        public static void main(String[] args)
  {
                try
                {
                        String outputType = "html";
                        TransformerFactory tfactory =
TransformerFactory.newInstance();

                        Transformer transformer =
tfactory.newTransformer(new
StreamSource(args[1]));

                        transformer.setOutputProperty(OutputKeys.METHOD,
outputType);

                        transformer.transform(new StreamSource(args[0]), new
StreamResult(System.out));
                }
                catch (Exception e)
                {
                        e.printStackTrace(System.out);
                }
  }
}
--------------------

        I've got no problem at all. It applies the .xsl doc to the .xml doc
I
specified and outputs the result. But when i try to do the same thing from a
servlet...

---------------------
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

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

import java.io.*;

public class transform extends HttpServlet
{
        public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws IOException, ServletException
        {
                ServletContext servletContext = getServletContext();
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();

                try
                {
                        String outputType = "html";
                        TransformerFactory tfactory =
TransformerFactory.newInstance();

                        Transformer transformer =
tfactory.newTransformer(new
StreamSource(servletContext.getRealPath("/xsl/foo.xsl")));

                        transformer.setOutputProperty(OutputKeys.METHOD,
outputType);

                        transformer.transform(new
StreamSource(servletContext.getRealPath("/xml/foo.xml")), new
StreamResult((Writer) out));
                }
                catch (Exception e)
                {
                        e.printStackTrace(out);
                }
        }
}
----------------

        I always get this error message:
javax.xml.transform.TransformerConfigurationException: Namespace not
supported by SAXParser

        Important: I'm using the same .xml and .xsl files in both
programs...

        Does anyone know where I did wrong or where I can get more
information on
this problem?


        Thanks...



Marcos Aurélio Alves
--------------------