Parse XML input stream (no .xml file)?

i have a java applet calling a web service that returns XML data as an input stream (char by char from SOAP) to this applet. if i append a all the chars to a string, is there some XML tool that will parse the string as if it were an XML document (like a getElement functions)?
the applet cannot write the data to a .xml file, and i don't want to mess around with .jarsigning. any ideas?
thanks,
jonathan

The XML parsers you are likely to be using support receiving input from a variety of sources besides files. For example you could parse XML from a String variable by passing a StringReader wrapping that String to the parser. Check the documentation for more details.

Similar Messages

  • Saving an input stream as a file.

    Hi,
    Please can any one tell me how can i directly save an InputStream as a file. If it is not possible then plz tell me how can i make reading the InputStream and writing to the File using the FileOutputStream faster. Actually i am using the code below:-
    DataInputStream dataInputStream = new DataInputStream (urlConnection.getInputStream ());
    FileOutputStream downloadFileStream=new FileOutputStream("Myfile.txt");
    int data;
    while((data=dataInputStream.read())!=-1)
    downloadFileStream.write(data);
    This is reading the dataInputStream byte by byte and writing to the FileOutputStream byte by byte which is a very slow affair. My dataInputStream can be at max of 15MB. Plz help. And thanks for any of ur suggestions.

    Dude. You cannot increase your Internet connection's
    bandwidth by using clever Java. Sorry to break the
    news.True, but copying a stream byte-for-byte can indeed be slower (even on a fairly limited connection).
    Using a BufferedReader/BufferedWriter and/or reading into a byte-array instead is usually a fairly simple and effective way of speeding things up.

  • Input stream to pdf file generation in WDJ

    Hi Experts,
    I want to create a pdf file from some inputstream or string content in Webdynpro Java code.
    Can anyone please provide me some code snippet related to this.
    I tried below code:
    public class test {
         public static void main(String[] args) {
                   String strFilePath = "C://demo.pdf";
                   try {
                             FileOutputStream fos = new FileOutputStream(strFilePath);
                             String strContent =
                                       "Write File using Java FileOutputStream example !";
                             fos.write(strContent.getBytes());
                             fos.close();
                   } catch (FileNotFoundException ex) {
                             System.out.println("FileNotFoundException : " + ex);
                   } catch (IOException ioe) {
                             System.out.println("IOException : " + ioe);
    It is creating a pdf file in my local system but while opening the file it is saying "Corrupted file".-
    Any kind of help will be highly appreciated.
    Regards,
    Sambarn

    You have to use WDResource and related classes for reading/writing the files on portal app server.
    For getting some Idea, look at this wiki.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71?quicklink=index&overridelayout=true
    -Yugandhar Reddy

  • [IWAF JCA PeopleSoft] **** Error in parsing the input document.

    Hi,
    I configured Peoplesoft Adapter 10.1.3.1 with Oracle BPEL 10.1.3.1, I am able to invoke BPEL from Peoplesoft using JCA configurtaion. But I am not able to invoke Peoplesoft component interface from BPEL PM, Invoke call fails with following error. Did any one know solution to this issue.
    Thanks,
    Manish
    Tue, 6 Nov 2007 16:40:20.0954 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [info ] [IWAF JCA PeopleSoft] IWAFManagedConnection for PeopleSoft:Peoplesoft has listener registered: com.evermind.server.connector.ConnectionContext@b78555
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [info ] [IWAF JCA PeopleSoft] Local transaction not supported by underlying adapter.
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [info ] [IWAF JCA PeopleSoft] IWAFManagedConnection for PeopleSoft:Peoplesoft dispatch event 2
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [error] [IWAF JCA PeopleSoft] **** Error in parsing the input document.
    oracle.xml.parser.v2.XMLParseException: Start of root element expected.
         at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:320)
         at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:341)
         at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:303)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:205)
         at com.iwaysoftware.idom.XmlDocument.parse(XmlDocument.java:120)
         at com.iwaysoftware.idom.XmlDocument.setRootXML(XmlDocument.java:77)
         at com.ibi.afjca.cci.IWAFInteraction.execProcess(IWAFInteraction.java:195)
         at com.ibi.afjca.cci.IWAFInteraction.exec(IWAFInteraction.java:136)
         at com.ibi.afjca.cci.IWAFInteraction.execute(IWAFInteraction.java:93)
         at oracle.tip.adapter.fw.wsif.jca.WSIFOperation_JCA.executeRequestResponseOperation(WSIFOperation_JCA.java:470)
         at com.collaxa.cube.ws.WSIFInvocationHandler.invoke(WSIFInvocationHandler.java:431)
         at com.collaxa.cube.ws.WSInvocationManager.invoke2(WSInvocationManager.java:416)
         at com.collaxa.cube.ws.WSInvocationManager.invoke(WSInvocationManager.java:222)
         at com.collaxa.cube.engine.ext.wmp.BPELInvokeWMP.__invoke(BPELInvokeWMP.java:736)
         at com.collaxa.cube.engine.ext.wmp.BPELInvokeWMP.__executeStatements(BPELInvokeWMP.java:371)
         at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:195)
         at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3271)
         at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1697)
         at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:184)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:269)
         at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5244)
         at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:1083)
         at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.createAndInvoke(CubeEngineBean.java:132)
         at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.syncCreateAndInvoke(CubeEngineBean.java:161)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:31)
         at com.evermind.server.ThreadState.runAs(ThreadState.java:620)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:34)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.TxRequiresNewInterceptor.invoke(TxRequiresNewInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
         at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)
         at CubeEngineBean_LocalProxy_4bin6i8.syncCreateAndInvoke(Unknown Source)
         at com.collaxa.cube.engine.delivery.DeliveryHandler.initialRequestAnyType(DeliveryHandler.java:499)
         at com.collaxa.cube.engine.delivery.DeliveryHandler.initialRequest(DeliveryHandler.java:451)
         at com.collaxa.cube.engine.delivery.DeliveryHandler.request(DeliveryHandler.java:125)
         at com.collaxa.cube.ejb.impl.DeliveryBean.request(DeliveryBean.java:95)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:31)
         at com.evermind.server.ThreadState.runAs(ThreadState.java:620)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:34)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
         at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)
         at DeliveryBean_RemoteProxy_4bin6i8.request(Unknown Source)
         at com.collaxa.cube.ws.soap.oc4j.SOAPRequestProvider.processNormalOperation(SOAPRequestProvider.java:455)
         at com.collaxa.cube.ws.soap.oc4j.SOAPRequestProvider.processBPELMessage(SOAPRequestProvider.java:278)
         at com.collaxa.cube.ws.soap.oc4j.SOAPRequestProvider.processMessage(SOAPRequestProvider.java:129)
         at oracle.j2ee.ws.server.provider.ProviderProcessor.doEndpointProcessing(ProviderProcessor.java:869)
         at oracle.j2ee.ws.server.WebServiceProcessor.invokeEndpointImplementation(WebServiceProcessor.java:349)
         at oracle.j2ee.ws.server.provider.ProviderProcessor.doRequestProcessing(ProviderProcessor.java:460)
         at oracle.j2ee.ws.server.WebServiceProcessor.processRequest(WebServiceProcessor.java:114)
         at oracle.j2ee.ws.server.WebServiceProcessor.doService(WebServiceProcessor.java:96)
         at oracle.j2ee.ws.server.WebServiceServlet.doPost(WebServiceServlet.java:177)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.security.jazn.oc4j.JAZNFilter$1.run(JAZNFilter.java:396)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:410)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [error] [IWAF JCA PeopleSoft] SOS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [error] [IWAF JCA PeopleSoft] oracle.xml.parser.v2.XMLElement@1f73ac7
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [error] [IWAF JCA PeopleSoft] EOS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Tue, 6 Nov 2007 16:40:21.0204 IST - Thread[AJPRequestHandler-HTTPThreadGroup-56,5,HTTPThreadGroup] [info ] [IWAF JCA PeopleSoft] IWAFManagedConnection for PeopleSoft:Peoplesoft dispatch event 4

    Kris,
    I tried your suggestion, but it didn't help. I think the Ci jar file is getting loaded, because when I try to call any other interface whos class files are not included in CI jar file, it gives different error like "Not Authorized (90,6)Failed to execute PSSession request Cannot find Component Interface {LACATION_TABLE} (91,2)".
    We verified all the configuration on Adapter and Peoplesoft aerver, every thing seems to be absolutely fine, even I turned on debug log level for adapter but that is not of any use.
    I tried searching on the google, it seems many people who used Component Interface Java Classes faced such type of problem, they recommended some peoplesoft configuration, I tried their suggestions as well, but that also didn't work out.
    Even though we are using Peoplesoft 8.4 Adapter asks for pstools.properties file whenever the BPEL Process is invoked, this file is there in the adapters lib directory, and jca-app-adapter directory, see below the log.
    <2007-11-26 18:33:17,656> <INFO> <collaxa> <ServerManager::loadProcesses> Done loading processes for all domains
    <2007-11-26 18:35:13,296> <INFO> <default.collaxa.cube.ws> <AdapterFramework::Outbound> http://192.168.133.164:8888/orainfra/wsil/adapters/applications/CI_PERSONAL_DATA_invoke.wsdl?wsdl [ CI_PERSONAL_DATAPortType::CI_PERSONAL_DATA(input_CI_PERSONAL_DATA,output_CI_PERSONAL_DATA) ] - Using JCA Connection Pool - max size = <unbounded>
    <2007-11-26 18:35:13,312> <WARN> <default.collaxa.cube.ws> <AdapterFramework::Outbound> http://192.168.133.164:8888/orainfra/wsil/adapters/applications/CI_PERSONAL_DATA_invoke.wsdl?wsdl [ CI_PERSONAL_DATAPortType::CI_PERSONAL_DATA(input_CI_PERSONAL_DATA,output_CI_PERSONAL_DATA) ] - Unable to provide Log4j handle to com.ibi.afjca.cci.IWAFConnectionFactory via <public void setLog4jLogger(org.apache.log4j.Logger logger)> due to: com.ibi.afjca.cci.IWAFConnectionFactory.setLog4jLogger(org.apache.log4j.Logger)
    Mon, 26 Nov 2007 18:35:13.0312 IST - Thread[HTTPThreadGroup-59,5,HTTPThreadGroup] [debug] [IWAF JCA] IWAFConnectionFactory:getConnection called with ConnectionSpec:
    User :null
    Password :null
    AdapterName :PeopleSoft
    Config :PSOFT9
    Mon, 26 Nov 2007 18:35:13.0312 IST - Thread[HTTPThreadGroup-59,5,HTTPThreadGroup] [debug] [IWAF JCA] IWAFConnectionFactory:getConnection called with ConnectionSpec:
    User :null
    Password :null
    AdapterName :PeopleSoft
    Config :PSOFT9
    Mon, 26 Nov 2007 18:35:13.0312 IST - Thread[HTTPThreadGroup-59,5,HTTPThreadGroup] [debug] [IWAF JCA] IWAFManagedConnectionFactory:createManagedConnection() entered.
    Mon, 26 Nov 2007 18:35:13.0312 IST - Thread[HTTPThreadGroup-59,5,HTTPThreadGroup] [debug] [IWAF JCA] setLogWriter() gets called.
    07/11/26 18:35:14 PSProperties not loaded from file. Couldn't find file: pstools.properties
    07/11/26 18:35:18 PSProperties not loaded from file. Couldn't find file: pstools.properties
    07/11/26 18:39:12 PSProperties not loaded from file. Couldn't find file: pstools.properties
    07/11/26 18:51:38 PSProperties not loaded from file. Couldn't find file: pstools.properties
    Thanks,
    manish
    Message was edited by:
    user604262

  • Buffered Input stream that increases internal buffer dynamically

    I need to parse an input stream until I find a <META> tag with character encoding. I then need to reset to the beginning of the input stream and start parsing the stream again with the correct character encoding.
    BufferedInputStream provides mark() and reset() methods which can be used to accomplish this task. However, the input stream data can be 1MB size and the only way I can think of forcing the BufferedInputStream to hold that content size is by specifying the size during construction.
    I don't want to initialize the content size during construction of the BufferedStream for every data file I parse because some documents could have the tag in the beginning of the file and it could be waste of memory.
    Question: Is there already a class which allows to set the maximum buffer size and which grows gradually to that size rather than during construction.
    Thanks for any help.

    DrClap, I connect to a webserver and request a file. I just use the InputStream returned by the HttpResponse object to read the file. So, the answer to your question is I can't close and reopen the file.
    Jawahar

  • Parsing XML from Socket input stream

    I create a sax parser to which I send the InputStream from the socket
    But my HandlerBase never gets the events. I get startDocument
    but that is it, I never get any other event.
    The code I have works just like expected when I make the InputStream
    come from a file. The only differeence I see is that when I file is used the
    InputStream is fully consumed while with the socket the InputStream
    is kept open (I MUST KEEP THE SOCKET OPEN ALL THE TIME). If the parser
    does not generate the events unless the InputStream is fully consumed,
    isn't that against the whole idea of SAX (sax event driven) .
    Has anyone been succesfull parsing XML from the InputStream of a socket?
    if yes how?
    I am using JAXP 1.0.1 but I can upgrade to JAXP 1.1.0
    which uses SAX 2.0
    Does anybody know if my needs can be met by JAXP 1.1.0?
    Thanks

    I did the same with client/server model.
    I have client program with SAX parser. Please try if you can make the server side. I was be able to write the program with help from this forum. Please search to see if you can get the forum from which I got help for this program.
    // JAXP packages
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    // JAVA packages
    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class XMLSocketClient {
    final private static int buffSize = 1024*10;
    final private static int PORTNUM = 8888;
         final private static int threadSleepValue = 1000;
    private static void usage() {
    System.err.println("Usage: XMLSocketClient [-v] serverAddr");
    System.err.println(" -v = validation");
    System.exit(1);
    public static void main(String[] args) {
    String address = null;
    boolean validation = false;
    Socket socket = null;
    InputStreamReader isr_socket = null;
    BufferedReader br_socket = null;
    CharArrayReader car = null;
    BufferedReader br_car = null;
    char[] charBuff = new char[buffSize];
    int in_buff = 0;
    * Parse arguments of command options
    for (int i = 0; i < args.length; i++) {
    if (args.equals("-v")) {
    validation = true;
    } else {
    address = args[i];
    // Must be last arg
    if (i != args.length - 1) {
    usage();
    // Initialize the socket and streams
    try {
    socket = new Socket(address, PORTNUM);
    isr_socket = new InputStreamReader(socket.getInputStream());
    br_socket = new BufferedReader(isr_socket, buffSize);
    catch (IOException e) {
    System.err.println("Exception: couldn't create stream socket "
    + e.getMessage());
    System.exit(1);
    * Check whether the buffer has input.
    try {
    while (br_socket.ready() != true) {
                   try {
                        Thread.currentThread().sleep(threadSleepValue);     
                   catch (InterruptedException ie) {
              System.err.println("Interrupted error for sleep: "+ ie.getMessage());
                   System.exit(1);
    catch (IOException e) {
    System.err.println("I/O error for in.read(): "+ e.getMessage());
    System.exit(1);
    try {
    in_buff = br_socket.read(charBuff, 0, buffSize);
    System.out.println("in_buff = " + in_buff);
    System.out.println("charBuff length: " + charBuff.length);
    if (in_buff != -1) {
    System.out.println("End of file");
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    System.exit(1);
    System.out.println("reading XML file:");
    StringBuffer display = new StringBuffer();
    display.append(charBuff, 0, in_buff);
    System.out.println(display.toString());
    * Create BufferedReader from the charBuff
    * in order to put into XML parser.
    car = new CharArrayReader(charBuff, 0, in_buff); // these two lines have to be here.
    br_car = new BufferedReader(car);
    * Create a JAXP SAXParserFactory and configure it
    * This section is standard handling of XML document by SAX XML parser.
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setValidating(validation);
    XMLReader xmlReader = null;
    try {
    // Create a JAXP SAXParser
    SAXParser saxParser = spf.newSAXParser();
    // Get the encapsulated SAX XMLReader
    xmlReader = saxParser.getXMLReader();
    } catch (Exception ex) {
    System.err.println(ex);
    System.exit(1);
    // Set the ContentHandler of the XMLReader
    xmlReader.setContentHandler(new MyXMLHandler());
    // Set an ErrorHandler before parsing
    xmlReader.setErrorHandler(new MyErrorHandler(System.err));
    try {
    * Tell the XMLReader to parse the XML document
    xmlReader.parse(new InputSource(br_car));
    } catch (SAXException se) {
    System.err.println(se.getMessage());
    System.exit(1);
    } catch (IOException ioe) {
    System.err.println(ioe);
    System.exit(1);
    * Clearance of i/o functions after parsing.
    try {
    br_socket.close();
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    try {
    socket.close();
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    try {
    br_car.close();
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    * The XML handler used by this program
    class MyXMLHandler extends DefaultHandler {
    // A Hashtable with tag names as keys and Integers as values
    private Hashtable tags;
    // Parser calls this once at the beginning of a document
    public void startDocument() throws SAXException {
    System.out.println("startDocument()");
    tags = new Hashtable();
    // Parser calls this for each element in a document
    public void startElement(String namespaceURI, String localName,
    String rawName, Attributes atts)
    throws SAXException
    String key = localName;
    Object value = tags.get(key);
    System.out.println("startElement()");
    System.out.println("namespaceURI: " + namespaceURI);
    System.out.println("localName: " + localName);
    System.out.println("rawName: " + rawName);
    if (value == null) {
    // Add a new entry
    tags.put(key, new Integer(1));
    } else {
    // Get the current count and increment it
    int count = ((Integer)value).intValue();
    count++;
    tags.put(key, new Integer(count));
    // Parser calls this once after parsing a document
    public void endDocument() throws SAXException {
    Enumeration e = tags.keys();
    System.out.println("endDocument()");
    while (e.hasMoreElements()) {
    String tag = (String)e.nextElement();
    int count = ((Integer)tags.get(tag)).intValue();
    System.out.println("Tag <" + tag + "> occurs " + count
    + " times");
    * Error handler of XML parser to report errors and warnings
    * This is standard handling.
    class MyErrorHandler implements ErrorHandler {
    /** Error handler output goes here */
    private PrintStream out;
    MyErrorHandler(PrintStream out) {
    this.out = out;
    * Returns a string describing parse exception details
    private String getParseExceptionInfo(SAXParseException spe) {
    String systemId = spe.getSystemId();
    if (systemId == null) {
    systemId = "null";
    String info = "URI=" + systemId +
    " Line=" + spe.getLineNumber() +
    ": " + spe.getMessage();
    return info;
    * The following methods are standard SAX ErrorHandler methods.
    * See SAX documentation for more info.
    public void warning(SAXParseException spe) throws SAXException {
    out.println("Warning: " + getParseExceptionInfo(spe));
    public void error(SAXParseException spe) throws SAXException {
    String message = "Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    public void fatalError(SAXParseException spe) throws SAXException {
    String message = "Fatal Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);

  • Xml URL to an input stream

    Hi Guys,
    Would appreciate any help here. Basically my web application recieved XML from a URL, and transforming it straight from the URL was causing problems. So I've found a way around it but its too cpu intensive for my liking.
    I now convert the URL to a string, convert the string to a byte array, and then stream the byte array.
    So basically I'm asking, is there a better way of converting the URL to an input stream than my code below...
          URL source = null;
          SAXBuilder builder;
          org.jdom.Document doc;
          source = new URL(xslFile);
          builder = new SAXBuilder();
          doc = builder.build(source);
          String xslData = Xml.getRawString(doc);
          byte [] barrBt = xslData.getBytes();
          ByteArrayInputStream barrInputStream2 = new ByteArrayInputStream(barrBt);
          processor.process(xmlDomSource, 
                            new StreamSource(barrInputStream2),
                            _request,
                            _response,
                            _xslParameters,
                            thisSessionInfo);  

    Seems to me a better way to do it would be to solve the problems associated with parsing directly from the URL. They should be solvable since if your code can read from the URL then so can the parser.
    However if you want to save some processing time, don't convert the XML from bytes to String and then back to bytes again. (You also run the risk of damaging the XML because you may not be doing those conversions with the encoding declared in the XML, but that's a separate problem.)

  • XML-32009: (Fatal Error) Failed to parse the input schema.

    I am attempting to generate the Java classes for the attached XLM schema (JMdict_e.xsd) using the following command:
    oracle.xml.jaxb.orajaxb -schema JMdict_e.xsd -targetPkg generated
    which results in the error "XML-32009: (Fatal Error) Failed to parse the input schema."
    I created the schema from a DTD file (http://www.csse.monash.edu.au/~jwb/jmdict_dtd_h.html) following the instructions in the example http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28394/adx_j_sproc.htm#CIHICCJB
    I am using version xdk_nt_10_1_0_2_0_production.
    Can anyone help me with this please? Thanks.
    JMdict_e.xsd
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="dial" type="xs:string"/>
    <xs:element name="example" type="xs:string"/>
    <xs:element name="upd_date" type="xs:string"/>
    <xs:element name="ke_pri" type="xs:string"/>
    <xs:element name="re_nokanji" type="xs:string"/>
    <xs:element name="xref" type="xs:string"/>
    <xs:element name="etym" type="xs:string"/>
    <xs:element name="re_inf" type="xs:string"/>
    <xs:element name="k_ele">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="keb"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="ke_inf"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="ke_pri"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="links">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="link_tag"/>
    <xs:element ref="link_desc"/>
    <xs:element ref="link_uri"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="lsource">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base="xs:string">
    <xs:attribute name="lang" fixed="eng"/>
    <xs:attribute name="ls_type" use="optional" type="xs:string"/>
    <xs:attribute name="ls_wasei" use="optional" type="xs:string"/>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>
    <xs:element name="ent_seq" type="xs:string"/>
    <xs:element name="info">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="links"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="bibl"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="etym"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="audit"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="s_inf" type="xs:string"/>
    <xs:element name="link_uri" type="xs:string"/>
    <xs:element name="bib_txt" type="xs:string"/>
    <xs:element name="link_tag" type="xs:string"/>
    <xs:element name="bibl">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" ref="bib_tag"/>
    <xs:element minOccurs="0" ref="bib_txt"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="upd_detl" type="xs:string"/>
    <xs:element name="ant" type="xs:string"/>
    <xs:element name="ke_inf" type="xs:string"/>
    <xs:element name="audit">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="upd_date"/>
    <xs:element ref="upd_detl"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="pos" type="xs:string"/>
    <xs:element name="pri" type="xs:string"/>
    <xs:element name="r_ele">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="reb"/>
    <xs:element minOccurs="0" ref="re_nokanji"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="re_restr"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="re_inf"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="re_pri"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="bib_tag" type="xs:string"/>
    <xs:element name="re_restr" type="xs:string"/>
    <xs:element name="stagk" type="xs:string"/>
    <xs:element name="sense">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="stagk"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="stagr"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="pos"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="xref"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="ant"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="field"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="misc"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="s_inf"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="lsource"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="dial"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="gloss"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="example"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="keb" type="xs:string"/>
    <xs:element name="field" type="xs:string"/>
    <xs:element name="link_desc" type="xs:string"/>
    <xs:element name="reb" type="xs:string"/>
    <xs:element name="entry">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="ent_seq"/>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="k_ele"/>
    <xs:element maxOccurs="unbounded" ref="r_ele"/>
    <xs:element minOccurs="0" ref="info"/>
    <xs:element maxOccurs="unbounded" ref="sense"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="stagr" type="xs:string"/>
    <xs:element name="re_pri" type="xs:string"/>
    <xs:element name="gloss">
    <xs:complexType mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="pri"/>
    </xs:choice>
    <xs:attribute name="lang" fixed="eng"/>
    <xs:attribute name="g_gend" use="optional" type="xs:string"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="misc" type="xs:string"/>
    <xs:element name="JMdict">
    <xs:complexType>
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" ref="entry"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    @Bhaskar (and @user11922800): You have to update the db10g/xdk to a version at least of 10.1.0.4. There were major bug fixes including XML-32009 error (bug number 3375952).
    http://www.eygle.com/case/bug10104.htm
    I've even tried the op's listing with my more to-date xdk without encountering any problem and it is compiled just fine.
    ps: I am sure that was the hasty typo in dvohra16 post. The namespace in the op (/2001/) is correct. Encoding is still capable of resulting in some problems (I've had encounted if I recall), but that is not the problem for the issue raised in this thread.

  • In PI how do I convert the XML payload (input) to a text file and send out

    I am extracting data from SAP and sending thru XI / PI to a file (non-sap system).
    On the receiving end, I need the file to be a text file, with one row for each "FTZ_Row concatenated_data" tag in the input.  It needs to be just a plain text file with no XML tags.
    Currently the file gets one record which matches exactly to the XML payload below.
    I want it to create a file that looks like this :
               CONCATENATED DATA 1
               CONCATENATED DATA 2
                012345678912345678MAKTX-TEST LB 123123123123 01/02/2009 Z001WCHA9876543210.12
    here is the payload going thru XI
      <?xml version="1.0" encoding="utf-8" ?>
    - <n0:FTZ_Concatenated_Row xmlns:n0="http://intel.com/xi/INTEL_PROCUREMENT/ForeignTradeZone" xmlns:prx="urn:sap.com:proxy:FI0:/1SAI/TAS0C0412CDBC3E782D0219:700:2008/06/25">
      <FTZ_Row concatenated_data="CONCATENATED DATA 1" />
      <FTZ_Row concatenated_data="CONCATENATED DATA 2" />
      <FTZ_Row concatenated_data="012345678912345678MAKTX-TEST LB 123123123123 01/02/2009 Z001WCHA9876543210.12" />
      </n0:FTZ_Concatenated_Row>
    thanks
    jay

    thanks for the input but I am still having issues - I get an empty file when I use the content conversion option.
    My payload coming into XI is :
            <?xml version="1.0" encoding="utf-8" ?>
    - <n0:FTZ_Concatenated_Row xmlns:n0="http://intel.com/xi/INTEL_PROCUREMENT/ForeignTradeZone" xmlns:prx="urn:sap.com:proxy:FI0:/1SAI/TAS0C0412CDBC3E782D0219:700:2008/06/25">
    <FTZ_Row concatenated_data="CONCATENATED DATA 1" />
    <FTZ_Row concatenated_data="CONCATENATED DATA 2" />
    <FTZ_Row concatenated_data="012345678912345678MAKTX-TEST LB 123123123123 01/02/2009 Z001WCHA9876543210.12" />
    </n0:FTZ_Concatenated_Row>
    Here is the layout of my data type - I am using the same for input & output
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://intel.com/xi/INTEL_PROCUREMENT/ForeignTradeZone" targetNamespace="http://intel.com/xi/INTEL_PROCUREMENT/ForeignTradeZone">
       <xsd:complexType name="FTZ_Concatenated_Row">
          <xsd:sequence>
             <xsd:element name="FTZ_Row" maxOccurs="unbounded">
                <xsd:complexType>
                   <xsd:attribute name="concatenated_data" type="xsd:string" />
                </xsd:complexType>
             </xsd:element>
          </xsd:sequence>
       </xsd:complexType>
    </xsd:schema>
    I mapped these items :  FTZ_Concatenated_Row & FTZ_Row & concatenated_data
    I set up my content convesion with :
      recordset structure   FTZ_Row
    FTZ_Row.fieldSeparator     #
    FTZ_Row.endSeparator     'nl'
    I am not sure why the following row looks like this ??
        <FTZ_Row concatenated_data="CONCATENATED DATA 1" />
    I thought FTZ_Row would be one tag and "concatenated_data" would be another one.
    any help would be appreciated.
    I have read many entries/blogs/etc in SDN but and tried many different setups, but nothing is working.
    thanks

  • Unable to display tree view; Error when parsing an XML document (Premature end of file.)

    Hi folks,
    I am using a cascaded mapping in my OM. I have a graphical mapping followed by the Java mapping. It is a flat file to IDOC mapping. Everything works fine in Dev but when I transport the same objects to QA, the Operation mapping though it doesn't fail in ESR testing tool, gives the following message and there is no output generated for the same payload which is successfully tested in DEV. Please advise on what could be the possible reasons.
    Unable to display tree view; Error when parsing an XML document (Premature end of file.)

    kalyan,
    There seems to be an invalid xml payload which causes this error in ESR not generating the tree view. Please find the similar error screenshot and rectify the payload.
    Mutti

  • How can I parse an XML string, (not an XML file)?

    Hi,
    I am using Xerces2 Java Parser 2.4.0,
    I wanta parse an XML string, not an XML file, but
    in the Parser class there is only following methods:
    parse(InputSource source)
    parse(java.lang.String systemId)
    thanks

    hi
      InputSource is = new InputSource(new ByteArrayInputStream(xmlSrc.getBytes()));
      HTH
    vasanth-ct

  • How to merge five different xml input files into three output files

    Hi All,
    Can you please explain me to merge 5 different xml input files into 3 output xml files.
    I'm looking forward for ur suggestions...
    Thanks
    Pullarao

    HI
    Please see the below links
    /people/pooja.pandey/blog/2005/07/27/idocs-multiple-types-collection-in-bpm - Collection of IDoc to Single File
    http://help.sap.com/saphelp_nw04/helpdata/en/3c/831620a4f1044dba38b370f77835cc/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/62/dcef46dae42142911c8f14ca7a7c39/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/de/766840bf0cbf49e10000000a1550b0/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cb/15163ff8519a06e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/08/16163ff8519a06e10000000a114084/content.htm
    Many other examples can be found under the following link at help.sap.com
    http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
    And some weblogs
    https://weblogs.sdn.sap.com/pub/wlg/1403 [original link is broken] [original link is broken] [original link is broken]
    /people/siva.maranani/blog/2005/05/22/schedule-your-bpm *****
    /people/krishna.moorthyp/blog/2005/06/09/walkthrough-with-bpm
    /people/michal.krawczyk2/blog/2005/06/11/xi-how-to-retrieve-messageid-from-a-bpm
    /people/arpit.seth/blog/2005/06/27/rfc-scenario-using-bpm--starter-kit
    /people/sravya.talanki2/blog/2005/08/24/do-you-like-to-understand-147correlation148-in-xi
    /people/michal.krawczyk2/blog/2005/09/04/xi-do-you-realy-enjoy-clicking-and-waiting-while-tracing-bpm-steps *****
    /people/udo.martens/blog/2005/09/30/one-logical-system-name-for-serveral-bpm-acknowledgements *****
    /people/sudharshan.aravamudan/blog/2005/12/01/illustration-of-multi-mapping-and-message-split-using-bpm-in-sap-exchange-infrastructure
    /people/kannan.kailas/blog/2005/12/07/posting-multiple-idocs-with-acknowledgement
    Also have a look at these seminars,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/daea5871-0701-0010-12aa-c3a0c6d54e02
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/media/uuid/e8515171-0701-0010-be98-e37bec4706cc
    <b>BPM CollectPattern..</b>
    http://help.sap.com/saphelp_nw2004s/helpdata/en/08/16163ff8519a06e10000000a114084/frameset.htm
    Thanks !
    Regards
    Abhishek Agrahari
    Questions are welcome here!!
    <b>Also mark helpful answers by rewarding points </b>

  • How to get and parse xml input parameter?

    Hi,
    If one transaction input parameter is xml string, like as below.
    <a>
    <b>
        <c>1</c>
        <d>2</d>
    </b>
    <b>
        <c>3</c>
        <d>4</d>
    </b>   
    </a>
    If I would like to get each element (maybe by repeater action), how to do that?
    Thanks!

    Hi,
    You must convert the string into xml with necessary action block. (XML Functions --> String to XML Parser)
    Then you must put a repeater after converter action and you must set Xpath expression for repeater (configuration) like below:
    String_To_XML_Parser_0.Output{/ARef/BRef}
    after repeater you can use values like below:
    Repeater.Output{/BRef/c}
    Repeater.Output{/BRef/d}
    Regards.

  • How to retain prolog in output xml after parse the input xml

    Hi,
    I am using com.bea.xml.XmlObject.Factory.parse(String) method to parse a xml.
    Input XML is having prolog defore the root node.But after parse the xml using the above method, the prolog is not there in the Output XML.
    can any one help me to retain the prolog in Output XML as it is in Input XML......
    Thanks in advance..
    Regards,
    Deba

    Hi,
    The Input XML is like
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <SOAP-ENV:Body>
         </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    But after parse the Output XML become
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <SOAP-ENV:Body>
         </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    But due to project requirement i want to keep the prolog(<?xml version="1.0" encoding="UTF-8"?>) as it is with Output XML after parse the xml.
    can i use any XMLOption while calling parse() method...Or any one have any otherway to retain prolog after parse ?
    please help me to get it .
    Thanks in advance.
    Regards,
    Deba

  • XML parsing error: not well formed Location:file///c:users/

    I have been trying to download tax info from the I.R.S site. When I try to open the downloads I get this error message:
    XML parsing error: not well formed
    Location: file///c:/Users/John/Downloads/available Transcripts.xhtml
    line number 1, Column 9

    Are you sure that this is an XML file and not some other file type like PDF that got saved with the wrong file extension?
    You can try to rename the file and change the file extension to .pdf to see if that works.

Maybe you are looking for

  • LeaveRequest Work Items are not shows in SBWP TCODE workplace under outbox

    Hi Friends I used work flow 12300111 for leave request process and I activated that work flow. I applied leave through ESS from portal(Employee login)employee sends a leave request sends good, and I got Leave request(work items) Managers in box(uwl i

  • IMac 17 won't load discs

    Hello. Just noticed a bug with my 2-year old iMac 17. It won't load DVDs or data CDs. It just makes noise and then spits them out. Music CDs work, however. Tried a few of the tricks suggested here on this board but to no avail. I don't use the drive

  • Video Controller not found, Code 28.

    I've googled everything and all it throws back at me is to click 'Update driver'. I've done that and the automatic search can't find it. I don't know what's causing this because it was fine yesterday!

  • Mpd won't start after recent upgrade

    Hi! After one of the last upgrades my mpd service does not start anymore. ● mpd.service - Music Player Daemon Loaded: loaded (/usr/lib/systemd/system/mpd.service; enabled) Active: failed (Result: exit-code) since Di 2014-09-30 10:21:04 CEST; 2s ago P

  • Websites don't look the way they are supposed to

    Greetings friends,      Here's my issue. Off late (for more than a month or so) I have noticed that a lot of websites that I have visited in the past stop loading after a certain period of interaction with them. For instance if I go to theverge.com a