JSP / XSL

Discussions

XML & Web services: JSP / XSL

  1. JSP / XSL (2 messages)

    I have done this in client side. Can anyone help
    me to do the same in server side? So that it will be
    browser independent? Iam using Tomcat .



    // Load XML
    var xml = new ActiveXObject("Microsoft.XMLDOM")
    xml.async = false
    xml.load("FirstXml.xml")

    // Load the XSL
    var xsl = new ActiveXObject("Microsoft.XMLDOM")
    xsl.async = false
    xsl.load("Xsl_Navigator.xsl")

    // Transform
    document.write(xml.transformNode(xsl))

    Threaded Messages (2)

  2. JSP / XSL[ Go to top ]

    <%@ page contentType="text/xml" import="javax.xml.transform.*, javax.xml.transform.stream.*" %> <%
    /**
     * I am using xalanj1compat.jar, xalan.jar and xerces.jar
     * from jakarta.apache.com
     * to make it work I had to remove jaxp.jar from
     * the classpath of the web container
     **/
    String xmlFilename = "FirstXml.xml";
    String xslFilename = "Xsl_Navigator.xsl";


    String xslFile = "file:///"+getServletConfig().getServletContext().getRealPath("/"+xslFilename);
    String xmlFile = "file:///"+getServletConfig().getServletContext().getRealPath("/"+xmlFilename);

    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
    transformer.transform(new StreamSource(xmlFile), new StreamResult(out));
    %>
  3. JSP / XSL[ Go to top ]

    how could i transform a xml string (i want to generate a xml string from a database and then transform it using xsl). i know how to transform a file (something like the example you just gave us). But is it possible with a plain text string too?