• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xml and xsl with jaxp-plz help

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
<b>"javax.xml.transform.TransformerConfigurationException:
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.
VERY URGENT
thanks in advance
sunil.s

// 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();
try
{
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.

//ERROR IS THROWN AT THIS LINE-----1
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) {
e.printStackTrace();
out.println("Error: " + e);
out.close();
}
}
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
Bill
 
sunilkumar ssuparasmul
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic