JEditorPane xml/xsl to html

I have build a little and simple xml/xsl parser that recive the xml file and the xsl file and return me a String that rapresent an html document respecting the input files.
Now, i try to put this string ina JEditpr Pane but if i set as ContentType text/html i just see a white background and if I set, again, as contentType text/plain I can read the html code that i need.
Sorry if this could be a stupid question, I'm a newbie in Swing.
thx to all
0m4r
here is a little example of what I do
JEditorPane jep = new JEditorPane();
jep.setContentType("text/html");
jep.setText(returnStringFromXMLParser);

this could be the problem
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">i try to not use this line of code and it works fine...ut the promlem is that this line is added ny the XMLParser...what can I do?
the Transformer I use:
public static String toHTML(Document doc, String xslSource){
        ByteArrayOutputStream testo = new ByteArrayOutputStream();
        try{
            DOMSource source = new DOMSource(doc);
            TransformerFactory tFactory = TransformerFactory.newInstance();
            System.out.println("----> " + xslSource);
            Transformer transformer = tFactory.newTransformer(new StreamSource(xslSource));
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
            transformer.setOutputProperty("encoding","iso-8859-1");   
            transformer.transform(source, new StreamResult(testo));
        }catch(Exception ioe){
            System.out.println("2 XMLTool.toHTML " + new java.util.Date());
            System.out.println(ioe);        
        return testo.toString();
    }

Similar Messages

  • XML, XSL - HTML(JSP), bad UTF-8 encoding on Tomcat

    I use simple transformation to create HTML (JSP) page from XML, XSL (both are encoded in UTF-8}. When doing this in embedded web server in JD9i developer, the result is fine. But when run at Tomcat 4.0.3, UTF-8 chars are displayed as 2 characters. It's interesting that the transformation gives different results:
    - in JD9i the UTF-8 chars are left unchanged and shown good in IE browser
    - in Tomcat the chars with acute (/) are transformed into "&iacute;" , "&aacute;" and so on and shown properly, whereas chars with caron (V) are encoded and shown badly.
    Does somebody know solution to this ? Thanks.

    Doing some more experiments reveals a subtle difference between GET and POST with Tomcat - it may apply to other application servers, but I have only tested with Tomcat 5 and Tomcat 6, so I can't say.
    The following is essentially what most people have indicated you need to do to have your JSP handle UTF-8:
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>My Title</title>
    </head>
    <body>
    </body>
    </html>This is what I couldn't get working with my GET (the default for forms) and ended up working when I specified the URIEncoding for the connector in the server.xml file.
    It turns out that the above will work with no modifications to the server.xml file if the form method is POST. If you need to be able use GETs then you will need to modify the connector, otherwise it would seem nothing you do at the JSP or servlet level will make a difference, unless you want to convert each parameter manually:
      String parameter = new String( request.getParameter("myParam").getBytes("ISO-8859-1"), "UTF-8" );Edited by: ajmasx on Sep 27, 2007 10:20 AM

  • Converting XML document to HTMl using xsl

    Hi,
    I'm trying to convert an xml document into html page using xsl. But when I try to open the page in the browser nothing comes up.
    I'm not sure if I am using the PrintWriter correctly.
    StreamResult result = new StreamResult(new PrintWriter(new (File"text.html")));
    Please help.

    Oops! I wrote the parenthesis wrong in the previous mail
    This is the correct one I use in my program.
    StreamResult result = new StreamResult(new PrintWriter(new File("text.html")));
    Please help. Its urgent

  • JSP(XML+XSL)=HTML : error: sealing violation

    Hi,
    I have this jsp which will transform an xml file to html using xsl file... but its giving me a sealing violation. i tried the same code in a java application and its working...
    The error thrown is this:
    Internal Servlet Error:
    javax.servlet.ServletException: sealing violation
    Root cause:
    java.lang.SecurityException: sealing violation
    <%@ page language="java" session="true" import="java.io.*,javax.xml.parsers.*,org.w3c.dom.*,javax.xml.transform.*,javax.xml.transform.stream.*" %>
    <%
    StreamSource xml = new StreamSource( new File( "C:\\Tomcat\\webapps\\pc\\logs\\TransactionLog.xml" ) );
    StreamSource xsl = new StreamSource( new File( "C:\\Tomcat\\webapps\\pc\\logs\\TransactionLog.xsl" ) );
    StreamResult result = new StreamResult( out );
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer( xsl );
    transformer.setParameter( "recordsPerPage", "10" );
    transformer.setParameter( "pageNumber", request.getParameter( "pageNumber" ) );
    transformer.transform( xml, result ); // this is where the error is thrown...
    %>
    i hope somebody can help me with this...
    thanks,
    mitch

    Hi
    I think that It's because of some confilict between packages, try to set more priority for your jar files in tomcat.bat file as below :
    set cp=%CLASSPATH%
    set CLASSPATH=.
    set CLASSPATH=%TOMCAT_HOME%\classes
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\webserver.jar
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\jasper.jar
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\xml.jar
    set CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\servlet.jar
    set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar
    if "%cp%" == "" goto next
    set CLASSPATH=%cp%;%CLASSPATH%
    ALI

  • Converting XML and XSL into HTML

    Hello!
    I'm designing a servlet class that merges an xml file and xsl file into html that will be sent to the client. But I don't understand how the (sparsely documented) javax.xml.transform.dom package works. An exception is generated for a missing "version" tag, when I've included one that has worked on client-side xml/xsl pages before. If it matters, I'm using Apache Tomcat/JDK 1.4.
    Here's the code:package mypackage.servlet.xml;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    public class XML2HTMLServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
              response.setContentType("text/html");
              PrintWriter writer = response.getWriter();
              try {
                   openFile("D:/Webdev/xml2html/data.xml", "D:/Webdev/xml2html/style.xsl", writer);
              } catch (Exception e) {
                   e.printStackTrace(writer);
         private void openFile(String xmlPath, String xslPath, PrintWriter writer)
          throws IOException, ParserConfigurationException, SAXException,
          TransformerConfigurationException, TransformerException {
              File xmlFile = new File(xmlPath);
              File xslFile = new File(xslPath);
              TransformerFactory tFact = TransformerFactory.newInstance();
              DocumentBuilderFactory dbFact = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = dbFact.newDocumentBuilder();
              Document xmlDoc = builder.parse(xmlFile);
              Document xslDoc = builder.parse(xslFile);
              Node xmlDocNode = (Node)xmlDoc;
              Node xslDocNode = (Node)xslDoc;
              DOMSource xmlSrc = new DOMSource(xmlDocNode);
              DOMSource xslSrc = new DOMSource(xslDocNode);
              DOMResult htmlResult = new DOMResult();
              Transformer transformer = tFact.newTransformer(xslSrc);  // the exception occurs here!
    When it runs, it complains:
    javax.xml.transform.TransformerConfigurationException:
    javax.xml.transform.TransformerConfigurationException:
    javax.xml.transform.TransformerException:
    javax.xml.transform.TransformerException: stylesheet requires attribute: version at
    org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:767) at
    mypackage.servlet.xml.XML2HTMLServlet.openFile(XML2HTMLServlet.java:49) at
    ...etc...etc...
    data.xml contains:
    <?xml version="1.0"?>
    <document type="lecture">
         <title>Test Data</title>
         <section>
              <name>A New Section</name>
         </section>
    </document>
    style.xsl contains:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
         <html>
              <head>
                   <title><xsl:value-of select="document/title"/></title>
              </head>
              <body>
                   <xsl:apply-templates select="document/section"/>
              </body>
         </html>
    </xsl:template>
    <xsl:template match="section">
         <div><i>Section</i><br/><xsl:value-of select="name"/></div>
    </xsl:template>
    </xsl:stylesheet>I'm not sure the method calls above are what I want, so here's the client-side equivalent in Internet Explorer 5.0:
    function createStyledXMLDocument(xmlUrl, xslUrl) {
         var xmlDocument = new ActiveXObject("Microsoft.XMLDOM");
         xmlDocument.load(xmlUrl);
         var xslDocument = new ActiveXObject("Microsoft.XMLDOM");
         xslDocument.load(xslUrl);
         return xmlDocument.transformNode(xslDocument);
    }Any help would be greatly appreciated.

    Hi!
    I found the immediate answer with
    dbFact.setNamespaceAware(true);As for parser, I'm just using the default JDK install. But I'd like to hear more on Xalan. Is it independent open source? How does Xalan compare to whatever is default in JDK?
    Thanks

  • Encoding of a XML +XSL - HTML tranformation

    Hello:
    I've run into a problem transforming a XML doc. containing results retrieved from a database and later passed from a EJB to a servlet. The thing is that the database contains data formatted with encoding="ISO-8859-1", the XML doc. I create based on this data is also formatted with this encoding and looks like this:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <?xml-stylesheet type="text/xsl" href="http://localhost:8080/liteClient/combos.xsl">
    <authors>
    <row>Staffan Truv�</row>
    <row>Christopher Ahlberg</row>
    </authors>
    You would ask how does the xsl file (combos.xsl) looks like, here it is:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
         <xsl:template match="/">
              <HTML>
              <HEAD>                    
                   <meta http-equiv="Content-Type" content="text/html; encoding=ISO-8859-1"/>
              <TITLE>Query options</TITLE>
              </HEAD>
    Nothing fancy as you can see, however, the HTML displayed shows strange characters, for instance, in the author Staffan Truv� (See XML document)the HTML displays: Staffan Truv&#9500;�.
    This is a problem for the name is embedded in a combo box (drop down list) to be used as a search parameter, obviously, as the string displayed is different the value sent when searching does not exist in the database and the result is null
    Do you know how to set the encoding in this special case, for reference, I depend on the XSLT processor from I. Explorer 6 given that the processing is done in the client side (The browser) due to a client requirement, that is a problem because I already found a way to set the output encoding but using xt by James Clark.
    I highly appreciate your help since this problem is the only thing that is delaying the project completion.
    Thanks a lot for taking the time to read this.
    Ugo Posada
    Zarpa Software

    If your are using the Transformer out of the javax.xml packages, you can specify this options with setOutputProperty() method too.
    Then it works if you have input boxes or a combo box. But I'd like to use text with special charakters in links. Now the transformer changes characters like the german "�" to "%C3%A4". But browsers cannot handle this and if someone follows the link, the Servlet doesn't read the argument in the right manner.
    Does anybody has a hint?
    Thanks in advance,
    Sebastian

  • Urgent! How to suppress indents in output from (XML , XSL) -- HTML

    I make transformation (XML , XSL) --> HTML using parser v2 of Oracle XDK for Java v 9.2.0.2.0
    I want to generate html in which several tags will follow one after another without new line, and indents.
    Like this
    <html>
    <body>
    <img src="1.jpg"/><img src="2.jpg"/>
    </body>
    </html>
    Only in this case images will be visualized in IE5 together without spaces.
    But xsl-processor is formatting output text: put each tag on new line and make indents for child tags.
    I tried to
    1) eliminate white spaces in xsl
    2) use <xsl:output indent="no"/>
    3) use <xsl:strip-space elements="*"/>
    4) use method setPreserveWhitespace(true/false) of XMLParser (oracle.xml.parser.v2.XMLParser)
    Xsl-processor continue to format output text.
    my xml
    <list>
    <element name="1.jpg" />
    <element name="2.jpg" />
    </list>
    my xsl
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="no"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="list">
    <html><body>
    <img src="{element[1]/@name}"/><img src="{element[2]/@name}"/>
    </body></html>
    </xsl:template>
    </xsl:stylesheet>
    html-output
    <html>
    <body>
    <img src="1.jpg"/>
    <img src="2.jpg"/>
    </body>
    </html>
    Please help me!

    html-output
    <html>
    <body>
    <img src="1.jpg"/>
    <img src="2.jpg"/>
    </body>
    </html>
    Please help me!

  • How do I generate HTML from XML & XSL using XSL Processor ?

    I want to generate a HTML from XML & XSL using XDK for C on
    linux-8i.
    I run the XSLSample well.
    But it only generate a XML from a XML & a XSL.
    Can any one give me some advise or sample code?

    Just use HTML tags instead of xml tags in your stylesheet, and
    you'll generate HTML instead.
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
          <body>
            <xsl:for-each select="ROWSET">
              <table border="1" cellspacing="0">
                <xsl:for-each select="ROW">
                  <tr>
                    <td><xsl:value-of select="EMPNO"/></td>
                    <td><xsl:value-of select="ENAME"/></td>
                  </tr>
                </xsl:for-each>
              </table>
            </xsl:for-each>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>

  • Code to translate xml data into html using jaxp ?

    Hi all !!
    Could you please send me code to translate xml data into html using jaxp
    i am sending my xml file and xsl file
    its urgent
    my xml file is :
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="scenario.xsl"?>
    <scenarioReport>
    <node name="node1">
    <netObjId>124 </netObjId>
    <result>undefined</result>
    <report>The cell is 124.</report>
    <action>qsdsqdqsd </action>
    </node>
    <node name="node 3">
    <netObjId>124 </netObjId>
    <result>undefined</result>
    <report>Result is unresolved because ...</report>
    <action>No action</action>
    </node>
    <node name="node 2">
    <netObjId>124 </netObjId>
    <result>undefined</result>
    <report>qsdqsdqs </report>
    <action>qsdsqd</action>
    </node>
    <node name="node 5">
    <netObjId>124 </netObjId>
    <result></result>
    <report> </report>
    <action> </action>
    </node>
    <node name="node 4">
    <netObjId>124 </netObjId>
    <result></result>
    <report> </report>
    <action></action>
    </node>
    </scenarioReport>
    my xsl file is::
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:template match="/">
    <html>
    <body>
    <h2> Scenario Report</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">Nodename</th>
    <th align="left">netObjId</th>
    <th align="left">Result</th>
    <th align="left">Report</th>
    <th align="left">Action</th>
    </tr>
    <xsl:for-each select="scenarioReport/node">
    <tr>
    <td><xsl:value-of select="@name"/></td>
    <td><xsl:value-of select="netObjId"/></td>
    <td bgcolor="#ffffff "><xsl:value-of select="result"/></td>
    <td><xsl:value-of select="report"/></td>
    <td><xsl:value-of select="action"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    Must be something wrong with your XSL.
    However apparently it was so urgent that you didn't have the time to look at what you posted. They just "fixed" the forum software and apparently it doesn't escape HTML that you type in any more. Or stuff that looks like HTML, either. So your post was unreadable.
    If your deadline hasn't passed, try reposting that code surrounded by [pre] and [/pre].

  • JAXP working with XML-XSL files - urgent help

    I have the code below to transform xml file into html file using xsl file:
    Transformer transformer = tFactory.newTransformer(new StreamSource("D:/Test/26120108026263560502.xsl"));
    transformer.transform(new StreamSource("D:/Test/26120108028469387014574415483532664948806162003.xml"), new StreamResult(new FileOutputStream("D:/Test/Test.html")));
    The code works fine with simple xml, xsl files, but it shows strange error messages when transforming more complex xsl file, please look at the errors below:
    [Error] 26120108026263560502.xsl:3:80: Element type "xsl:stylesheet" must be declared.
    [Error] 26120108026263560502.xsl:4:58: Element type "xsl:output" must be declared.
    [Error] 26120108026263560502.xsl:6:75: Element type "xsl:include" must be declared.
    [Error] 26120108026263560502.xsl:12:25: Element type "xsl:template" must be declared.
    [Error] 26120108026263560502.xsl:14:7: Element type "html" must be declared.
    [Error] 26120108026263560502.xsl:15:7: Element type "head" must be declared.
    [Error] 26120108026263560502.xsl:16:8: Element type "title" must be declared.
    [Error] 26120108026263560502.xsl:17:75: Element type "xsl:value-of" must be declared.
    [Error] 26120108026263560502.xsl:19:74: Element type "meta" must be declared.
    [Error] 26120108026263560502.xsl:20:8: Element type "style" must be declared.
    [Error] 26120108026263560502.xsl:38:25: Element type "body" must be declared.
    [Error] 26120108026263560502.xsl:39:48: Element type "xsl:call-template" must be declared.
    [Error] 26120108026263560502.xsl:40:55: Element type "xsl:call-template" must be declared.
    [Error] 26120108026263560502.xsl:41:49: Element type "xsl:call-template" must be declared.
    [Error] 26120108026263560502.xsl:43:67: Element type "table" must be declared.
    [Error] 26120108026263560502.xsl:44:7: Element type "tr" must be declared.
    [Error] 26120108026263560502.xsl:45:21: Element type "td" must be declared.
    [Error] 26120108026263560502.xsl:45:24: Element type "b" must be declared.
    [Error] 26120108026263560502.xsl:45:51: Element type "br" must be declared.
    [Error] 26120108026263560502.xsl:46:123: Element type "xsl:value-of" must be declared.
    It look to me that JAXP can't recognize the tags. Everyone's help is appreciated.
    Neil

    Here is the top part of it: ***********************
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="no" encoding="UTF-8" />
    <xsl:include href="http://connexion.vdr.com/ematrix/reports/xsllib.xsl" />
    <xsl:template match="/">
    <html>
    <head>
    <title>
    <xsl:value-of select="//businessObject[objectType='CRA']/objectName"/>
    </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <style>
    TABLE
    font-family: Arial Narrow, Tahoma, Verdana;
    border: #000000 solid;
    border-width: 2px 2px 0px;}
    TABLE.BOTTOM
    font-family: Arial Narrow, Tahoma, Verdana;
    border: #000000 solid;
    border-width: 2px 2px 2px;}
    TD.DATA, TH.DATA
    border: #cccccc solid;
    border-width: 0px 1px 1px 0px;}
    </style>
    </head>
    <body bgcolor="#FFFFFF">
    <xsl:call-template name="ECRHeaderTable" />
    <xsl:call-template name="ECRHeaderDetailsTable" />
    <xsl:call-template name="ECRDetailsTable" />
    Anh here is the top part of file xsllib.xsl in the xsl:include: ********
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!--*******************************************************************
    CalJulian - Calculate the Julian date for any date
    Inputs: Year - Year
    Month - Month
    Day - Day
    hour - hour (24 hour based, 0=midnight, 23=11pm)
    min - minute
    sec - second
    History:
    http://www.nr.com/julian.html
    *********************************************************************-->
    <xsl:template name="CalJulian">
    <xsl:param name="Year"/>
    <xsl:param name="Month" select="1"/>
    <xsl:param name="Day" select="1"/>
    <xsl:param name="Hour" select="0"/>
    <xsl:param name="Min" select="0"/>
    <xsl:param name="Sec" select="0"/>
    <xsl:variable name="jy">
    <xsl:choose>
    <xsl:when test="($Year < 0) and ($Month > 2)">
    <xsl:value-of select="$Year + 1"/>
    </xsl:when>
    <xsl:when test="($Year >= 0) and ($Month <= 2)">
    <xsl:value-of select="$Year - 1"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$Year"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    The files work fine when I use msxsl.exe without any errors. I forgot to mention that dispite all the errors, JAXP still creates the html file but seeing the errors is not a good thing.
    Neil

  • Large Pdf using XML XSL - Out of Memory Error

    Hi Friends.
    I am trying to generate a PDF from XML, XSL and FO in java. It works fine if the PDF to be generated is small.
    But if the PDF to be generated is big, then it throws "Out of Memory" error. Can some one please give me some pointers about the possible reasons for this errors. Thanks for your help.
    RM
    Code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.xml.sax.InputSource;
    import org.xml.sax.XMLReader;
    import org.apache.fop.apps.Driver;
    import org.apache.fop.apps.Version;
    import org.apache.fop.apps.XSLTInputHandler;
    import org.apache.fop.messaging.MessageHandler;
    import org.apache.avalon.framework.logger.ConsoleLogger;
    import org.apache.avalon.framework.logger.Logger;
    public class PdfServlet extends HttpServlet {
    public static final String FO_REQUEST_PARAM = "fo";
    public static final String XML_REQUEST_PARAM = "xml";
    public static final String XSL_REQUEST_PARAM = "xsl";
    Logger log = null;
         Com_BUtil myBu = new Com_BUtil();
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException {
    if(log == null) {
         log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
         MessageHandler.setScreenLogger(log);
    try {
    String foParam = request.getParameter(FO_REQUEST_PARAM);
    String xmlParam = myBu.getConfigVal("filePath") +"/"+request.getParameter(XML_REQUEST_PARAM);
    String xslParam = myBu.SERVERROOT + "/jsp/servlet/"+request.getParameter(XSL_REQUEST_PARAM)+".xsl";
         if((xmlParam != null) && (xslParam != null)) {
    XSLTInputHandler input = new XSLTInputHandler(new File(xmlParam), new File(xslParam));
    renderXML(input, response);
    } else {
    PrintWriter out = response.getWriter();
    out.println("<html><head><title>Error</title></head>\n"+
    "<body><h1>PdfServlet Error</h1><h3>No 'fo' "+
    "request param given.</body></html>");
    } catch (ServletException ex) {
    throw ex;
    catch (Exception ex) {
    throw new ServletException(ex);
    public void renderXML(XSLTInputHandler input,
    HttpServletResponse response) throws ServletException {
    try {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    response.setContentType("application/pdf");
    Driver driver = new Driver();
    driver.setLogger(log);
    driver.setRenderer(Driver.RENDER_PDF);
    driver.setOutputStream(out);
    driver.render(input.getParser(), input.getInputSource());
    byte[] content = out.toByteArray();
    response.setContentLength(content.length);
    response.getOutputStream().write(content);
    response.getOutputStream().flush();
    } catch (Exception ex) {
    throw new ServletException(ex);
    * creates a SAX parser, using the value of org.xml.sax.parser
    * defaulting to org.apache.xerces.parsers.SAXParser
    * @return the created SAX parser
    static XMLReader createParser() throws ServletException {
    String parserClassName = System.getProperty("org.xml.sax.parser");
    if (parserClassName == null) {
    parserClassName = "org.apache.xerces.parsers.SAXParser";
    try {
    return (XMLReader) Class.forName(
    parserClassName).newInstance();
    } catch (Exception e) {
    throw new ServletException(e);

    Hi,
    I did try that initially. After executing the command I get this message.
    C:\>java -Xms128M -Xmx256M
    Usage: java [-options] class [args...]
    (to execute a class)
    or java -jar [-options] jarfile [args...]
    (to execute a jar file)
    where options include:
    -cp -classpath <directories and zip/jar files separated by ;>
    set search path for application classes and resources
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -showversion print product version and continue
    -? -help print this help message
    -X print help on non-standard options
    Thanks for your help.
    RM

  • Issue with XML & XSL...

    Hi All,
    I am trying to display a saved XML file with a pre-defined
    XSL, which was provided to us by a third party vendor. The XML file
    is the same format the third party vendor expects it to be:
    This is the code I am using to display the XML file in HTML
    friendly way..
    <cffile action="read"
    file="#Request.ReportPath#/Report.xsl" variable="ReportXsl">
    <cfset xmldoc =
    XmlParse("E:\Inetpub\EMPProjDEV\Reports\Report_2003.xml")>
    <cfoutput>#XmlTransform(xmldoc,ReportXsl)#</cfoutput>
    But the display page comes up empty. No error either. Am I
    missing something??

    Hi,
    This is what i Get if i use the cfscript and writeoutput to
    do the xml transformation ..
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html> <head> <META http-equiv="Content-Type"
    content="text/html; charset=utf-8">
    <title>Report</title> </head>
    <body></body> </html>
    The XSL styles inside the body tag are not getting processed.
    Can someone shed any light on this? I have never worked with XSL's
    before.

  • How to generate the XML file to HTML?

    Hi all,
    I am new to XML.
    Can I somehow see the HTML-Output of the XML-File, when I have the XSL-File too, but don't use any XML-Editor (XMLSpy) and FOP? I do not want use any additional tools - only the database tools.
    What I need for this?
    Do I need the XSLT-File too?
    ============================
    My test.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="test.xsl"?>
    <ROW num="1">
         <TABLE_NAME>ABR_ART_ABR_DAU_MATRIX</TABLE_NAME>
         <TABLESPACE_NAME>PS2000_STAMM</TABLESPACE_NAME>
         <PCT_FREE>10</PCT_FREE>
         <INI_TRANS>1</INI_TRANS>
         <MAX_TRANS>255</MAX_TRANS>
         <INITIAL_EXTENT>516096</INITIAL_EXTENT>
         <NEXT_EXTENT>65536</NEXT_EXTENT>
         <MIN_EXTENTS>1</MIN_EXTENTS>
         <MAX_EXTENTS>2147483645</MAX_EXTENTS>
         <PCT_INCREASE>0</PCT_INCREASE>
         <LOGGING>YES</LOGGING>
         <BACKED_UP>N</BACKED_UP>
         <NUM_ROWS>33</NUM_ROWS>
         <BLOCKS>20</BLOCKS>
         <EMPTY_BLOCKS>0</EMPTY_BLOCKS>
         <AVG_SPACE>0</AVG_SPACE>
         <CHAIN_CNT>0</CHAIN_CNT>
         <AVG_ROW_LEN>100</AVG_ROW_LEN>
         <AVG_SPACE_FREELIST_BLOCKS>0</AVG_SPACE_FREELIST_BLOCKS>
         <NUM_FREELIST_BLOCKS>0</NUM_FREELIST_BLOCKS>
         <DEGREE> 1</DEGREE>
         <INSTANCES> 1</INSTANCES>
         <CACHE> N</CACHE>
         <TABLE_LOCK>ENABLED</TABLE_LOCK>
         <SAMPLE_SIZE>33</SAMPLE_SIZE>
         <LAST_ANALYZED>1/8/2004 11:45:1</LAST_ANALYZED>
         <PARTITIONED>NO</PARTITIONED>
         <TEMPORARY>N</TEMPORARY>
         <SECONDARY>N</SECONDARY>
         <NESTED>NO</NESTED>
         <BUFFER_POOL>DEFAULT</BUFFER_POOL>
         <ROW_MOVEMENT>DISABLED</ROW_MOVEMENT>
         <GLOBAL_STATS>YES</GLOBAL_STATS>
         <USER_STATS>NO</USER_STATS>
         <SKIP_CORRUPT>DISABLED</SKIP_CORRUPT>
         <MONITORING>NO</MONITORING>
         <DEPENDENCIES>DISABLED</DEPENDENCIES>
         <COMPRESSION>DISABLED</COMPRESSION>
    </ROW>
    ============================
    ============================
    My test.xsl-file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="html"/>
    <xsl:template match="/">
    <html>
    <head>
    <title>Test XSL ALL_TABLES</title>
    </head>
    <body>
    <xsl:for-each select="ROW">
    <h2>Tabelle: <xsl:value-of select="TABLE_NAME"/></h2>
         <hr/>
         <table border="1" cellpadding="0">
                             <tr>
                             <td><xsl:value-of select="TABLESPACE_NAME"/></td>
                             <td><xsl:value-of select="PCT_FREE"/></td>
                             </tr>
                        </table>
              </xsl:for-each>          
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    ============================
    I am waiting for your answers, when possible with examples please.
    Regards
    Leonid Pavlov

    XSLT to convert the XML document to Html:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:template match="/">
    <html>
    <head>
    <title>Test XSL ALL_TABLES</title>
    </head>
    <body>
    <table border="1" cellspacing="0">
    <tr>
    <th>TABLE NAME</th>
    <th>TABLESPACE NAME</th>
    <th>PCT FREE</th>
    </tr>
    <xsl:for-each select="ROW">
    <tr>
    <td><xsl:value-of select="TABLE_NAME"/></td>
    <td><xsl:value-of select="TABLESPACE_NAME"/></td>
    <td><xsl:value-of select="PCT_FREE"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

  • C++ versrion XML/XSL processor problem

    Hi Folks,
    I encounted the ' ' problem when I was trying to apply XSL style sheet to XML to generate html file. It seems no matter what way I ever tried, in the html, I only see the &#38 instead of getting the '&', that eventually prevents me from getting the   in html to get the non-breaking space.
    I looked through almost all the discussions about the question, but I only saw the java version solution. Could anyone give me some ideas about the C++ versioin solution.
    The parser version I am using is 2.0.4 in Solaris and I use the XSLSample which compiled from XSLSample.cpp.
    Any help will be greatly appriciated.
    Sean

    Starting with version 2.0.6, you can use the disable-output-escaping attribute.
    null

  • Problem transforming XML/XSL Using Xalan

    Hi, I am using the xalan apis to transform XML/XSL in a servlet..My servlet code is like...
    response.setContentType("text/html; charset=UTF-8");
    // Output goes in the response stream.
    PrintWriter out = response.getWriter();
    boolean environmentOK = (new org.apache.xalan.xslt.EnvironmentCheck()).checkEnvironment (out);
    try
    TransformerFactory tFactory = TransformerFactory.newInstance();
    // Get the XML input document and the stylesheet.
    Source xmlSource = new StreamSource("D:\\DATA\\jrun\\test\\test.xml");
    Source xslSource = new StreamSource("D:\\DATA\\jrun\\test\\test.xsl");
    // Generate the transformer.
    Transformer transformer = tFactory.newTransformer(xslSource);
    // Perform the transformation, sending the output to the response.
    transformer.transform(xmlSource, new StreamResult(out));
    I am getting the error ..
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParserjavax.xml.transform.TransformerConfigurationException
    That's why I have added the line..
    boolean environmentOK = (new org.apache.xalan.xslt.EnvironmentCheck()).checkEnvironment (out);
    But that gives me the following error diagnostic information...
    ERROR.version.DOM=ERROR attempting to load DOM level 2 class: java.lang.NoSuchMethodException
    I have put all the 3 required classes, xml-apis.jar, xercesImpl.jar and xalan.jar in my application servers classpath..
    Please let me know what I am doing wrong..and how this can be fixed.
    Thanks
    Surajit

    hey Surajit
    Your code is unable to create a transformer from a factory instance.
    I would check why it is not creating the Transformer.On my win32 system i usee two forward slashes..to identify the file path
    D://xyz//abc....instead of D:\\...i wonder if thats one reason why your code is not able to create a transformer based on the StreamSource u create for the file paths.
    Code i use..that works
    javax.xml.transform.TransformerFactory tFactory =
                                                                javax.xml.transform.TransformerFactory.newInstance();
                                                      javax.xml.transform.Source xmlSource = new javax.xml.transform.stream.StreamSource                              (xmlInputSource);
                                                 javax.xml.transform.Source xslSource = new javax.xml.transform.stream.StreamSource
                                       (xslInputSource);
                                                                                                        // Generate the transformer.
                                                                javax.xml.transform.Transformer transformer = tFactory.newTransformer(xslSource);
                                                                                                   // Perform the transformation, sending the output to the response.
                                                                transformer.transform(xmlSource,new javax.xml.transform.stream.StreamResult(out));
                                                                                                        I used jaxp-1.2 with tomcat 4.1.12
    Hope that helps.

Maybe you are looking for

  • I am unable to save my form responses as a pdf or excel file.

    I am unable to save my form responses as a pdf or excel file.  The error message states: Acrobat.com could not save this file. The file might be open in another application and cannot be overwritten.

  • How do I make timelines work independently - Flash CS3 AS2

    I've just done my first website in Flash, got all the navigation and buttons to work, but just have a final problem. I want a slideshow timeline (about 30 tweened images to run independently on a loop throughout the website, whilst still being able t

  • Female to femal adapter for external iSight?

    I have a 2011 mini and an external iSight connected by a 6pin - 9pin cable that I got with a hard drive. It works fine but I cannot use the apple mounts because they only work with the apple 6 pin cable. I know I can use a 6 pin to 9 pin adapter on t

  • Cisco ISE authentication failed because client reject certificate

    Hi Experts, I am a newbie in ISE and having problem in my first step in authentication. Please help. I am trying to deploy a standalone Cisco ISE 1.1.2 with WLC using 802.1x authentication. The user authentication configured to be checked to ISE's in

  • Conversion from "feet to inches"to"meter and centimeters"

    hi, i need this answer urgently!!!! i'm trying to write a java program that reads lenghts in feets and inches(or meters and centimeters(or feet and inches). the program askes the user if he/she wants to convert from "feet to inches" to "meters and ce