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.

Similar Messages

  • 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>

  • Problem for xml generation using DBMS_XMLGEN

    Hi All,
    i have problem during xml generation using Any help would be highly appreciate
    how could we publish xml data using data base API DBMS_XMLGEN in oracle applications (APPS) i.e. at 'View Output" using
    Any help would be highly appreciate.
    Let me know if need more explanation, this is High priority for me.
    Thanks and Regards,
    [email protected]
    Message was edited by:
    user553699

    You can set the null attribute to true , so that the tag appears in your XML
    see the statement in Bold.
    DECLARE
    queryCtx dbms_xmlquery.ctxType;
    result CLOB;
    BEGIN
    -- set up the query context
    queryCtx := dbms_xmlquery.newContext(
    'SELECT empno "EMP_NO"
    , ename "NAME"
    , deptno "DEPT_NO"
    , comm "COMM"
    FROM scott.emp
    WHERE deptno = :DEPTNO'
    dbms_xmlquery.setRowTag(
    queryCtx
    , 'EMP'
    dbms_xmlquery.setRowSetTag(
    queryCtx
    , 'EMPSET'
    DBMS_XMLQUERY.useNullAttributeIndicator(queryCtx,true);
    dbms_xmlquery.setBindValue(
    queryCtx
    , 'DEPTNO'
    , 30
    result := dbms_xmlquery.getXml(queryCtx);
    insert into clobtable values(result);commit;
    dbms_xmlquery.closeContext(queryCtx);
    END;
    select * from clobtable
    <?xml version = '1.0'?>
    <EMPSET>
    <EMP num="1">
    <EMP_NO>7499</EMP_NO>
    <NAME>ALLEN</NAME>
    <DEPT_NO>30</DEPT_NO>
    <COMM>300</COMM>
    </EMP>
    <EMP num="2">
    <EMP_NO>7521</EMP_NO>
    <NAME>WARD</NAME>
    <DEPT_NO>30</DEPT_NO>
    <COMM>500</COMM>
    </EMP>
    <EMP num="3">
    <EMP_NO>7654</EMP_NO>
    <NAME>MARTIN</NAME>
    <DEPT_NO>30</DEPT_NO>
    <COMM>1400</COMM>
    </EMP>
    <EMP num="4">
    <EMP_NO>7698</EMP_NO>
    <NAME>BLAKE</NAME>
    <DEPT_NO>30</DEPT_NO>
    <COMM NULL="YES"/>
    </EMP>
    <EMP num="5">
    <EMP_NO>7844</EMP_NO>
    <NAME>TURNER</NAME>
    <DEPT_NO>30</DEPT_NO>
    <COMM>0</COMM>
    </EMP>
    <EMP num="6">
    <EMP_NO>7900</EMP_NO>
    <NAME>JAMES</NAME>
    <DEPT_NO>30</DEPT_NO>
    <COMM NULL="YES"/>
    </EMP>
    </EMPSET>
    http://sqltech.cl/doc/oracle9i/appdev.901/a89852/d_xmlque.htm

  • Import xml/xsl using javascript

    I had problem in import a xml file with xsl using javascript. CS3 only take the elements in xml without any xsl information when I defined doc.xmlImportPreferences.transformFilename="c:\\sample.xsl"; What else do I need to define to allow CS3 know that my xsl file is sample.xsl.

    By the way, after I maunually import them, it can be handled by the program. I wonder there must be something missing when I try to import it viw Javascript at first time.

  • Problem writing xml file using DOM

    Hi,
    I am trying to write a xml file using DOM. I am using xalan 2.5, xerces 1.4.4, jdk 1.3.1 in JRun 3 on windows.
    The code where I get exception :
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   Transformer transformer = tFactory.newTransformer();
                   transformer.transform(new DOMSource(doc), new StreamResult("pr.xml"));
    I get the runtime error as follows:
    javax.servlet.ServletException: null
    java.lang.NoSuchMethodError
         at org.apache.xml.utils.DOM2Helper.getNamespaceOfNodeDOM2Helper.java:342)
         at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:387)
         at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:202)
         at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:343)
    Thinking it is because of classpath, I placed xalan 2.5, xerces 1.4.4 jar files in jrun admin lib directory and in server lib directory as well. Still getting the same error.
    Any suggestion?
    Thanks in advance

    xalan is included in JRun 4. However JRun 3 does not.
    However I tried with the same code in JRun3 in different system. The error is completely different. I understand this is because of different version of files. trying to solve ;)
    Here my new exception
    javax.servlet.ServletException: org/w3c/dom/ranges/DocumentRange
    java.lang.NoClassDefFoundError: org/w3c/dom/ranges/DocumentRange
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
         at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source)
         at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
         at com.cybell.appl.deliveryorder.cmd.CreateXMLDOFile.createFile(CreateXMLDOFile.java:73)
         at com.cybell.appl.deliveryorder.cmd.CreateXMLDOFile.execute(CreateXMLDOFile.java:36)
         at com.cybell.appl.framework.cmd.BaseCommand.start(BaseCommand.java:50)
         at com.cybell.appl.framework.control.BaseController.service(BaseController.java:38)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
         at allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatcher.java:34)
         at allaire.jrun.servlet.Invoker.service(../servlet/Invoker.java:84)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
         at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:88)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1131)
         at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:330)
         at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:107)
         at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
         at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)

  • Problem loading XML-file using SQL*Loader

    Hello,
    I'm using 9.2 and tryin to load a XML-file using SQL*Loader.
    Loader control-file:
    LOAD DATA
    INFILE *
    INTO TABLE BATCH_TABLE TRUNCATE
    FIELDS TERMINATED BY ','
    FILENAME char(255),
    XML_DATA LOBFILE (FILENAME) TERMINATED BY EOF
    BEGINDATA
    data.xml
    The BATCH_TABLE is created as:
    CREATE TABLE BATCH_TABLE (
    FILENAME VARCHAR2 (50),
    XML_DATA SYS.XMLTYPE ) ;
    And the data.xml contains the following lines:
    <?xml version="2.0" encoding="UTF-8"?>
    <!DOCTYPE databatch SYSTEM "databatch.dtd">
    <batch>
    <record>
    <data>
    <type>10</type>
    </data>
    </record>
    <record>
    <data>
    <type>20</type>
    </data>
    </record>
    </batch>
    However, the sqlldr gives me an error:
    Record 1: Rejected - Error on table BATCH_TABLE, column XML_DATA.
    ORA-21700: object does not exist or is marked for delete
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
    If I remove the first two lines
    "<?xml version="2.0" encoding="UTF-8"?>"
    and
    "<!DOCTYPE databatch SYSTEM "databatch.dtd">"
    from data.xml everything works, and the contentents of data.xml are loaded into the table.
    Any idea what I'm missing here? Likely the problem is with special characters.
    Thanks in advance,

    I'm able to load your file just by removing the second line <!DOCTYPE databatch SYSTEM "databatch.dtd">. I dont have your dtd file, so skipped that line. Can you check if it's problem with ur DTD?

  • Problem Transforming XML to JSF tags

    I have a fealing there is something I don't know here,
    I am transforming XML into a JSP that include tags from taglib http://java.sun.com/jsf/html (prefix="h")
    This is an section from my stylesheet
    <xsl:template name="forename">
    <h:inputText>
    <xsl:attribute name="value">#{abyss.myCustomer.forename}</xsl:attribute>
    </h:inputText>
    </xsl:template>
    which transforms my XML to exactly what I expect if a was writting it directly as a jsp
    <h:inputText value="#{abyss.myCustomer.forename}"></h:inputText>
    but it still looks like this after it is rendered in the browser, and not like
    <input type="text" name="dataCapture:j_id_id199" value="Customer Name" />
    which is how it looks if I cut and paste the result of the transformation into a jsp, and run that by itself
    Does anyone have any idea was the <h:inputText does not evaluate the tag in the browser after the transformation ?
    Edited by: OB1 on Nov 23, 2007 1:46 PM
    Edited by: OB1 on Nov 23, 2007 2:43 PM

    Unfortunatly I do, my jsp is
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml_rt" %>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <html>
    <c:set value="${abyss.myBusinessServicePath}" var="xmldocpath"></c:set>
    <c:import url="${xmldocpath}" var="xmldoc"/>
    <c:import url="/xsl/transform.xsl" var="xslt"/>
    <x:transform xml="${xmldoc}" xslt="${xslt}"/>
    </html>

  • Programmatically transform xml report using Labview

    I want to transform the standard xml report from Teststand into a more user-friendly file format for users that need to view reports, but don't have access to the test station.  Check out the attached code.  It should work, but I get this error. "Objects of type 'Script2' do not have such a member"  'Script2' is referring to the msxsl:script javascript node in the Teststand horizontal.xsl stylesheet. 
    Solved!
    Go to Solution.

    I agree with kwkengineer.  The HTML report is fugly... haha.  You can change the colors but I still don't like the format.
    kwkengineer,
    I was actually trying to do the same thing as you.  We have customized our style sheet and now people are complaining because they need it and the xml file to view it.  I also don't want to rewrite the HTML generation.  I might welcome the task if we were using the new version of TestStand with plugins but we aren't, and it's too expensive to upgrade right now.
    I do know that if you right click on the report in the viewer and choose "view source" you will get an html output of your xml report.  So my question is, and I dig around some more because I've only spent about an hour on this, how does the viewer in TestStand translate the xml report to the html one that is displayed in it.  I noticed there is a TempReport.html in the report folder.  However, it disappears when you close the finished execution.
    Not sure if any of this is helpful but I will spend some more time routing around.
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Transformer(XML, Xsl)

    Hello
    There is my class. When I run it I get error: stylesheet requires attribute version ; missimg or incorect XSLT Namespaces
    What to do?
    I have in database XML and Xsl file and i nead this function to join them.
    import java.io.*;
    import java.lang.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.parsers.DocumentBuilder;
    public class Parser{
         public static void main(String[] args)     {
                   Parser f = new Parser();
                   f.join();
         public void join(){
              try{
                   File stylesheet = new File("d:/jelenak/install/vezba/cdcatalog.xsl");
                   File xmlfile = new File("d:/jelenak/install/vezba/cdcatalog.xml");
                   File outputFile=new File("d:/jelenak/install/vezba/cdcatalog.xml");
                   TransformerFactory tFactory =TransformerFactory.newInstance();
                   StreamSource stylesource = new StreamSource(stylesheet);
                   StreamSource source = new StreamSource(xmlfile);
                   StreamResult result = new StreamResult(outputFile);
                   Transformer transformer = tFactory.newTransformer(stylesource);
                   transformer.transform(source, result);
              }catch (Exception e) {
                   e.printStackTrace(System.err);
    Thanks a lot

    aaaaaah! in a servlet, ok.
    you can build a StreamResult on the Servlet response output stream.
    personally, to provide the browser with the correct size of data to receive in the HTTP header, i output the XSLT result in a ByteArrayOutputStream (baos) then i use this kind of code in my servlet:
    response.setContentType("text/xml");
    response.setContentLength(baos.size());
    baos.writeTo(response.getOutputStream());

  • Transforming XML/XSL data to PDF

    What is a process to convert a XML document to a PDF? Where could I find some Java classes that aid in this process?

    There's XSL Formatter from www.antennahouse.com, and there's FOP from xml.apache.org/fop, and probably others that could be found by a simple Google search.

  • Transforming XML/XSLT : CDATA problem

    Hi!
    I have a problem transforming xml with XSLT using the API javax.xml.
    The result is correct until I have a CDATA section in my xml document.
    The transforming process encodes all the & < > (special characters) it finds in.
    This occurs problem for the follow of my treatement because the content of my CDATA is already encoded.
    For example, this xml code :
    <?xml version='1.0' encoding="ISO-8859-1" ?>
    <article>
    <article-contenu><![CDATA[Accent : &eacute; Signe : &lt;]]></article-contenu>
    </article>
    produces in my output :
    Accent : &amp;eacute; Signe : &amp;lt;
    This is my java code :
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Source xmlSource = new StreamSource(readerXml);
    Source xslSource = new StreamSource( fileXsl );
    // Generate the transformer.
    Transformer transformer = tFactory.newTransformer(xslSource);
    // Perform the transformation, sending the output to the response.
    transformer.transform(xmlSource, new javax.xml.transform.stream.StreamResult(sw));
    How can I tell the transformer not to do that?
    Thanks for your answers!

    I am having a similar problem. I have enclosed my text data in my xml file like this:
    <![CDATA[<b>Hello World!</b>]]>
    My select statement in my XSLT sheet is as follows:
    <xsl:value-of select="." disable-output-escaping="yes"/>
    I have tried setting xsl:output to text, to html, and to xml. The <, >, and & get converted to xhtml entities.
    Where should I begin to troubleshoot? If the Xalan xslt jars? My stylesheet. My xml doc? Java code?
    Any feedback welcome.

  • Problem Tranforming xml using jstl

    Hello To Every One
    I have transformed xml document using servlet now i need to know how can i transform xml document using jstl. I have found this code very often but it doesn't work with a relative or absolute url. I need to pass parameters dynamically.
    <c:import var="xml" url="<%=xmlFile%>" />
    <c:import var="xslt" url="<%=xsltFile%>" />
    <x:transform xml="${xml}" xslt="${xslt}" />In this code I have to pass xmlFile and xsltFile parameter dynamically and i want to make it as session variables. When i put relative url in *<c: import >* tag it works fine but for absolute url it does not work. Although I doesnot want to pass absolute url but relative ones, but how can i achieve that one.
    E.G.
    <x:transform xml="relative url for xmlfile" xslt="relative url for xslt file" />If anyone have the solution please reply me as soon as possible. Thanx in Advance for your kind Attention.

    Thanx for your answer This is my Code which works fine.
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
    <html>
      <head>
      </head>
      <body>
        <form method="post">
       <c:import var="xml" url="..\\data\\192.168.1.94\\master.xml" />
    <c:import var="xslt" url="..\\other\\Masterview.xsl" />
    <x:transform xml="${xml}" xslt="${xslt}" />
        </form>
      </body>
    </html>But in <c:import > tag i want to put url value dynamically so when i convert that string to a variable and pass that variable into url attribute it does not work.
    Like This
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
    <html>
      <head>
      </head>
      <body>
       <%
       try{
            String xmlFile="..\\data\\"+session.getAttribute("param1").toString()+"\\master.xml";
            String xsltFile="..\\other\\"+session.getAttribute("param2").toString()+"\\MasterView.xsl";
            }catch(Exception ep){ep.printStackTrace();}
       %>
        <form method="post">
       <c:import var="xml" url="<%=xmlFile.toString()%>" />
    <c:import var="xslt" url="<%=xsltFile.toString()%>" />
    <x:transform xml="${xml}" xslt="${xslt}" />
        </form>
      </body>
    </html>

  • Transforming XML Data with XSLT in a servlet

    Trying to transform XML data using XSLT. The following code works fine outside of a servlet. But in a servlet it gives the following error :
    * Transformer Factory error
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParser
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParser
         at org.apache.xml.utils.DefaultErrorHandler.fatalError(DefaultErrorHandler.java:257)
         at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:813)
         at TransformationApp.XSLTTransformServlet.MyTransform(XSLTTransformServlet.java:79)
         at TransformationApp.XSLTTransformServlet.doGet(XSLTTransformServlet.java:39)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Several articles hinted at setting the factory namespace attribute to TRUE. I have tried that but same results. Here is the code :
    static Document document;
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    //factory.setNamespaceAware(true);
    //factory.setValidating(true);
    try {
    File stylesheet = new File(argv[0]);
    File datafile = new File(argv[1]);
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse(datafile);
    // Use a Transformer for output
    TransformerFactory tFactory =
    TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource(stylesheet);
    Transformer transformer = tFactory.newTransformer(stylesource);
    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(System.out);
    transformer.transform(source, result);
    } catch (TransformerConfigurationException tce) {
    // Error generated by the parser
    System.out.println ("\n** Transformer Factory error");
    System.out.println(" " + tce.getMessage() );
    // Use the contained exception, if any
    Throwable x = tce;
    if (tce.getException() != null)
    x = tce.getException();
    x.printStackTrace();
    } catch (TransformerException te) {
    // Error generated by the parser
    System.out.println ("\n** Transformation error");
    System.out.println(" " + te.getMessage() );
    // Use the contained exception, if any
    Throwable x = te;
    if (te.getException() != null)
    x = te.getException();
    x.printStackTrace();
    } catch (SAXException sxe) {
    // Error generated by this application
    // (or a parser-initialization error)
    Exception x = sxe;
    if (sxe.getException() != null)
    x = sxe.getException();
    x.printStackTrace();
    } catch (ParserConfigurationException pce) {
    // Parser with specified options can't be built
    pce.printStackTrace();
    } catch (IOException ioe) {
    // I/O error
    ioe.printStackTrace();
    Any help would be greatly appreciated.

    I don't know that this is true, but i think the problem is the classpath.
    The runtime has his own parser. This parser is befor your xalan.lib in the classpath and the
    parser from the runntime don't support namespace.
    Try Tomcat 4.
    Regard Dietmar

  • 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!

  • "encoding = UTF-8" missing while writing XML file using file Adapter

    Hi,
    We are facing an unique problem writing xml file using file adapter. The file is coming without the encoding part in the header of xml. An excerpt of the file that is getting generated:
    <?xml version="1.0" ?>
    <customerSet>
    <user>
    <externalID>51017</externalID>
    <userInfo>
    <employeeID>51017</employeeID>
    <employeeType>Contractor</employeeType>
    <userName/>
    <firstName>Gail</firstName>
    <lastName>Mikasa</lastName>
    <email>[email protected]</email>
    <costCenter>8506</costCenter>
    <departmentCode/>
    <departmentName>1200 Corp IT Exec 8506</departmentName>
    <businessUnit>1200</businessUnit>
    <jobTitle>HR Analyst 4</jobTitle>
    <managerID>49541</managerID>
    <division>290</division>
    <companyName>HQ-Milpitas, US</companyName>
    <workphone>
    <number/>
    </workphone>
    <mobilePhone>
    <number/>
    </customerSet>
    </user>
    So if you see the header the "encoding=UTF-8" is missing after "version-1.0".
    Do we need to configure any properties in File Adapter?? Or is it the standard way of rendering by the adapter.
    Please advice.
    Thanks in advance!!!

    System.out.println(nodeList.item(0).getFirstChild().getNodeValue());

Maybe you are looking for