XML transformation problems - URGENT!!!!!

Hi,
I have a problem on writing data into XML files on Win NT/Tomcat platform from a servlet. This problem has been getting on my nerves for the past few weeks now. It was earlier giving a SecurityException: sealing violation error, when trying to write into the XML file using the Transformer object's transform method. What I need to do is, just read in data from the XML file first, do some processing and then dump in the results back in the same XML file.
I managed to get rid of the Sealing violation exception now, by downloading the xalan2 package and giving the reference of the new xalan.jar in the classpath. I am using the JAXP Transformer class's transform method to change the XML document. But, the problem now is that it is throwing a NoSuchMethodError exception on the line where the transform(source, result) method is coded.
This is the source code:
private void writeXMLData(Node n) throws IOException
     Transformer transformer;
     StreamResult streamresult;
     DOMSource domsource;
     TransformerFactory factory;
     factory= TransformerFactory.newInstance();
     try
     transformer = factory.newTransformer();
     domsource = new DOMSource(n);
transformer.transform(domsource, new javax.xml.transform.stream.StreamResult(new                FileOutputStream("d:\\tomcat\\webapps\\ROOT\\Orders.xml")));
     catch (Exception e)
          e.printStackTrace();
transformer = null;
factory=null;
domsource= null;
streamresult=null;
This is the error that is thrown:
java.lang.NoSuchMethodError: org.w3c.dom.Node: method getNamespaceURI()Ljava/lang/String; not found
     at org.apache.xpath.DOM2Helper.getNamespaceOfNode(DOM2Helper.java:348)
     at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java, Compiled Code)
     at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java, Compiled Code)
     at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java, Compiled Code)
     at test.TestOrderAdd_proto.writeXMLData(TestOrderAdd_proto.java:427)
     at test.TestOrderAdd_proto.doPost(TestOrderAdd_proto.java:228)
     at test.TestOrderAdd_proto.doGet(TestOrderAdd_proto.java:246)
     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:402)
     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:797)
     at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
     at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
     at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled Code)
     at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
     at java.lang.Thread.run(Thread.java:479)
The classpath settings are:
d:\jaxp-1.1\jaxp.jar;d:\xalan2\xalan-j_2_2_D9\bin\xalan.jar;d:\jaxp-1.1\crimson.jar (in that order)
Could anyone please help me out with this problem?
Thanks,
Jatin

I assume you're starting tomcat by using the tomcat.bat file. Keep in mind that this batch file adds every .jar file in tomcat's lib directory BEFORE your own classpath and it usually contains a parser.jar file, which might cause problems, it also contains a jaxp.jar.
If you want to switch to xerces, remove jaxp and crimson from your classpath and add xerces.jar to it (xerces contains jaxp). In the case of tomcat, you'd need to delete parser.jar and add xerces.jar to its lib dir.
Hope that helps.

