• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

xml and xsl with jaxp-plz help

Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai all,
i am using jaxp to apply an xsl to an xml and generate HTML output via servlet .But it says
Namespace not supported by SAXParser "</b>
for u r reference i am sending the source code
The excep[tion occurs at 1. i tried using String argument to pass insted of InputStream at line 2 but still it throws the same error . PLease help.
thanks in advance

// Need Servlet classes
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.xml.transform.*;
import javax.xml.transform.sax.*;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.Source;
// Needed java classes
import java.io.*;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import java.util.Properties;
// Needed SAX classes
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.Parser;
import java.net.*;
import javax.xml.parsers.ParserConfigurationException;
* A simple example to convert XML tp HTML
* through XSL.
* @author <a href="mailto:sunilgct@yahoo.com">Sunil kumar</a>
* @version="1.0"
public class Examples_jaxp extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws javax.servlet.ServletException, java.io.IOException{
// Open a URL to hostname on portNumber, and get file
PrintWriter out = res.getWriter();
StringWriter ol_CharWriter = new StringWriter();
URL xmlURL = new URL("http", "localhost",8100,"/JSPFILES/xml/sort1.xml");
InputStream in = xmlURL.openStream();

//LINE 2
URL xmlURL1 = new URL("http", "localhost",8100,"/JSPFILES/xsl/sort1.xsl");
InputStream in1 = xmlURL1.openStream();
System.out.println("INside Example Simple");
// Create a transform factory instance.
TransformerFactory tfactory = TransformerFactory.newInstance();
System.out.println("creating transfromer");
// Create a transformer for the stylesheet.

Templates stylesheet1 = tfactory.newTemplates(new StreamSource(in1));
Transformer transformer= stylesheet1.newTransformer();
// Transform the source XML to System.out.
transformer.transform(new StreamSource(in),
new StreamResult(new File("foo1.out")));
catch (Exception e) {
out.println("Error: " + e);
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like you have an older version of the jaxp parser toolkit. Have you checked java.sun.com for the newest, which is supposed to fully support namespaces?
sunilkumar ssuparasmul
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YES i have downloadeed the latest version from sun that is jaxp1.1 which is availablesince march 1st week
please help
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!