Java Http Listener to parse incoming XML

Hey folks,
I have a task where I need to create a secure http listener, which will then parse an incoming XML. Parsing an XML document seems pretty straight forward so no problems there.
basically what I would like to know is how would I get started? Would I use a servlet? Im not familiar enough with the capabilities of Java to know what packages to use and whatnot. How would some of you go about designing such a system?
Thanks in advance,
Ken

Yes, you can write a Servlet which does that.

Similar Messages

  • UTFDataFormatException when parsing incoming XML

    Hi,
    I am constantly seeing this message bellow when upgrade OCEP from 11.1.1.2 to 11.1.1.3 when parsing the XML from inbound JMSAdapter . Anyone knows the problem and how to fix it?
    patcherException: java.rmi.UnmarshalException: failed to unmarshal response; nested exception is:
    java.io.UTFDataFormatException
    weblogic.jms.common.JMSException: weblogic.messaging.dispatcher.DispatcherException: java.rmi.UnmarshalException: failed
    to unmarshal response; nested exception is:
    java.io.UTFDataFormatException
    at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:116)
    at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)
    at weblogic.jms.client.JMSSession.receiveMessage(JMSSession.java:894)
    at weblogic.jms.client.JMSConsumer.receiveInternal(JMSConsumer.java:647)
    at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:526)
    at weblogic.jms.client.WLConsumerImpl.receive(WLConsumerImpl.java:184)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessag
    eListenerContainer.java:405)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingM
    essageListenerContainer.java:309)
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMes
    sageListenerContainer.java:261)
    at com.bea.core.asyncbeans.internal.DefaultMessageListenerContainer.receiveAndExecute(DefaultMessageListenerCont
    ainer.java:59)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(D
    efaultMessageListenerContainer.java:983)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLo
    op(DefaultMessageListenerContainer.java:974)
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessa
    geListenerContainer.java:876)
    at com.bea.core.asyncbeans.internal.WorkManagerTaskExecutor$1.run(WorkManagerTaskExecutor.java:39)
    at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Thanks,
    Brandon

    I also got the same exception:
    I am trying to access the JMS queue from CEP application and the JMS queue are configured and populated by the OBS server.
    OSB server Version : 11g R1
    Weblogic version : 10.3.3
    CEP server Version : 11.1.1.3
    Also I disable the DMS option in both CEP and OSB server.
    In CEP Server:
    I disable DMS option in ‘startwlevs.cmd’ file in CEP domain folder as shown below.
    "%JAVA_HOME%\bin\java" %JVM_ARGS% %DGC% %DEBUG% -Doracle.dms.context=OFF
    -Dwlevs.home="%USER_INSTALL_DIR%" -Dbea.home="%BEA_HOME%" -jar
    "%USER_INSTALL_DIR%\bin\wlevs.jar" %1 %2 %3 %4 %5 %6
    :finish
    In OSB Server:
    OSB11g WLS Path : C:\Oracle11g\user_projects\domains\base_domain\bin
    File Name : startWebLogic.cmd
    if "%WLS_REDIRECT_LOG%"=="" (
    echo Starting WLS with line:
    echo %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Doracle.dms.context=OFF -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
    ) else (
    echo Redirecting output from WLS window to %WLS_REDIRECT_LOG%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Doracle.dms.context=OFF -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS% >"%WLS_REDIRECT_LOG%" 2>&1
    Please share your suggestion

  • MissingResourceException: Error parsing jdbcdrivers.xml

    java.io.IOException: Unable to resolve input source.
    Error: writeDomain() failed. Do dumpStack() to see details.
    Problem invoking WLST - Traceback (innermost last):
    File "D:\release\7420WLS\SCPO\weblogic\config\weblogic\setup\createManuWLSDomain.py", line 222, in ?
    File "C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py", line 70, in writeDomain
    com.bea.plateng.domain.script.jython.WLSTException: java.util.MissingResourceException: Error parsing jdbcdrivers.xml
    at com.bea.plateng.domain.script.jython.CommandExceptionHandler.handleException(CommandExceptionHandler.java:51)
    at com.bea.plateng.domain.script.jython.WLScriptContext.handleException(WLScriptContext.java:1373)
    at com.bea.plateng.domain.script.jython.WLScriptContext.writeDomain(WLScriptContext.java:712)
    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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
    at org.python.core.PyMethod.__call__(PyMethod.java:96)
    at org.python.core.PyObject.__call__(PyObject.java:270)
    at org.python.core.PyInstance.invoke(PyInstance.java:261)
    at org.python.pycode._pyx5.writeDomain$14(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py:70)
    at org.python.pycode._pyx5.call_function(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyTableCode.call(PyTableCode.java:267)
    at org.python.core.PyFunction.__call__(PyFunction.java:172)
    at org.python.pycode._pyx18.f$0(D:\release\7420WLS\SCPO\weblogic\config\weblogic\setup\createManuWLSDomain.py:222)
    at org.python.pycode._pyx18.call_function(D:\release\7420WLS\SCPO\weblogic\config\weblogic\setup\createManuWLSDomain.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyCode.call(PyCode.java:14)
    at org.python.core.Py.runCode(Py.java:1135)
    at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:167)
    at weblogic.management.scripting.WLST.main(WLST.java:106)
    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 weblogic.WLST.main(WLST.java:29)
    Caused by: java.util.MissingResourceException: Error parsing jdbcdrivers.xml
    at com.bea.plateng.domain.jdbc.JDBCAspectHelper.getGenericJDBCDriverInfo(JDBCAspectHelper.java:850)
    at com.bea.plateng.domain.jdbc.JDBCAspectHelper.getGenericJDBCDriverInfo(JDBCAspectHelper.java:223)
    at com.bea.plateng.domain.aspect.XBeanJDBCConnectionPoolDriverNameConfigAspect.decompose(XBeanJDBCConnectionPoolDriverNameConfigAspect.java:56)
    at com.bea.plateng.domain.aspect.AbstractConfigAspect.setDelegate(AbstractConfigAspect.java:550)
    at com.bea.plateng.domain.aspect.FilteredConfigAspect.setDelegate(FilteredConfigAspect.java:333)
    at com.bea.plateng.domain.aspect.XBeanConfigAspectBuilder.createJDBCConnectionPoolSimpleAspect(XBeanConfigAspectBuilder.java:300)
    at com.bea.plateng.domain.aspect.AbstractConfigAspectBuilder.createJDBCConnectionPoolSimpleAspects(AbstractConfigAspectBuilder.java:288)
    at com.bea.plateng.domain.operation.config.ConfigJDBCConnectionPool.createInitialSimpleAspects(ConfigJDBCConnectionPool.java:115)
    at com.bea.plateng.domain.operation.HTableEditOperation.createSimpleTableModel(HTableEditOperation.java:784)
    at com.bea.plateng.domain.operation.HTableEditOperation.getSimpleTableModel(HTableEditOperation.java:348)
    at com.bea.plateng.domain.operation.HTableEditOperation.initSimpleTableModel(HTableEditOperation.java:654)
    at com.bea.plateng.domain.DomainChecker.isOperationValid(DomainChecker.java:726)
    at com.bea.plateng.domain.DomainChecker.getInvalidSection(DomainChecker.java:168)
    at com.bea.plateng.domain.GeneratorHelper.validateConfig(GeneratorHelper.java:257)
    at com.bea.plateng.domain.GeneratorHelper.validateDomainCreation(GeneratorHelper.java:235)
    at com.bea.plateng.domain.script.ScriptExecutor.writeDomain(ScriptExecutor.java:580)
    at com.bea.plateng.domain.script.jython.WLScriptContext.writeDomain(WLScriptContext.java:704)
    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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
    at org.python.core.PyMethod.__call__(PyMethod.java:96)
    at org.python.core.PyObject.__call__(PyObject.java:270)
    at org.python.core.PyInstance.invoke(PyInstance.java:261)
    at org.python.pycode._pyx5.writeDomain$14(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py:70)
    at org.python.pycode._pyx5.call_function(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyTableCode.call(PyTableCode.java:267)
    at org.python.core.PyFunction.__call__(PyFunction.java:172)
    com.bea.plateng.domain.script.jython.WLSTException: com.bea.plateng.domain.script.jython.WLSTException: java.util.MissingResourceException: Error parsing jdbcdrivers.xml
    The system cannot find the path specified.
    0 file(s) copied.
    Attempting to shutdown server ...
    Checking JSP Precompilation ...
    Thanks

    java.io.IOException: Unable to resolve input source.
    Error: writeDomain() failed. Do dumpStack() to see details.
    Problem invoking WLST - Traceback (innermost last):
    File "D:\release\7420WLS\SCPO\weblogic\config\weblogic\setup\createManuWLSDomain.py", line 222, in ?
    File "C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py", line 70, in writeDomain
    com.bea.plateng.domain.script.jython.WLSTException: java.util.MissingResourceException: Error parsing jdbcdrivers.xml
    at com.bea.plateng.domain.script.jython.CommandExceptionHandler.handleException(CommandExceptionHandler.java:51)
    at com.bea.plateng.domain.script.jython.WLScriptContext.handleException(WLScriptContext.java:1373)
    at com.bea.plateng.domain.script.jython.WLScriptContext.writeDomain(WLScriptContext.java:712)
    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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
    at org.python.core.PyMethod.__call__(PyMethod.java:96)
    at org.python.core.PyObject.__call__(PyObject.java:270)
    at org.python.core.PyInstance.invoke(PyInstance.java:261)
    at org.python.pycode._pyx5.writeDomain$14(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py:70)
    at org.python.pycode._pyx5.call_function(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyTableCode.call(PyTableCode.java:267)
    at org.python.core.PyFunction.__call__(PyFunction.java:172)
    at org.python.pycode._pyx18.f$0(D:\release\7420WLS\SCPO\weblogic\config\weblogic\setup\createManuWLSDomain.py:222)
    at org.python.pycode._pyx18.call_function(D:\release\7420WLS\SCPO\weblogic\config\weblogic\setup\createManuWLSDomain.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyCode.call(PyCode.java:14)
    at org.python.core.Py.runCode(Py.java:1135)
    at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:167)
    at weblogic.management.scripting.WLST.main(WLST.java:106)
    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 weblogic.WLST.main(WLST.java:29)
    Caused by: java.util.MissingResourceException: Error parsing jdbcdrivers.xml
    at com.bea.plateng.domain.jdbc.JDBCAspectHelper.getGenericJDBCDriverInfo(JDBCAspectHelper.java:850)
    at com.bea.plateng.domain.jdbc.JDBCAspectHelper.getGenericJDBCDriverInfo(JDBCAspectHelper.java:223)
    at com.bea.plateng.domain.aspect.XBeanJDBCConnectionPoolDriverNameConfigAspect.decompose(XBeanJDBCConnectionPoolDriverNameConfigAspect.java:56)
    at com.bea.plateng.domain.aspect.AbstractConfigAspect.setDelegate(AbstractConfigAspect.java:550)
    at com.bea.plateng.domain.aspect.FilteredConfigAspect.setDelegate(FilteredConfigAspect.java:333)
    at com.bea.plateng.domain.aspect.XBeanConfigAspectBuilder.createJDBCConnectionPoolSimpleAspect(XBeanConfigAspectBuilder.java:300)
    at com.bea.plateng.domain.aspect.AbstractConfigAspectBuilder.createJDBCConnectionPoolSimpleAspects(AbstractConfigAspectBuilder.java:288)
    at com.bea.plateng.domain.operation.config.ConfigJDBCConnectionPool.createInitialSimpleAspects(ConfigJDBCConnectionPool.java:115)
    at com.bea.plateng.domain.operation.HTableEditOperation.createSimpleTableModel(HTableEditOperation.java:784)
    at com.bea.plateng.domain.operation.HTableEditOperation.getSimpleTableModel(HTableEditOperation.java:348)
    at com.bea.plateng.domain.operation.HTableEditOperation.initSimpleTableModel(HTableEditOperation.java:654)
    at com.bea.plateng.domain.DomainChecker.isOperationValid(DomainChecker.java:726)
    at com.bea.plateng.domain.DomainChecker.getInvalidSection(DomainChecker.java:168)
    at com.bea.plateng.domain.GeneratorHelper.validateConfig(GeneratorHelper.java:257)
    at com.bea.plateng.domain.GeneratorHelper.validateDomainCreation(GeneratorHelper.java:235)
    at com.bea.plateng.domain.script.ScriptExecutor.writeDomain(ScriptExecutor.java:580)
    at com.bea.plateng.domain.script.jython.WLScriptContext.writeDomain(WLScriptContext.java:704)
    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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:160)
    at org.python.core.PyMethod.__call__(PyMethod.java:96)
    at org.python.core.PyObject.__call__(PyObject.java:270)
    at org.python.core.PyInstance.invoke(PyInstance.java:261)
    at org.python.pycode._pyx5.writeDomain$14(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py:70)
    at org.python.pycode._pyx5.call_function(C:\Documents and Settings\j1007353\Local Settings\Temp\WLSTOfflineIni2466.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:208)
    at org.python.core.PyTableCode.call(PyTableCode.java:267)
    at org.python.core.PyFunction.__call__(PyFunction.java:172)
    com.bea.plateng.domain.script.jython.WLSTException: com.bea.plateng.domain.script.jython.WLSTException: java.util.MissingResourceException: Error parsing jdbcdrivers.xml
    The system cannot find the path specified.
    0 file(s) copied.
    Attempting to shutdown server ...
    Checking JSP Precompilation ...
    Thanks

  • Parsing an XML using DOM parser in Java in Recursive fashion

    I need to parse an XML using DOM parser in Java. New tags can be added to the XML in future. Code should be written in such a way that even with new tags added there should not be any code change. I felt that parsing the XML recursively can solve this problem. Can any one please share sample Java code that parses XML recursively. Thanks in Advance.

    Actually, if you are planning to use DOM then you will be doing that task after you parse the data. But anyway, have you read any tutorials or books about how to process XML in Java? If not, my suggestion would be to start by doing that. You cannot learn that by fishing on forums. Try this one for example:
    http://www.cafeconleche.org/books/xmljava/chapters/index.html

  • PLEASE : JAVA PARSER SCHEMA XML doesn't work

    Hi,
    I search how can I parse a xml document with schema, which works with Sun'SAX in JAVA.
    I have no real idea to it, but I think that JAXP can work (is it a good idea?)
    I have found this exemple :
    http://dataml.net/articles/ValidateXMLSchema/part1.htm
    This example is often posted in the forum, but for me it doesn't work, and you? have you had a probleme with it?
    Have you others examples which work or tutorials for parse xml with schema with SAX in java?
    Furthermore what are the specifics recommandations to install JAXP ?
    Thanks a lots.

    Nobody can help me?
    please

  • Java stored proc performance parsing XML docs

    Hi
    We are using ORACLE 8i(8.1.6). I have a JAVA Stored procedure that parses XML doc and returns tha values. If I am testing on the box, I get an avg. return time of 2 secs. If I have 20 users, my return time for all went to 25 to 35 secs?
    Are there any parameters on ORACLE I can modify to increase the performance. We are developing app for 1000 to 1500 users. I dont want to guess the time based on my test with 20 users.
    Any help will be greatly appreciated.
    Thank You
    Raju

    Raju,
    Oracle 8.1.7 should be better choice for you since it does have the XML stuff
    natively compiled.
    Regarding scaleability the JVM should scale
    very well. However let us know what you find.
    - Stefan

  • How to parse whole xml elements into a java String

    hello everybody,
    I am trying to parse whole xml into a string for example
    my xml file is as below:
    <root>
        <element>
           <data id="1">1</data>
        </element>
        <element>
           <data id="2">2</data>
        </element>
    </root>
    in java whole data should be transfered as
    String xmlString ="<root><element><data id=\"1\">1</data></element><element><data id=\"2\">2</data></element></root>";or in a simple way can xml be copied into a string? any assistance ...
    thanQ in Advance.
    Han.

    This code is to convert xml document to a string.
                             try {
                                  javax.xml.transform.TransformerFactory tfactory = TransformerFactory.newInstance();
                                  javax.xml.transform.Transformer xform = tfactory.newTransformer();
                                  javax.xml.transform.Source src = new DOMSource(xmlString);
                                  java.io.StringWriter writer = new StringWriter();
                                  StreamResult result = new javax.xml.transform.stream.StreamResult(writer);
                                  xform.transform(src, result);
                                  //System.out.println(writer.toString());          
                             } catch (TransformerConfigurationException e) {
                                  e.printStackTrace();
                             }catch(Exception ex )
                                  ex.printStackTrace();
                             }

  • How to Parse an XML file using SAXParser in java.

    Hi all
    Am a bit new to XML files and have no idea about SAXParsers ... Now my problem is to parse this XML file below
    <?xml version="1.0" encoding="UTF-8"?>
    <sc:memory_segmentation xmlns:sc="sc_memory_segmentation.xsd">
       <sc:architecture name="MPC55xx"></sc:architecture>
       <sc:derivative name=""></sc:derivative>
       <sc:configuration name=""></sc:configuration>
       <sc:memory name="Internal ROM" type="ROM">
          <sc:area-list>
             <sc:area name="Bootmanager" type="BOOTMANAGER">
                 <sc:segment-list>
                   <sc:segment name="ROM page 1">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                 </sc:segment-list>
             </sc:area>
             <sc:area name="Bootloader SWE" type="BOOTLOADER">
                 <sc:segment-list>
                   <sc:segment name="ROM page 2">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 3">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 1" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 4">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 5">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 6">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="ROM page 7">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 2" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 8">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 3" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 9">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
             <sc:area name="Application SWE 4" type="APPLICATION">
                <sc:segment-list>
                   <sc:segment name="ROM page 10">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
          </sc:area-list>
       </sc:memory>
       <sc:memory name="Internal RAM" type="RAM">
          <sc:area-list>
             <sc:area name="RAM" type="RAM">
                <sc:segment-list>
                   <sc:segment name="RAM page 1">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 2">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 3">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 4">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="RAM page 5">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
          </sc:area-list>
       </sc:memory>
       <sc:memory name="Internal EEPROM" type="EEPROM">
          <sc:area-list>
             <sc:area name="EEPROM" type="EEPROM">
                <sc:segment-list>
                   <sc:segment name="EEPROM page 1">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 2">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 3">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 4">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                   <sc:segment name="EEPROM page 5">
                      <sc:start></sc:start>
                      <sc:end></sc:end>
                   </sc:segment>
                </sc:segment-list>
             </sc:area>
          </sc:area-list>
       </sc:memory>
    </sc:memory_segmentation> And from this file I need to make 3 Hashtables out of it one for ROM , RAM and EEPROM containg Segment information i.e. Segment start and end addresses and Area type of the segment....
    If anyone could at least guide me with the basic commands and structure of the parser it would be really really great ...
    Thanks a lot
    Anisha

    Normally if you have no idea about X, the first thing you should do is google "X tutorial". You will find plenty of them out there. And the advantage is, they are better written than whatever we spend two minutes throwing together here. Not to mention that it saves us the two minutes.
    But if you have specific questions with your SAX parser when you get it going, then ask them here. Actually, ask them in the XML forum here, not this one.

  • Ignore DTD declaration in incoming XML message

    Hi,
    I have an issue where I am receiving an incoming XML message which starts with a DTD declaration.
    This causes an issue with the XML parser step in the mapping because the parser attempts to resolve the DTD location. However this location is external and the PI server cannot access it.
    The location for reference is http://dtd.bibit.com/paymentService_v1.dtd
    Therefore I am investigating options to ignore the DTD declaration or removing it altogether prior to the XML parser step.
    I would hope I could use either XSLT or Java mapping but do not really know where to start.
    Can anyone please provide a method of doing this ? I would prefer to use XSLT but am open to other options.
    I have no control over the DTD declaration as it is supplied by a 3rd party application. 
    Thanks
    Colin.

    Hi Russell,
    The XSLT sample you have provided does not work.
    I still get the message below in the trace file:
    <Trace level="2" type="T">Call XSLT processor with stylsheet BIBIT_PaymentResponse.xsl.</Trace>
      <Trace level="2" type="T">resolveEntity systemId = 'http://dtd.bibit.com/paymentService_v1.dtd' (publicId = '-//Bibit//DTD Bibit PaymentService v1//EN').</Trace>
      <Trace level="3" type="T">Search http://dtd.bibit.com/paymentService_v1.dtd (urn:com-dg-ng:crm:paycardauth, -1) in swcv 703fadc0-858c-11dd-971b-f2400a20801e.</Trace>
      <Trace level="3" type="T">Search http://dtd.bibit.com/paymentService_v1.dtd (-1) in swcv 703fadc0-858c-11dd-971b-f2400a20801e without namespace.</Trace>
      <Trace level="1" type="T">Resource not found: http://dtd.bibit.com/paymentService_v1.dtd Thrown: com.sap.aii.ib.server.mapping.execution.MappingClassNotFoundException: http://dtd.bibit.com/paymentService_v1.dtd at com.sap.aii.ib.server.mapping.execution.InternalMappingFinder.getInputStream(InternalMappingFinder.java:119) at com.sap.aii.ib.server.mapping.execution.InternalMappingFinder.readFile(InternalMappingFinder.java:62) at com.sap.aii.ib.server.mapping.execution.MappingLoader.getResourceAsStream(MappingLoader.java:131) at com.sap.aii.ib.server.mapping.execution.AbstractMappingTransformer$MappingEntityResolver.resolveEntity(AbstractMappingTransformer.java:328) at com.sap.engine.lib.xml.parser.XMLParser.scanDTD(XMLParser.java:1272) at com.sap.engine.lib.xml.parser.XMLParser.scanProlog(XMLParser.java:2804) at com.sap.engine.lib.xml.parser.XMLParser.scanDocument(XMLParser.java:2839) at com.sap.engine.lib.xml.parser.XMLParser.parse0(XMLParser.java:229) at com.sap.engine.lib.xml.parser.AbstractXMLParser.parseAndCatchException(AbstractXMLParser.java:145) at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:160) at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:261) at com.sap.engine.lib.xml.parser.Parser.parse_DTDValidation(Parser.java:282) at com.sap.engine.lib.xml.parser.Parser.parse(Parser.java:293) at com.sap.engine.lib.xml.parser.SAXParser.parse(SAXParser.java:126) at com.sap.aii.ib.server.mapping.execution.jaxpfactories.MappingXMLReader.parse(MappingXMLReader.java:102) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:387) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) at com.sap.aii.ib.server.mapping.execution.AbstractMappingTransformer.transform(AbstractMappingTransformer.java:174) at com.sap.aii.ib.server.mapping.execution.XSLTMapping.executeStep(XSLTMapping.java:79) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep(SequenceMapping.java:40) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:87) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:71) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:119) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:72) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at sun.reflect.GeneratedMethodAccessor310.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:43) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:71) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:38) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:22) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:189) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:16) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:21) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:16) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177) at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:133) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:164) at $Proxy544.processFunction(Unknown Source) 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.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:183) at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run(RFCJCOServer.java:269) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:152) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:247)</Trace>
    I will try your Java mapping next and get back to you if I get success with this.
    Cheers for your help.
    Colin.

  • Parsing String XML Document

    I didn't find a method that parses a XML document when it's not a file. I have a String that I want to parse and the method DocumentBuilder.parse only accepts a String that is a uri to a file.
    I write this code:
    String strXML = "<?xml version='1.0' ?><root><node>anything</node></root>";
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    domDoc = docBuilder.parse(strXML);
    Please gimme a light!!
    []'s
    Saulo

    I have a similar problem, I'm trying to do the same BUT in a servlet, it compiles and it actually works if I use it outside my servlet, but, when I mount the servlet with the code similar to this one here it doesn't read the string (at least that's what appears to be, because it doesn't writes to my DB as it should and it doesn't display anything as I'm specifying as my servlet response). Any help? I'm posting my code here:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.*;
    import org.apache.xml.serialize.*;
    import java.net.URLDecoder;
    import java.sql.*;
    import org.xml.sax.InputSource;
    import java.io.StringReader;
    public class SMSConnector extends HttpServlet
    //Public variables we will need
    public String Stringid;
    public String Stringpath;
    public String st;
    public int nid;
    //Servlet service method, which permits listening of events
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    //Initialization for the servlet
    ServletOutputStream salida = res.getOutputStream();
    ServletInputStream entrada = req.getInputStream();
    //Reading of the entering string
    BufferedReader lector = new BufferedReader(new InputStreamReader (entrada));
    res.setContentType("text/HTML");
    try {
    //Database handler
    Class.forName("org.gjt.mm.mysql.Driver");
    //DocumentBuilderFactory factory =
    //DocumentBuilderFactory.newInstance();
    //DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource inStream = new InputSource();
    inStream.setCharacterStream(new StringReader(lector.readLine()));
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc1 = docBuilder.parse(inStream);
    NodeList listasms = doc1.getElementsByTagName("sms");
    for(int s=0; s<listasms.getLength() ; s++)
    Connection Conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/smsdb","root", "");
    Node nodosms = listasms.item(s);
    if(nodosms.getNodeType() == Node.ELEMENT_NODE){
    Element elementosms = (Element)nodosms;
    NodeList listatelf = elementosms.getElementsByTagName("tlf");
    Element elementotelf = (Element)listatelf.item(0);
    NodeList textTelfList = elementotelf.getChildNodes();
    String telefono = ((Node)textTelfList.item(0)).getNodeValue();
    //String SendingAddress = ((Node)textAddressList.item(0)).getNodeValue().trim();
    salida.println(telefono);
    NodeList listaop = elementosms.getElementsByTagName("op");
    Element elementoop = (Element)listaop.item(0);
    NodeList textOpList = elementoop.getChildNodes();
    String operadora = ((Node)textOpList.item(0)).getNodeValue();
    NodeList listasc = elementosms.getElementsByTagName("sc");
    Element elementosc = (Element)listasc.item(0);
    NodeList textSCList = elementosc.getChildNodes();
    String shortcode = ((Node)textSCList.item(0)).getNodeValue();
    NodeList listabody = elementosms.getElementsByTagName("body");
    Element elementobody = (Element)listabody.item(0);
    NodeList textBodyList = elementobody.getChildNodes();
    String body = ((Node)textBodyList.item(0)).getNodeValue();
    Statement sta = Conn.createStatement();
    sta.executeUpdate("INSERT INTO smstable (telf,op,sc,body) VALUES ('" + telefono + "','" + operadora + "','" + shortcode + "','" + body + "')");
    Conn.commit();
    Conn.close(); }
    //Catching errors for the SAX and XML parsing
    catch (SAXParseException err)
    System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
    System.out.println(" " + err.getMessage ());
    catch (SAXException e)
    Exception x = e.getException ();
    ((x == null) ? e : x).printStackTrace ();
    catch (Throwable t)
    t.printStackTrace ();
    }

  • Charset conversion of incoming XML documents

    XML documents may contain data in other charsets than SAP's UTF-8. I'm using the ixml lib in ABAP.  Using 'get_encoding', I can determine the incoming document's charset, but it seems only after having parsed it. I'd like to convert the entire document to the current SAP charset before processing.  I didn't find a way in the ixml methods to do this, so I imagine I'll have to use CL_ABAP_CONV_IN_CE somehow. 
    What's the best way to handle non-SAP charsets in incoming XML documents?

    ha that was just a joke. check the link below
    http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sdkHelp&file=convertPDFToImage.64.3.html
    Google - java api for converting pdf documents to images
    Google - java api for converting xml documents to images etc

  • Parseing an XML Document as a String

    Hi all,
    i am trying to parse an XML document to a parser. I get the file as a request parameter, which is filled in to at String variable.
    But for some reason i get an SAXException, does anyone se the problem?
    Thank you for your help...
    Below is the code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.text.*;
    import java.net.*;
    import java.net.URL;
    import java.sql.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import javax.xml.parsers.*;
    import javax.xml.transform.stream.StreamSource;
    public class StartServlet extends HttpServlet
    private boolean debug = true;
    private final static String CONTENT = "content";
    private final static String COOKIES = "cookies";
    String resp = new String();
    private static String NODE_TYPES[] = new String[] {
         "ELEMENT",
         "ATTRIBUTE",
         "TEXT",
         "CDATA_SECTION",
         "ENTITY_REFERENCE",
         "ENTITY",
         "PROCESSING_INSTRUCTION",
         "COMMENT",
         "DOCUMENT",
         "DOCUMENT_TYPE",
         "DOCUMENT_FRAGMENT",
         "NOTATION" };
    public static void println(String s, int indent) {
         for(int i = 0 ; i < indent; i++) {
                   System.out.println(" ");
         System.out.println(s);
    public static void println(String s) {
         System.out.println(s);
    public static void print(Node node){
         printImpl(node, 0);
    public static void printImpl(Node node, int indent){
         if(node == null) {
              return;
         String nodeType = NODE_TYPES[node.getNodeType()];
         String nodeName = node.getNodeName();
         String nodeValue = node.getNodeValue();
         if(nodeValue != null) {
              nodeValue = nodeValue.trim();
         if(nodeType.equals("TEXT") && nodeValue.equals("")) {
              ; //Ignore emty node
         else {
              println(nodeType + " - " + nodeName + " - " + nodeValue, indent);
         NamedNodeMap attributes = node.getAttributes();
         if (attributes != null) {
              for(int i = 0; i < attributes.getLength(); i++) {
                   printImpl(attributes.item(i), indent + 1);
         NodeList children = node.getChildNodes();
         if(children != null) {
              for(int i = 0; i < children.getLength(); i++){
                   printImpl(children.item(i), indent + 1);
    public static DocumentBuilder newBuilder(boolean validation)
                        throws ParserConfigurationException {
         DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
         domFactory.setValidating(validation);
         domFactory.setNamespaceAware(true);
         DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
         //domBuilder.setErrorHandler(new PrintErrorHandler());
         return domBuilder;
    public static Document newDocument()
                        throws ParserConfigurationException{
         DocumentBuilder domBuilder = newBuilder(false);
         Document document = domBuilder.newDocument();
         return document;
    public static Document parse( String xml, boolean validation)
                        throws ParserConfigurationException, IOException, SAXException {
              DocumentBuilder domBuilder = newBuilder(validation);
              Document document = domBuilder.parse(xml);
              return document;
    public void init() {
    public void service( javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) {
              String[] cookies = null;
              try{
                   Hashtable document = getDocument("http://.../first.xml", cookies);
                   resp = (String) document.get(CONTENT);
                   debug(resp);
                   print(parse(resp, false));
              catch (SAXParseException e){
                   System.out.println("Saxfejl");
                   //System.exit(1);
              catch (Exception e){
                   e.printStackTrace();
                   System.exit(1);
    public void debug(String msg) {
         if(debug) {
              System.out.println(msg);
    public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
         try
              // Insert user code from here.
         catch(Throwable theException)
              // uncomment the following line when unexpected exceptions
              // are occuring to aid in debugging the problem.
              //theException.printStackTrace();
    public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
         performTask(request, response);
    public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
         performTask(request, response);
    private Hashtable getDocument(String urlCode, String[] oldCookies) {
         Hashtable document = new Hashtable();
         HttpURLConnection http = null;
         try {
              URL httpURL = new URL(urlCode);
              // If HTTP Protocol, then open connection using the Request method indicated
              URLConnection conn = httpURL.openConnection();
              http = (HttpURLConnection) conn;
              //http.setRequestMethod("GET");
              http.setDoInput(true);
              http.setDoOutput(true);
              http.setUseCaches(false);
              http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              if (oldCookies != null) {
                   for (int j = 0; j < oldCookies.length; j++) {
                        String cookie = oldCookies[j];
                        http.setRequestProperty("Cookie", cookie);
              http.connect();
              http.getContent();
              StringBuffer tsb = new StringBuffer("");
              if (http.getResponseCode() == 200) {
                   InputStream cis = http.getInputStream();
                   byte[] a = new byte[1024];
                   int n = cis.read(a);
                   while (n >= 0) {
                        tsb.append(new String(a, 0, n));
                        n = cis.read(a);
                   cis.close();
                   document.put(CONTENT, tsb.toString());
              String[] cookies = null;
              if (cookies == null) {
                   int headerFieldIndex = 0;
                   String headerFieldValue = http.getHeaderField(headerFieldIndex);
                   Vector cookieValues = new Vector();
                   while (headerFieldValue != null) {
                        String headerFieldName = http.getHeaderFieldKey(headerFieldIndex);
                        if ((headerFieldName != null) && headerFieldName.toLowerCase().equals("set-cookie")) {
                             int index = headerFieldValue.indexOf(";");
                             if (index > -1) {
                                  headerFieldValue = headerFieldValue.substring(0, index);
                             cookieValues.addElement(headerFieldValue);
                        headerFieldValue = http.getHeaderField(++headerFieldIndex);
                   cookies = new String[cookieValues.size()];
                   cookieValues.copyInto(cookies);
              document.put(COOKIES, cookies);
         catch (Exception e) {
              debug("url problem" + e);
         finally {
              if (http != null) {
                   http.disconnect();
         return document;
    }

    Hi,
    Use this code it will helpful to you.
    resultXMLDocument=(XmlDocument)documentDoc;
    StringWriter sw = new StringWriter();
    resultXMLDocument.write((Writer) sw);
    xmlString=sw.toString();
    thnaks,
    suneel

  • Can someone help me with a problem of parsing an XML file?

    Hello,
    I'm having some problems parsing an xml file. I get a SAXNotSupportedException when setting a property value.
    Here is the piece of code where I have the problem:
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    SAXParser saxParser = spf.newSAXParser();
    XMLReader xmlReader = saxParser.getXMLReader();
    DefaultHandler defHandler = new DefaultHandler();
    xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", defHandler);
    and the log is:
    Problem with the parser org.xml.sax.SAXNotSupportedException: PAR012 For propertyID "http://xml.org/sax/properties/lexical-handler", the value "org.xml.sax.helpers.DefaultHandler@4ff4f74a" cannot be cast to LexicalHandler.
    http://xml.org/sax/properties/lexical-handler org.xml.sax.helpers.DefaultHandler@4ff4f74a LexicalHandler
    I've been working on this problem but I can't find the error.
    Does anyone have an idea of what to do to solve it?
    Thanx in advance,
    M@G

    before deciding which XML technology to use, you should see if your application fit in the category below:
    use SAX:
    1. The XML file is rather large (30 or 40+ MB)
    2. I don't need the xml document in memory. I will parse the document and store the data in my own object.
    use DOM or JDOM
    1. The XML file is relatively small (less than 30 MB) or I can increase the runtime memory for larger xml file.
    2. I will need to walk up and down the xml document tree severals time.
    3. My application is in Java and it's not going to be rewritten in C++, etc (use JDOM)
    NOTE:
    JDOM is rather easier to use (for Java developer), but it's not an www.org.com standardlized xml parser.
    personally, i like JDOM for traversing the DOM.

  • Parsing an XML doc with unavailable entity (DTD)

    Hi all,
    I am trying to parse an XML file (web.xml) that has the following DOCTYPE in the head of the document:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app id="WebApp">When the parser starts, it will look for the DTD on the Sun site, however my work firewall blocks access to this so I get an exception when parsing.
    To resolve this, I have tried to force the parser to look for a local copy of the DTD instead of the Sun site but to no avail. I still get the same error but don't know why it wont look at the local DTD.
    Here is my code:
    * InterceptingXml.java
    * Created on 04 April 2006, 15:58
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package org.xmldemos;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.net.URI;
    import java.net.URISyntaxException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.xml.sax.EntityResolver;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    * @author CS781RJ
    public class InterceptingXml
        /** Creates a new instance of InterceptingXml */
        public InterceptingXml() { }
        public void parse(String filename)
            try
                // Create an XML parser
                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                // Install the entity resolver
                builder.setEntityResolver(new MyResolver());
                // Parse the XML file
                Document doc = builder.parse(new File(filename));
            catch (SAXException e) { e.printStackTrace(); }
            catch (ParserConfigurationException e) { e.printStackTrace(); }
            catch (IOException e) { e.printStackTrace(); }
            catch (Exception e) { e.printStackTrace(); }
        public class MyResolver implements EntityResolver
            // This method is called whenever an external entity is accessed
            // for the first time.
            public InputSource resolveEntity(String publicId, String systemId)
                try
                    System.out.println("publicId: " + publicId + " systemId: " + systemId);
                    // Wrap the systemId in a URI object to make it convenient
                    // to extract the components of the systemId
                    URI uri = new URI(systemId);
                    System.out.println("URI scheme: " + uri.getScheme());
                    System.out.println("URI scheme specific: " + uri.getSchemeSpecificPart());
                    // Check if external source is a file
                    if ("http".equals(uri.getScheme()))
                        String filename = uri.getSchemeSpecificPart();
                        filename = "file:/C:/web-app_2_3.dtd";
                        InputSource isrc = new InputSource(new FileReader(filename));
                        return isrc;
                catch (URISyntaxException e) { }
                catch (IOException e) { }
                // Returning null causes the caller to try accessing the systemid
                return null;
        public static void main(String[] args)
            InterceptingXml ixml = new InterceptingXml();
            ixml.parse("c:\\web.xml");
    }And here is the exception:
    init:
    deps-jar:
    compile-single:
    run-single:
    publicId: -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN systemId: http://java.sun.com/dtd/web-app_2_3.dtd
    URI scheme: http
    URI scheme specific: //java.sun.com/dtd/web-app_2_3.dtd
    java.net.UnknownHostException: java.sun.com
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
            at java.net.Socket.connect(Socket.java:507)
            at java.net.Socket.connect(Socket.java:457)
            at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
            at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
            at sun.net.www.http.HttpClient.New(HttpClient.java:287)
            at sun.net.www.http.HttpClient.New(HttpClient.java:299)
            at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792)
            at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:744)
            at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:669)
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:913)
            at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
            at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905)
            at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872)
            at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
            at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
            at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
            at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
            at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
            at org.xmldemos.InterceptingXml.parse(InterceptingXml.java:45)
            at org.xmldemos.InterceptingXml.main(InterceptingXml.java:88)
    BUILD SUCCESSFUL (total time: 18 seconds)I have noticed that return isrc; does not get executed even though the debugger steps to the line above it.
    Thanks in advance.
    Riz

    What's the point of all that code in your EntityResolver? Would the code work just as well if the DTD didn't even exist? Then do this:public InputSource resolveEntity(String publicId, String systemId)
                return new InputSource(new StringReader(""));
            }However if you really do need to redirect to a local copy of the DTD then consider this:catch (IOException e) { }can be a real barrier to understanding in the case that an IOException is thrown. At least print a stacktrace. And: the FileReader class wants a file name in its constructor, not a URI. And in this code:String filename = uri.getSchemeSpecificPart();
    filename = "file:/C:/web-app_2_3.dtd";you could write this instead:String filename = "file:/C:/web-app_2_3.dtd";which would be both shorter and easier to understand.

  • Parsing a XML file using Jdom-Problem.

    Hi all,
    I am reposting it as I was told to format the code and send it again.
    I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns" attribute is put in the xml as it should be then the parsing and retrieving returns null. Please tell me how to fix this issue.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Xml
    <process name="CreateKBEntryService" targetNamespace="http://serena.com/CreateKBEntryService" suppressJoinFailure="yes" xmlns:tns="http://serena.com/CreateKBEntryService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:nsxml0="http://localhost:8080/axis/services/CreateKBEntryService" xmlns:nsxml1="http://DefaultNamespace" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="tns:CreateKBEntryService" myRole="CreateKBEntryServiceProvider"/>
    <partnerLink name="CreateKBEntryPartnerLink" partnerLinkType="nsxml0:CreateKBEntryLink" partnerRole="CreateKBEntryProvider"/>
    </partnerLinks>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java:
    import java.io.*;
    import java.util.*;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    public class sample1 {
    public static void main(String[] args) throws Exception {
    // create a XML parser and read the XML file
    SAXBuilder oBuilder = new SAXBuilder();
    Document oDoc = oBuilder.build(new File("**xml file location**"));
    Element root = oDoc.getRootElement();
    System.out.println(root.getName());
    String tgtns= root.getAttributeValue("targetNamespace");
    System.out.println("tgt ns "+ tgtns);
    List list= root.getChildren("partnerLinks");
    Iterator it1= list.iterator();
    System.out.println("Iterator 1 - "+list.size());
    while(it1.hasNext()){
    Element partnerlinks = (Element)it1.next();
    List list2= partnerlinks.getChildren("partnerLink");
    System.out.println("iterator 2 - "+list2.size());
    }~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Result:
    Without Xmlns in xml file(Expected and correct output)
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 1//expected and correct result that comes when I remove xmlns attribute from xml
    iterator 2 - 2
    Result with xmlns:
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 0 //instead of 0 should return 1

    LOL
    This is what you get for working 12 hours straight....
    I changed:
    xmlObject["mydoc"]["modelglue"]["event-handlers"]["event-handler"][i].xmlAttrib utes["name"]<br>
    to:
    #mydoc["modelglue"]["event-handlers"]["event-handler"][i].xmlAttrib utes["name"]#<br>
    xmlObject is the name of my xml object in memory, and then you reference from the root of the xml doc down the chain.
    Sorry for the inconvenience,
    Rich

Maybe you are looking for

  • Cancellati​ons

    How can I cancel The Daily Manager & the daily NBC News printout? This question was solved. View Solution.

  • Looking at other websites

    is there a place where you can look at other websites made on a mac? i want to see how i can improve mine.

  • Histograms in Match Color

    Hello, As we all know, the Match Color utility was a great addition to the Photoshop series. But it does lack an important feature. When I have two images, [1] and [2], and I choose one image [1] to match color to, it copies colors that I see to the

  • 3.1EA1 database compare: add options to skip partitions comparison

    I just tried the new comparison tool, and it works far better than the old one. Just, I didn't find an option to skip comparing the partitions, I mean how many partitions there are and their names/boundaries. For example if I am comparing a developme

  • Send Button under 0ANALYSIS_PATTERN web template

    I use the standard 0ANALYSIS_PATTERN web template for "my query" and I have set "my query" as the data provider under the web template. When press the send button, the broadcaster wizard is launched. However the wizard does not pick up "my query" as