Having a problem calling an xsl from this servlet.... any ideas folks,
********************************
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.sun.xml.tree.*;
public class PersonServlet extends HttpServlet {
public static XmlDocument document;
// public static Element Elem;
public static void BuildUi() {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
document = new XmlDocument();
//****** Root
// Node header = document.createProcessingInstruction("xml", "version='1.0'"
// document.appendChild(header);
ProcessingInstruction headerStyle = document.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"UIConfigStyle.xsl\""
document.appendChild(headerStyle);
Element data = (Element) document.createElement("data"
document.appendChild(data);
Element person = document.createElement("person"
data.appendChild( person );
Element Name = document.createElement("Name"
person.appendChild( Name );
Name.appendChild( document.createTextNode("Chris McDermott" );
Element Job = document.createElement("Job"
person.appendChild( Job );
Job.appendChild( document.createTextNode("Full Time Dreamer" );
Element Details = document.createElement("Details"
person.appendChild( Details );
Details.appendChild( document.createTextNode("This data has been transformed into HTML through xsl and formatted through JavaScript and xml ...blah blah blah" );
}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
//set content type
res.setContentType("text/xml"
PrintWriter out = res.getWriter();
BuildUi();
out.println(((ElementNode)document.getDocumentElement()).toString());
}
}
********************************
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.sun.xml.tree.*;
public class PersonServlet extends HttpServlet {
public static XmlDocument document;
// public static Element Elem;
public static void BuildUi() {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
document = new XmlDocument();
//****** Root
// Node header = document.createProcessingInstruction("xml", "version='1.0'"
// document.appendChild(header);
ProcessingInstruction headerStyle = document.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"UIConfigStyle.xsl\""
document.appendChild(headerStyle);
Element data = (Element) document.createElement("data"
document.appendChild(data);
Element person = document.createElement("person"
data.appendChild( person );
Element Name = document.createElement("Name"
person.appendChild( Name );
Name.appendChild( document.createTextNode("Chris McDermott" );
Element Job = document.createElement("Job"
person.appendChild( Job );
Job.appendChild( document.createTextNode("Full Time Dreamer" );
Element Details = document.createElement("Details"
person.appendChild( Details );
Details.appendChild( document.createTextNode("This data has been transformed into HTML through xsl and formatted through JavaScript and xml ...blah blah blah" );
}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
//set content type
res.setContentType("text/xml"
PrintWriter out = res.getWriter();
BuildUi();
out.println(((ElementNode)document.getDocumentElement()).toString());
}
}