Similar Messages

  • XML Transformation Problem in JDeveloper 11.1.1.3.0

    Friends,
    I am trying to transform an XML using an XSL, by a Java program, which uses javax.xml.transform.Transformer.
    I have a Java project which has the above program and I have a Web project created, where i have the java project's jar in the WEB-INF/lib. And, when i tried to access the same java program from inside the web project, I am getting the following error:
    XML-22000: (Fatal Error) Error while parsing XSL file ({0}).
    oracle.jbo.JboException: XML-22000: (Fatal Error) Error while parsing XSL file ({0}).
    Code in ServiceAMImpl class:
    TransformerFactory factory = TransformerFactory.newInstance();
    template =
    factory.newTemplates(new StreamSource(AMImpl.class.getClassLoader().getResourceAsStream("text.xsl")));
    AMImpl.class.getClassLoader().getResourceAsStream("text.xsl") is returning NULL.
    Please help in resolving this error.
    Thanks much.

    Hi,
    I figured out the problem. The file was not in correct class path. Now it works fine.
    Thanks everyone.

  • XML Transformation Problem in JDeveloper 10.1.3

    I am trying to transform an XML using an XSL, by a Java program, which uses javax.xml.transform.Transformer.
    I have a Java project which has the above said program, where when i run the program, the xml transformation is done successfully.
    But I have a Web project created, where i have the java project's jar in the WEB-INF/lib. And, when i tried to access the same java program from inside the web project, I am getting the following error:
    XML-22000: (Fatal Error) Error while parsing XSL file (unknown protocol: c).
    Please help in resolving this error.

    This is from Metalink:
    Cause
    This is caused by a conflict between the Oracle XML parser installed by default in OC4J and the
    Xerces parser that the application was developed with. Under 10.1.3 OC4J it is possible to tell OC4J not to use the default XML parser for the application at deployment time.
    Solution
    1. Undeploy the existing application using AS Console.
    2. Start a new deployment of the application in AS Console. Click deploy
    3. On the Deploy: Select Archive screen, browse to your deployment war file. Click Next
    4. On the Deploy: Application Attributes give the application a name and click next
    5. On the Deploy: Deployment Settings screen, click the pencil "Go To Task" Icon for the Configure Class Loading option.
    6. Locate the shared library called "oracle.xml" (You may need to click "next 10" one or many times depending on the number of shared libraries you have) . For this row, UNCHECK the box for the column "IMPORT". Click OK
    7. Click deploy, then test you application.

  • ABAP XML transformation problem

    Hi all,
    I am creating an XML based on a custom transformation I have made. The problem I have is that my variables type P decimals 2 are passed to the XML with just one decimal place, but I need two decimal places.
    I was investigating and SAP documentation says that it should be passed with 2 decimal places according to the conversion, however it is not working in my case.
    The only solution I found is making those variables type C, but I really want a solution that allows me keep my fields as type P.
    Thanks in advance

    Hi,
    That's strange, it works well on my computer. I guess you should check SAP notes or contact SAP support.
    Sandra

  • Jaxb & XML & encoding problem                      *URGENT*

    Hello,
    ***Do not be scared because of the length of the question please. I tried to explain problem clearly.***
    I am developing a Web service for a particular client. The client has provided .wsdl and some .xsd files for me.
    I used JWSDP-2.0 to generate holder classes from those .xsd files. In order to specify the root elemnen, I added "@XmlRootElement" annotation in front of the ServiceInfo class (, and also imported "javax.xml.bind.annotation.XmlRootElement"). I am using Eclipse in this project.
    I prepared the Web service exactly as specified by the client, but when I test it with the client the client application cannot show the XML data that it receives as a response to its request. The client application opens a file, writes the XML response to that file and also shows the response on the client application window. However, that file is always empty and I see nothing on the client application window. I do not have the client application's source code, but I do know that client application has no bug.
    NOTE: I have a guideline for developing the Web Service for this particular client and it says there: "ServiceInfo is transfered as a Unicode string, and then encoded as UTF-16."
    (Actually I don't know whether this is the reason of my problem but it is still sth that should be known I guess.)
    Here is the code of my method:
    public java.lang.String getServiceInfo() throws java.rmi.RemoteException {
    JAXBContext servInfoContext = JAXBContext.newInstance("com.gw.oms.serviceinfo"); //com.gw.oms.serviceinfo is the directory where all generated java (from serviceinfo.xsd file) files are stored.
    // create an ObjectFactory instance, create instances of holder classes
    // (root element is "serviceInfo") and set their values.
              try {
                   StringWriter writer = new StringWriter();
                   Marshaller marshaller = servInfoContext.createMarshaller();
                   marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-16");
                   marshaller.marshal(serviceInfo, writer);
                   return writer.toString();
              } catch (JAXBException e) {
                   throw new RemoteException("Error marshalling serviceInfo", e);
    I guess the code piece in the try-catch block is true, but maybe I am continuously missing sth. Can you see any wrong thing in the code?
    In order to see what is happenning in the communication between my Web Service and the client application I analyzed the traffic between them via Ethereal network sniffing tool. Here is some info:
    FROM CLIENT TO WEB SERVICE: (Data Content of HTTP packet)
    <?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope
    xmlns:soap="http://schema.xmlsoap.org/soap/envelope"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <GetServiceInfo
    xmlns="http://....XXX....."/>
    </soap:Body>
    </soap:Envelope>
    FROM WEB SERVICE TO CLIENT: (Data Content of HTTP packet)
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope
    xmlns:soap="http://schema.xmlsoap.org/soap/envelope"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <GetServiceInfoResult
    xmlns=""/> **>> WARNING 1 <<**
    <?xml version="1.0" encoding="UTF-16" standalone="yes"?>\n<serviceInfo xmlns="http://....XXX..../serviceInfo"><serviceProvider>Service Provider Name< **>> WARNING 2 <<**
    </GetServiceInfoResult>
    </soapenv:Body>
    </soapenv:Envelope>
    **>> WARNING 1 <<**: WHY IS 'XMLNS' EMPTY HERE??? SHOULDN'T IT BE "http://....XXX....." ALSO????
    **>> WARNING 2 <<**: WHY DON'T I SEE THE COMPLETE SERVICEINFO HERE? ONLY 1 HTTP RESPONSE PACKET IS BEING SENT TO THE CLIENT BY MY WEB SERVICE.
    If I make Eclipse write to the console what I am sending, I see the result below:
    <?xml version="1.0" encoding="UTF-16"?>
    <serviceInfo xmlns="http://....XXX...../serviceInfo">
    <serviceProvider>MY UNIVERSITY</serviceProvider>
    <serviceUri>http://myserviceuri.com</serviceUri>
    <signUpPage>http://signupmyservice/services/ITUServiceSoap</signUpPage>
    <targetLocale>1053</targetLocale>
    <localName>MIN SERVIS</localName>
    <englishName>MY SERVICE</englishName>
    <authenticationType>other</authenticationType>
    <supportedService>
    <SMS_SENDER maxSbcsPerMessage="160" maxRecipientsPerMessage="400" maxMessagesPerSend="5" maxDbcsPerMessage="0"/>
    </supportedService>
    </serviceInfo>
    Somehow the client application cannot receive (or validate) the serviceinfo that my Web service sends. I suspect that sth is wrong with my Java code. Can any one see any error in this schema?
    I am really stucked. Any recommendation would be very valuable for me.
    Thanks & Regards

    I feel like nobody is following this forum anymore.. :)
    Does anybody have any idea...?
    Regards

  • Styling XML with XSLT Problem with javax.xml.transform???

    I have been trying to make a transformation and seem to be having a problem in that javax.xml.transform can not be found while using jdk1.3....If I use jdk1.4, there is no problem....
    Does anyone know how I can get things to work using jdk1.3???
    (Description of what I am doing...1) Building XML Source 2) Setting up the XSLT File 3) Building Source Object 4) Build Result Object 5) Transforming the Data.....MY RESULT SHOULD BE AN HTML PAGE)
    I have tried putting xerces.jar and xalan.jar in my CLASSPATH....but this still doesn't work....onyl thing that has worked is using jdk1.4 as my JAVA_HOME....
    PLEASE HELP!!!!

    PLEASE HELP....your advice here would be greatly appreciated.....

  • Problem with JBuilder and javax.xml.transform package

    Hi,
    My JBuilder 7 can not find javax.xml.transform package. i use javax.xml.parsers package but i can not access to javax.xml.transform. is there a problem or something necessary to do to access that?
    Best Wishes - WiseWarrior

    Hey WiseWarrior,
    your problem is directly related to your jar file in run time. The xml parser jar which you are using to perform transfor is not having the appropriate classes, take the latest version of xalan it has transform package and put it into your class path, it will work.
    CheerS!!
    Sandeep Raikwar

  • Java transform problem - resulting XML has wrong namespace on imported Node

    I use Document.importNode(Node, String) to import a node from one document into another document. I want to preserve the namespace of the imported node. This works ok if the imported node specifies xmlns, even xmlns="". But if the imported node does not specify a namespace, I would expect the resulting serialized XML to have xmlns="". However, this is not the case. I use javax.xml.transform.Transformer when I serialize the XML. After the transform, the imported node has the namespace of the document it is imported into, which we do not want. So how do I get the imported node to serialize out with xmlns="", even if it's not specified in the source document? I am using javax.xml.transform.* and javax.xml.parsers.DocumentBuilder from Java 1.4.2.
    Example of XML that node is imported into (imported node replaces PayloadPlaceHolder):
    <?xml version="1.0" encoding="UTF-8"?>
    <Envelope envelopeVersion="0.0.0" classificationLevel="Unclassified" xmlns="http://disa.gcss.mil/XMLGateway/Envelope">
    <Header>
    <UID>GM0000001</UID>
    <DateTime>2006-12-05T16:11:50Z</DateTime>
    </Header>
    <Status reason="FAILED" lastTransactionID="9999999999" inReplyTo="ZZZ9999999999">
    <LastMessageUID>ZZZ9999999999</LastMessageUID>
    </Status>
    <Payload>
    <PayloadPlaceHolder>
    </PayloadPlaceHolder>
    </Payload>]
    </Envelope>
    Example of XML with null namespace, test_segment is imported node:
    <?xml version="1.0" encoding="UTF-8"?>
    <test_segment>
    <name>test</name>
    </test_segment>
    Example of result XML with imported node (test_segment):
    <?xml version="1.0" encoding="UTF-8"?>
    <Envelope classificationLevel="Unclassified" envelopeVersion="0.0.0" xmlns="http://disa.gcss.mil/XMLGateway/Envelope">
    <Header>
    <UID>GM0000001</UID>
    <DateTime>2006-12-05T16:11:50Z</DateTime>
    </Header>
    <Status inReplyTo="ZZZ9999999999" lastTransactionID="9999999999" reason="FAILED">
    <LastMessageUID>ZZZ9999999999</LastMessageUID>
    </Status>
    <Payload>
    <test_segment>
    <name>test</name>
    </test_segment>
    </Payload>
    </Envelope>
    Here is the code to build the documents and transform the XML:
         Document document = null;
    Document dataBlockDoc = null;
    ByteArrayInputStream inStream = new ByteArrayInputStream
    (StringUtils.getBytes(xml.toString()));
    try {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware( true );
    DocumentBuilder parser = dbf.newDocumentBuilder();
    document =
    parser.parse(
    new InputSource(inStream ) );
    if (dataBlock != null) {
    inStream = new ByteArrayInputStream(StringUtils.getBytes(dataBlock));
    dataBlockDoc = parser.parse(
    new InputSource(inStream ) );
    Element root = document.getDocumentElement();
    Element payload = null;
    NodeList children = root.getChildNodes();
    //get Payload child from envelope document
    for (int i = 0; i < children.getLength(); i++) {
    if (children.item(i).getNodeName().equals("Payload")) {
    payload = (Element)children.item(i);
    break;
    //get the PayloadPlaceHolder
    Element payloadPlaceHolderElement = null;
    children = payload.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
    if (children.item(i).getNodeName().equals("PayloadPlaceHolder")) {
    payloadPlaceHolderElement = (Element)children.item(i);
    break;
    Node newPayload = null;
    if (dataBlockDoc != null) {
    Element dataBlockElement = dataBlockDoc.getDocumentElement();
    //make new Payload element to replace old (empty) Payload
    newPayload = document.importNode((Node) dataBlockElement, true);
    payload.replaceChild(newPayload, payloadPlaceHolderElement);
    else
    payload.removeChild(payloadPlaceHolderElement);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer nullTransform = tf.newTransformer();
    ByteArrayOutputStream oStream = new ByteArrayOutputStream();
    nullTransform.transform(                    new DOMSource( document ),
         new StreamResult( oStream ) );
    xml = new StringBuffer(oStream.toString());
    Thanks in advance.

    It appears that the problem is that the DOM serializer implementation in JDK 1.4 is not properly handling namespaces. Does anyone know of a workaround or alternate serializers we could use to serialize a DOM tree? I also need it to work with XSLT.
    Thanks.

  • Problem with return of javax.xml.transform.Source impl from webService

    I have a web services that needs to return an XML string to the calling client. If I return the XML as a String object it gets deserialized twice and the end result is no longer XML. My research indicates that I can return an implementation of javax.xml.transform.Source and this will cause SOAP to attach the XML string to the message rather than embed it (protecting it from deserialization). The following is the effective part of my method:
    public Source[] consumeTextMessage(String id) throws RemoteException {
    try {
    MessageConsumer mc = new MessageConsumer();
    String[] messages = mc.consumeTextMessage(id);
    StreamSource[] sources = new StreamSource[messages.length];
    for(int i = 0; i < messages.length; i++) {
    sources[ i ] = new StreamSource();
    return sources;
    } catch(RemoteException e) {
    throw e;
    note: the mc.consumeTextMessage(id) call works correctly and I know that I'm not putting anything in the StreamSource objects in the loop to build the array of StreamSource objects - just trying to get SOMETHING to work
    so this deploys without problem, but when I try to get a wsdl for the webservice i get a Server 500 error; the log says this:
    javax.servlet.ServletException: WSDL Generation exception: java.lang.Exception javax.xml.transform.Source is an abstract class: cannot be instanciated
    ok.... if I change the method return type to a concrete class (StreamSource[]), redeploy and try to get a wsdl, I get this absolutely crazy error:
    javax.servlet.ServletException: WSDL Generation exception: java.lang.Exception java.io.Reader is an abstract class: cannot be instanciated
    I have NO clue why it thinks it needs a Reader.
    If I change the method return type to String[] (and make the various adjustments to the method) then it deploys ok and gives me a good WSDL (though it still doesn't work because the Strings are deserialized twice so this isn't a viable solution but it does show that my webservice config is correct).
    So... bottom line seems to be that the webService "engine" of 10g AS doesn't like Source or StreamSource.....
    Any ideas what I can do??

    Funny story here: trying to deploy a different webserivce all together and got the same error message; thought I remembered seeing it before but wasn't sure; did a google search on it and lo and behold came across my first posting in this thread.... crazy.
    Anyway, I have discovered something that answers some of the questions I had in my first post: It seems that the argument types used in a webservice signature MUST be CONCRETE classes (and I would think primitives would work too though I don't remember trying them) - they can not be Interfaces or abstract classes. Probably if I read the webservices spec it would tell me that.
    So the error I was getting before was because Source was not a concrete class, and presumably the second error was caused by some signature somewhere along the line using the Reader abstract class.
    Fun stuff.

  • File size problem when performing XML Transformation into Excel

    Hi All,
    We are performing XML Transformation in ABAP which can open in Excel and saving to common share. But the file size of excel is around 50MB. After opening the excel and save with diffrent name the file is getting compressed and its below 1MB. So what kind of settings does we need to make to the transformation code which will create the excel files with less memory/size??
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="AAAAAAA"/>
    <tt:root name="BBBBBBBB"/>
    <tt:root name="CCCCCCCC"/>
    <tt:template>
    <?mso-application progid="Excel.Sheet"?>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:html="http://www.w3.org/TR/REC-html40">
       <ProtectObjects>True</ProtectObjects>
       <ProtectScenarios>True</ProtectScenarios>
      </WorksheetOptions>
    </Worksheet>
    </Workbook>
    </tt:template>
    </tt:transform>
    <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
    </DocumentProperties>
    <CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
      <ContentTypeId dt:dt="string">0x01010049B4763FE606154C9C9BC639FE7EE179</ContentTypeId>
    </CustomDocumentProperties>
    <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
      <Colors>
       <Color>
        <Index>0</Index>
        <RGB>#FF0000</RGB>
       </Color>
       <Color>
        <Index>1</Index>
        <RGB>#FFE4B5</RGB>
       </Color>
       <Color>
        <Index>2</Index>
        <RGB>#FFF8DC</RGB>
       </Color>
       <Color>
        <Index>3</Index>
        <RGB>#000000</RGB>
       </Color>
      </Colors>
    </OfficeDocumentSettings>
    <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
      <WindowHeight>7305</WindowHeight>
      <WindowWidth>11340</WindowWidth>
      <WindowTopX>0</WindowTopX>
      <WindowTopY>0</WindowTopY>
      <TabRatio>334</TabRatio>
      <ProtectStructure>True</ProtectStructure>
      <ProtectWindows>False</ProtectWindows>
    </ExcelWorkbook>
    </DocumentProperties>
    <CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
      <ContentTypeId dt:dt="string">0x01010049B4763FE606154C9C9BC639FE7EE179</ContentTypeId>
    </CustomDocumentProperties>
    <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">

    Hi Raghu,
    have a look at the XLSX file generated by Excel, you'll see that it's simply a zipped file. So you can't do it with a transformation, but you need CL_ABAP_ZIP class. I advise you to look at the abap2xslx project ABAP code (currently 3.0) to see how it works.
    Best regards,
    Sandra

  • XSL problem with javax.xml.transform.sax.SAXTransformerFactory

    Dear sirs,
    I use SAXTransformerFactory in order to transform a Hashtable to SAX Event and apply a XSL.
    I try this code with the lastest version of apache parser.
    It run well.
    But, I put this software to WEBLOGIC 6.2 server and no run.
    this check is true:
              if (transFact.getFeature(javax.xml.transform.sax.SAXTransformerFactory.FEATURE)&&transFact.getFeature(javax.xml.transform.sax.SAXSource.FEATURE))
    Some one can help me.
    Thank in avance
    The code:
    java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
              com.cajarural.xml.HashtableParser parser = new com.cajarural.xml.HashtableParser(hashtable);
              // Codigo para el TansformerHandler
              // set the destination for the XSLT transformation
                   javax.xml.transform.TransformerFactory transFact = javax.xml.transform.TransformerFactory.newInstance();
                   if (transFact.getFeature(javax.xml.transform.sax.SAXTransformerFactory.FEATURE)&&transFact.getFeature(javax.xml.transform.sax.SAXSource.FEATURE))
    javax.xml.transform.sax.SAXTransformerFactory saxTransFact = (javax.xml.transform.sax.SAXTransformerFactory) transFact;
    javax.xml.transform.sax.TransformerHandler transHand = saxTransFact.newTransformerHandler(templates);
    transHand.setResult(new javax.xml.transform.stream.StreamResult(bout));
    parser.setContentHandler(transHand);
    // attach the XSLT processor to the           parser.parse();
              return new String(bout.toByteArray());

    put Xalan in your war file then try using this kind of commands:     System.setProperty("org.xml.sax.parser", "org.apache.xerces.parsers.SAXParser");
    System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");This tells JAXP what implementations it should use without even asking your administrator to modify the WebLogic setup...
    It's what I've done with the WLS7.0 server I am using ;-)

  • Fatal Error and NullPointerException in Oracle XML Transformer

    Hi,
    I'm building a dom tree in memory with oracle xml parser. Then I transform the dom document into a string to send xml to the client. But I get an fatal error on calling transform.
    I don't know what could be the problem, because apache and weblogic parser works, an when I create a dom document with org.w3c.dom elements and statements then the xml document can't be invalid,
    because the document implementation would throw an exception if wrong nodes or something like this should be inserted...
    I'm using oracle xml parser 9.2.0.4 for java, bea weblogic 7.0 and win2k.
    Thanks for help.
    XSL-1900: (Fatal Error) An internal error condition occurred.
    javax.xml.transform.TransformerException: XSL-1900: (Fatal Error) An internal error condition occurred.
    at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:681)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:309)
    java.lang.NullPointerException
    at oracle.xml.parser.v2.XSLSAXPrintDriver.printAttributes(XSLSAXPrintDriver.java:394)
    at oracle.xml.parser.v2.XSLSAXPrintDriver.startElement(XSLSAXPrintDriver.java:322)
    at oracle.xml.parser.v2.XMLElement.reportSAXEvents(XMLElement.java:993)
    at oracle.xml.parser.v2.XMLNode.reportChildSAXEvents(XMLNode.java:1014)
    at oracle.xml.parser.v2.XMLDocument.reportSAXEvents(XMLDocument.java:942)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:294)

    Hi,
    I'm having that problem to:
    I'm getting the following exception
    javax.xml.transform.TransformerException: XSL-1900: (Fatal Error) An internal error condition occurred.
         at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:723)
         at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:340)
         at com.ac.mqif.control.Handler.handleLong(Handler.java:835)
         at com.ac.mqif.control.Handler.run(Handler.java:951)
    Caused by: java.lang.NullPointerException
         at oracle.xml.parser.v2.XPathStep.getSelectedNodes(XPathStep.java:380)
         at oracle.xml.parser.v2.PathExpr.getValue(XSLNodeSetExpr.java:483)
         at oracle.xml.parser.v2.XSLExprBase.getStringValue(XSLExprBase.java:363)
         at oracle.xml.parser.v2.XSLValueOf.processAction(XSLValueOf.java:99)
         at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:367)
         at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:199)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:214)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:207)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:207)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:120)
         at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:367)
         at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:199)
         at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:471)
         at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:448)
         at oracle.xml.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:246)
         at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:327)
         ... 2 more
    when using a stylesheet which has a template match condition of more than 1600 characters.
    The second thing is that the Oracle XML transformer is
    NOT threadsafe. I was using several threads using different templates to transform an incoming XML simultaneously but was ALWAYS getting internal XSL errors
    and Nullpointer Exceptions. I solved this by synchronizing the transformation, but I don't like it.
    I'm using the following versions on Windows XP:
    Oracle IDE: 9.0.3.10.35
    Business Components Version: 9.0.3.10.7
    SCM Support Version: 9.0.3.9.4
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
    Thanx,
    Ellcrys

  • XML : Transform DOM Tree to XML String in an applet since the JRE 1.4.2_05

    Hello,
    I build a DOM tree in my applet.
    Then I transform it to XML String.
    But since the JRE 1.4.2_05 it doesn't work.
    These lines failed because these variables became final:
    org.apache.xalan.serialize.CharInfo.XML_ENTITIES_RESOURCE = getClass().getResource("XMLEntities.res").toString();
    org.apache.xalan.processor.TransformerFactoryImpl.XSLT_PROPERTIES = getClass().getResource("XSLTInfo.properties").toString();The rest of the code :
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    Document domXML = builder.newDocument();
    // I build my DOM Tree
    StringWriter xmlResult = new StringWriter();
    Source source = new DOMSource(domXML);
    Result result = new StreamResult(xmlResult);
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT,"yes");
    xformer.transform(source,result);Is there any other way to get an XML String from a DOM tree in an applet ?
    I'm so disappointed to note this big problem.

    Does anyone have an idea why I get this error message when try to use transform in an applet?
    Thanks...
    java.lang.ExceptionInInitializerError
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at org.apache.xalan.serialize.SerializerFactory.getSerializer(Unknown Source)
         at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(Unknown Source)
         at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Unknown Source)
         at matrix.CreateMtrx.SaveDoc(CreateMtrx.java:434)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at thinlet.Thinlet.invokeImpl(Unknown Source)
         at thinlet.Thinlet.invoke(Unknown Source)
         at thinlet.Thinlet.handleMouseEvent(Unknown Source)
         at thinlet.Thinlet.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.RuntimeException: The resource [ XMLEntities.res ] could not load: java.net.MalformedURLException: no protocol: XMLEntities.res
    XMLEntities.res      java.net.MalformedURLException: no protocol: XMLEntities.res
         at org.apache.xalan.serialize.CharInfo.<init>(Unknown Source)
         at org.apache.xalan.serialize.SerializerToXML.<clinit>(Unknown Source)
         ... 28 more

  • Javax.xml.transform.TransformerException durin XSL Transformation in Java

    Hi,
    Below is my piece of code where i access a web service that returns a xml as a string. I apply a xsl tranformation on it and try to store the result as a string. I get this error message
    javax.xml.transform.TransformerException: Result object passed to ''{0}'' is invalid.
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(Unknown Source)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
         at NewService.main(NewService.java:52)My Code:
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.StringReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.rmi.RemoteException;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ServiceException;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    public class NewService {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              String endPoint = "http://localhost:8080/SampleDynamicWebProj/services/SampleClient";
              Service service = new Service();
              Call callOne;
              try {
                   callOne = (Call) service.createCall();
                   callOne.setTargetEndpointAddress(new URL(endPoint));
                   callOne.setOperationName(new QName("http://DefaultNamespace",
                             "getXMLString"));
                   String concated = (String) callOne.invoke(new Object[] { "s" });
                   InputStream xsltFile = new FileInputStream("xslpackage/empTran.xsl");
                   Source xmlSource = new StreamSource(new StringReader(concated));
                 Source xsltSource = new StreamSource(xsltFile);
                 TransformerFactory transFact =
                    TransformerFactory.newInstance();
                 Transformer trans = transFact.newTransformer(xsltSource);
                 Result result = new StreamResult();
                 trans.transform(xmlSource, result);
                 System.out.println(result.toString());
              } catch (ServiceException e) {
                   e.printStackTrace();
              } catch (MalformedURLException e) {
                   e.printStackTrace();
              } catch (RemoteException e) {
                   e.printStackTrace();
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (TransformerConfigurationException e) {
                   e.printStackTrace();
              } catch (TransformerException e) {
                   e.printStackTrace();
    }I get the transformed XML into a Result object, but when i do a toString() oon it, i get the above exception.
    any help wil be appreciated,
    Dilip

    Oh well, yes it was a typo in address tag...ok agreed that its a bad example, check this out then,
    i have a XML data that i convert to a html format using xsl transformation, now this converted html has to be shown in a html page(i use the out.write option).
    so my initial xml looks like this ::
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Results>
        <ColumnCount>6</ColumnCount>
        <Columns>
            <column>UID</column>
            <column>UserName</column>
            <column>Password</column>
            <column>LastName</column>
            <column>FirstName</column>
            <column>EmailAddress</column>
        </Columns>
        <Rows>
            <Row>
                <value>1</value>
                <value>userone</value>
                <value>password-1</value>
                <value>Anant</value>
                <value>Dilip</value>
                <value>[email protected]</value>
            </Row>
            <Row>
                <value>2</value>
                <value>usertwo</value>
                <value>password-2</value>
                <value>Palli</value>
                <value>Gilli</value>
                <value>[email protected]</value>
            </Row>
        </Rows>I apply XSL transformation on this to get a HTML which i will be writing into my output screen hoping that the user will see it in a tabular format!
    <[!CDATA["
    <?xml version="1.0" encoding="UTF-8"?>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">UID</th>
    <th align="left">UserName</th>
    <th align="left">Password</th>
    <th align="left">LastName</th>
    <th align="left">FirstName</th>
    <th align="left">EmailAddress</th>
    </tr>
    <tr>
    <td>1</td>
    <td>userone</td>
    <td>password-1</td>
    <td>Anant</td>
    <td>Dilip</td>
    <td>[email protected]</td>
    </tr>
    <tr>
    <td>2</td>
    <td>usertwo</td>
    <td>password-2</td>
    <td>Palli</td>
    <td>Gilli</td>
    <td>[email protected]</td>
    </tr>
    </table>
    "]]>The entire data is passed to a XML parser . I want the transformed xml data (which will be inside a <status></status> tag to be untouched by this parser. As you see i have put the transformed xml in a CDATA tag, but this aint helping me...
    need urgent help,
    Dilip

  • XSLT problem -- urgent

    Hi,
    We are porting our application from WLS5.1 to WLS6.0SP2. We
    use Apache's Xerces parser for XSLT processing. After starting the server while
    loading a page, I get the following error:
    javax.xml.transform.TransformerException
    at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1242)
    at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    java.lang.ArrayIndexOutOfBoundsException
    at org.apache.xalan.serialize.SerializerToXML.accum(SerializerToXML.java:1321)
    at org.apache.xalan.serialize.SerializerToXML.outputLineSep(SerializerToXML.java:195)
    at org.apache.xalan.serialize.SerializerToXML.indent(SerializerToXML.java:2241)
    at org.apache.xalan.serialize.SerializerToHTML.startElement(SerializerToHTML.java:559)
    at org.apache.xalan.transformer.QueuedStartElement.flush(QueuedStartElement.java:357)
    at org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandler.java:770)
    at org.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.java:279)
    at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:749)
    at org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:498)
    at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:193)
    at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2202)
    at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2085)
    at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1219)
    at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    Has anyone come across this problem and got the solution ?
    Regards,
    Ramkumar

    This is correct you can use different 3rd party parsers like crimson or xml4j , by
    configuring the xml registry .However using different versions of apache xerces and xalan
    other than those shipped can cause compatibility problems and is not supported.
    Look at the faq url for details.
    http//e-docs.bea.com/wls/docs61/faq/xml.html#740643
    It might be possible however to hack this and get it to work.
    yeshwant
    Simon Spruzen wrote :
    If at all possible, you should limit your versions of Xalan and Xerces to those
    shipped with WLS (in weblogic.jar and xmlx.jar). So your imports look something
    like:
    import org.w3c.dom.*;
    import weblogic.apache.*; // not org.apache.*
    It seems that different versions of Xalan and Xerces ship with different versions
    of the org.w3c.dom classes that can be incompatible. You also must also use compatible
    versions of Xalan and Xerces together, else all sorts of oddness starts.
    (I wish Jakarta would merge the Xalan and Xerces packages into one super-package
    and gave it a single name)
    If you use the stuff shipped with WLS6.0 and nothing else, everything works fine.
    You don't have to use the registry and JAXP if you don't want to, however it's
    a nice clean API, providing you agree on what versions of Xalan and Xerces you're
    on. I found using JAXP with mixed versions of Xalan/Xerces just made things more
    confusing!
    WLS6.1 upgrades Xalan and Xerces and drops xmlx.jar. Here's part of a reply from
    a support case I've raised in a related area that clears things up:
    [Helen - BEA Support - writes:]
    "Here is some information that I hope will clarify things a little more :-
    The packaging was intended to make sure that customers could use newer versions
    of xerces and xalan without causing problems for the built in parser.The org.apache
    classes are packaged in xmlx.jar whereas the weblogic.apache classes are packaged
    in weblogic.jar.
    Originally, we planned to rev the xmlx.jar version of Xerces more often than
    the built-in version in WLS. But it turned out that there were compatibility
    problems involving the Level 2 DOM classes (org.w3c.dom package), so in
    practice people couldn't easily plug in a different version of Xerces than
    the one included in weblogic.jar. This problem generally only affects
    customers desiring to plug in a different version of Xerces;
    Because of the compatibility issue, which is not easily solvable, we have
    decided not to support plugging in a different version of Xerces than the one
    shipped. Therefore, we have decided to axe xmlx.jar.
    Note that for 6.1 it is not possible to use a different version of xerces and
    xalan than what is shipped as per
    http//e-docs.bea.com/wls/docs61/faq/xml.html#740643"
    "Ram Kumar" <[email protected]> wrote:
    Hi Kenneth,
    Yes, it is already in my classpath before weblogic.jar.
    Do I need to use the XML Registry and JAXP API for this to work compulsorily
    Regards,
    Ramkumar
    "Kenneth Chenis" <[email protected]> wrote:
    Try putting your xerces.jar file in the classpath before the weblogic.jar
    .... that resolved some (not all) of the problems we had with the internal
    xerces/parser classes in the weblogic.jar file.
    hope this helps,
    Kenneth Chenis
    ComponenTree Inc.
    Data Code Inc.
    [email protected]
    978-521-5970
    "Ram Kumar" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    We are porting our application from WLS5.1 to WLS6.0SP2. We
    use Apache's Xerces parser for XSLT processing. After starting theserver
    while
    loading a page, I get the following error:
    javax.xml.transform.TransformerException
    atorg.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1242)
    atorg.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    java.lang.ArrayIndexOutOfBoundsException
    atorg.apache.xalan.serialize.SerializerToXML.accum(SerializerToXML.java:1321)
    atorg.apache.xalan.serialize.SerializerToXML.outputLineSep(SerializerToXML.jav
    a:195)
    atorg.apache.xalan.serialize.SerializerToXML.indent(SerializerToXML.java:2241)
    atorg.apache.xalan.serialize.SerializerToHTML.startElement(SerializerToHTML.ja
    va:559)
    atorg.apache.xalan.transformer.QueuedStartElement.flush(QueuedStartElement.jav
    a:357)
    atorg.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandle
    r.java:770)
    atorg.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.
    java:279)
    atorg.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:
    749)
    atorg.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.ja
    va:498)
    atorg.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
    a:193)
    atorg.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
    erImpl.java:2202)
    atorg.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transformer
    Impl.java:2085)
    atorg.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
    ava:1219)
    atorg.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2942)
    at java.lang.Thread.run(Thread.java:484)
    Has anyone come across this problem and got the solution ?
    Regards,
    Ramkumar

Maybe you are looking for