Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAXP Processing Instruction Problem

Status
Not open for further replies.

ChrisMcD

Programmer
Nov 8, 2001
5
GB
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());
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top