Can I use a C/C++ xml parser in my java program?

Hi,
How can I use a C/C++ xml parser in my java program?
Elvis.

You would still need to convert the XML data structure into a Java data structure to import it into Java.
Don't assume you need C++ to do anything. I woudl write it in Java first, then profile the application to see where the bottle necks are and then optimise them
Don't optimise code unless you have proof it needs to be optimised.
If you want to improve the speed of reading XML, try XMLbooster

Similar Messages

  • How can I use a 3rd party XML parser such as xerces with OC4J ?

    Hi all tech experts,
    I am using Oracle Application Server 10g Release 2 (10.1.2) and i have
    installed Portal and Wireless and OracleAS Infrastructure on the same
    computer.
    i tried all the solutions on this thread
    Use of Xerces Parser in out application with Oracle App Server 9.0.4
    but still fighting.
    I have also posted this query on OTN on following thread
    How can I use a 3rd party XML parser such as xerces with OC4J?
    but no reply....
    Please help me on this issue.
    Since OC4J is preconfigured to use the Oracle XML parser which is xmlparserv2.jar.
    i have read the following article which states that
    OC4J is preconfigured to use the Oracle XML parser. The Oracle XML parser is fully JAXP 1.1 compatible and will serve the needs of applications which require JAXP functionality. This approach does not require the download, installation, and configuration of additional XML parsers.
    The Oracle XML parser (xmlparserv2.jar) is configured to load as a system level library of OC4J through it's inclusion as an entry in the Class-Path entry of the oc4j.jar Manifest.mf file. This results in the Oracle XML parser being used for all common deployment and packaging situations. You are not permitted to modify the Manifest.mf file of oc4j.jar.
    It must be noted that configuring OC4J to run with any additional XML parser or JDBC library is not a supported configuration. We do know customers who have managed to successfully replace the system level XML parser and the Oracle JDBC drivers that ship with the product, but we do not support this type of configuration due to the possibility of unexpected system behavior and system errors that might occur from replacing the tested and certified libraries.
    If you absolutely must use an additional XML parser such as xerces, then you have to start OC4J such that the xerces.jar file is loaded at a level above the OC4J system classpath. This can be accomplished using the -Xbootclasspath flag of the JRE.
    i have also run the following command
    java -Xbootclasspath/a:d:\xerces\xerces.jar -jar oc4j.jar
    but no success.
    How could i utilize my jar's like xerces.jar and xalan.jar for parsing instead of OC4J in-built parser ?
    All reply will be highly appreciated.
    Thnx in advance to all.
    Neeraj Sidhaye
    try_catch_finally @ Y !

    Hi Neeraj Sidhaye,
    I am trying to deploy a sample xform application to the Oracle Application Server (10.1.3). However, I encountered the class loader issue that is similar to your stuation. I tried all the three solutions but the application is still use the Oracle xml paser class. I am wondering if you have any insight about this?
    Thanks for your help.
    Xingsheng Qian
    iPass Inc.
    Here is the error message I got.
    Message:
    java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
    Stack Trace:
    org.chiba.xml.xforms.exception.XFormsException: java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
         at org.chiba.xml.xforms.Container.dispatch(Unknown Source)
         at org.chiba.xml.xforms.Container.dispatch(Unknown Source)
         at org.chiba.xml.xforms.Container.initModels(Unknown Source)
         at org.chiba.xml.xforms.Container.init(Unknown Source)
         at org.chiba.xml.xforms.ChibaBean.init(Unknown Source)
         at org.chiba.adapter.servlet.ServletAdapter.init(ServletAdapter.java:153)
         at org.chiba.adapter.servlet.ChibaServlet.doGet(ChibaServlet.java:303)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
         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)
    Caused by: java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
         at org.chiba.xml.xforms.Instance.iterateModelItems(Unknown Source)
         at org.chiba.xml.xforms.Bind.initializeModelItems(Unknown Source)
         at org.chiba.xml.xforms.Bind.init(Unknown Source)
         at org.chiba.xml.xforms.Initializer.initializeBindElements(Unknown Source)
         at org.chiba.xml.xforms.Model.modelConstruct(Unknown Source)
         at org.chiba.xml.xforms.Model.performDefault(Unknown Source)
         at org.chiba.xml.xforms.XFormsDocument.performDefault(Unknown Source)
         at org.chiba.xml.xforms.XFormsDocument.dispatchEvent(Unknown Source)
         at org.apache.xerces.dom.NodeImpl.dispatchEvent(Unknown Source)
         ... 18 more

  • How to read an XML file into a java program?

    hi,
    i want to load the following very simple xml file in my java program.
    <root>
    <weblogic>
    <url value="t3://192.168.1.160:7001" />
    <context value="weblogic.jndi.WLInitialContextFactory" />
    </weblogic>
    </root>
    I am getting the error: " Line=1: cvc-elt.1: Cannot find the declaration of element 'root'."
    What might be the problem can anyone help me out.
    My java class code is:
    public class BIXMLReader {
    /** All output will use this encoding */
    static final String outputEncoding = "UTF-8";
    // Parses an XML file and returns a DOM document.
    // If validating is true, the contents is validated against the DTD
    // specified in the file.
    public static Document parseXmlFile(String filename, boolean validating) {
    try {
    // Create a builder factory
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setIgnoringComments(false);
    factory.setIgnoringElementContentWhitespace(false);
    factory.setCoalescing(false);
    factory.setValidating(validating);
    // Create the builder and parse the file
    System.out.println("filename = " + filename);
    DocumentBuilder db = factory.newDocumentBuilder();
    // Set an ErrorHandler before parsing
    OutputStreamWriter errorWriter = new OutputStreamWriter(System.err, outputEncoding);
    db.setErrorHandler(new MyErrorHandler(new PrintWriter(errorWriter, true)));
    Document doc = db.parse(new File(filename));
    System.out.println(doc.toString());
    return doc;
    } catch (SAXException e) {
    System.out.println("A parsing error occurred; the xml input is not valid. " + e.getMessage());
    } catch (ParserConfigurationException e) {
    System.out.println("Parser configuration exception has occured");
    } catch (IOException e) {
    System.out.println("IO Exception has occured " + e.getMessage());
    return null;
    // Error handler to report errors and warnings
    private static class MyErrorHandler implements ErrorHandler {
    /** Error handler output goes here */
    private PrintWriter out;
    MyErrorHandler(PrintWriter 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);
    }

    ok thanks, i can get the elements, but why did it not validate it?
    I want to read the child nodes of "weblogic" not by their name but by their index. Because i dont want to confine the reader so i want to read all the child nodes of weblogic (looping over them). i m doing the following but its not returning me the correct result and giving me the wrong count of child nodes.
    Element elementNode = (Element)doc.getElementsByTagName("weblogic").item(0);
    NodeList nodeList = elementNode.getChildNodes();
    int length = nodeList.getLength();
    System.out.println("length = "+ length); // the length its giving is 5 but i shuld get only 2
    for(int i=0; i < length; i++) {
    Element elmChild = (Element) nodeList.item(i);
    System.out.println(elmChild.getAttribute("value"));
    what might be the problem?

  • How Can One use XML data into our Java Program

    I have an Java Program and an XML file contaning data. I want to parse the xml data and use into my Java Program. How can I do so.

    Check out the org.xml.sax.XMLReader class.

  • Can anyone help me fix an XML Parsing Error?

    Hi I have been working with a form in a PDF and suddenly it won't let me open it. The following error pops up: "Xml parsing error: not well-formed (invalid token) (error code 4), line 71537, column 695 of file" and I haven't been able to come up with a solution. A lot of data has been entered into this file for a grant that my clinic is applying for, so if anyone can help me I would be greatly appreciative.

    Hm, now I get:
    JPVNCManager.java:211: warning: [unchecked] unchecked cast
    found : java.lang.Object
    required: java.util.Vector<java.lang.String>
    Vector<String> v1 = (Vector<String>)o1;
    ^
    JPVNCManager.java:212: warning: [unchecked] unchecked cast
    found : java.lang.Object
    required: java.util.Vector<java.lang.String>
    Vector<String> v2 = (Vector<String>)o2;
    ^
    JPVNCManager.java:207: warning: [unchecked] unchecked conversion
    found : java.util.Vector
    required: java.util.List<T>
    Collections.sort(main, new Comparator()
    ^
    JPVNCManager.java:207: warning: [unchecked] unchecked conversion
    found : <anonymous java.util.Comparator>
    required: java.util.Comparator<? super T>
    Collections.sort(main, new Comparator()
    ^
    JPVNCManager.java:207: warning: [unchecked] unchecked method invocation: <T>sort(java.util.List<T>,java.util.Comparator<? super T>) in java.util.Collections is applied to (java.util.Vector,<anonymous java.util.Comparator>)
    Collections.sort(main, new Comparator()
    ^
    Thanks,
    James

  • Can we use MessageTransformBean in between XML -- XML scenario !!

    Hi Claver Heads,
    Small thing in XML to XML transformation. Can we use MessageTransformBean? The reason why I am asking, In my scenario, XML to ABAP proxy, messages are splitting (1:n) everything is working fine. But in splitting messages, first Messages is getting all nodes etc., from split second message on words, Couple of nodes are missing(not coming at all)?
    Any solutions for this please?
    Thanks
    Regards
    San

    Hi hetal,
    Yeah you are 100% correct. This must be context issue. But I don't know how to fix this. The target message is quite big hierarchy, like ProductActivityNotification>ProductActivity>Item>SalesTimeSeries>Item>ValidPeriod>Startdate etc.,
    Source XML is getting DTM segment, which is in Header -- comes one time, more than 100 line items to this message. This 100 line items has to go with this date into Startdate etc.,
    At present I am getting only one time this into Startdate. Please any clue in this!!
    Many Thanks in advance
    Kind Regards
    San

  • Is there a method I can use to test the space cost of a Java program?

    I am trying to test the space cost of a Java program (or a few lines of executed codes), however...
    Firstly I tried to use the method freeMemory() in runtime class at start and end of a number of lines tested on, and then find the differences between them. But because I don't know when JVM releases memories, this idea seems not working.
    I also tries to use the -verbose:gc to print the GC actions, which is also hard to be automatically collected (Computing the results one by one by hand is too burdensome).
    Is there a method in some classes can be used for doing this? Could anyone help me on this, please?

    Up _+ ...                                                                                                                                                                                                                                                       

  • Can we limit number of CPUs seen by a JVM/Java programs?

    We have a Java application which is licensed in several tiers for a number of CPUs (i.e. 1 for trial, 4 and unlimited CPUs for supported version of different cost).
    If the application is not provided with a supported license and is executed on multiprocessor hardware, it complains and aborts.
    When we tried this application on a Solaris server, we made a zone with a single CPU thread as a dedicated processor, and the application worked.
    Now we are trying to set up a trial version on a developer's Windows CoreDuo notebook, and since there are two cores the trial version barks and aborts.
    Can we use some JVM feature to force it into seeing and using only a certain number of CPUs, smaller than the number of available hardware CPUs (or at least reporting that number to the java apps)?

    You can set the processor affinity to the process you are interested in. Just go to "Task Manager" and click the processes tab, highlight the process you care about and right click it, then select "set affinity" menu and bind that process to the processor you want. This requires you to have the process running first, if that does not work for you, you can write a launcher which calls SetProcessAffinityMask call provided for Windows (see http://msdn.microsoft.com/en-us/library/ms686223(VS.85).aspx for details) and then launch the java process. This works since process affinity is inherited by any child process or newly instantiated local process based on the MSDN documents.

  • Using a UNIX shell script to run a Java program (packaged in a JAR)

    Hi,
    I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
    Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
    loggedinuser="$(whoami)"
    CFG_DIR="`dirname $0`"
    EXIT_STATUS=${SUCCESS}
    export PATH=/opt/java1.3/bin:$PATH
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIR
    java -classpath $
    EXIT_STATUS=$?
    cd $OLDDIR
    echo $EXIT_STATUS
    exit $EXIT_STATUS

    Hi,
    I have an application (very small) that connects to
    our database. It needs to run in our UNIX environment
    so I've been working on a shell script to set the
    class path and call the JAR file.
    #!/bin/sh
    exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
    CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
    cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
    echo $EXIT_STATUS
    exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
    Harald.

  • Can we get file name which we are compiling in java program

    Hi,
    I want to know if we can get filename(when compiling) or jarfile(when running) which we are compiling in the program itself.
    EX:java -jar myjar.jar
    How can I display jar file(i.e myjar.jar) in my program
    ex:sop("file which compiled is:"<filename>);

    can you rephrase the question in english, please!!

  • How can I use SAX to Read XML in JSP?

    I created a class which extend DefaultHandler of SAX. I can use java to call this class and read XML data without any problems. But I can't call this class through JSP. Looks it didn't active startElement() when I called from JSP. Do you have any ideas on this case?
    ======================This is java call and works==============
    import java.io.*;
    import java.util.*;
    import ReadXmlSax;
    public class ReadElement
         public static void main(String argv[])
              ReadXmlSax r = new ReadXmlSax();
              Enumeration e = r.getAttribute("dre.xml","server","name");
              try{
                   while (e.hasMoreElements()) {
                   System.out.println((String)e.nextElement());}
              }catch(Throwable t){
                   t.printStackTrace();
    ======================================================================
    ========================This is jsp call but doesn't work=============
    <%@ page import = "java.util.*" %>
    <%@ page import = "java.io.*" %>
    <%@ page import = "ReadXmlSax" %>
    <html>
    <head><title>SAX Reader</title></head>
    <body>
    <%
    ReadXmlSax r = new ReadXmlSax();
    Enumeration e = r.getAttribute("dre.xml","server","name");
    while (e.hasMoreElements()) {
    out.println(e.nextElement());
    out.println("<br>");
    %>
    </body>
    </html>
    ======================================================================

    maybe you just simply can't reach dre.xml from your web server!

  • WebLogic: Can I use CMP for HTTP/XML calls like I can for JDBC ConnPools

    I have an Entity EJB that I currently persist using WebLogic's CMP with an Oracle Conn Pool and JDBC. I have a new persistance (home-made) storage system that talks XML over HTTP. No real SOAP implementation except in the XML/HTTP communications.
    Questions:
    Can I still leverage CMP to persist entities - such that I could create a pool of XML/HTTP objects (that open a java.net connection - send a URL request in XML format) and have CMP handle persisting as it does now?
    I would think there is some universal way to create a pool of communication objects to talk to anything if you define the mechanisms..right? If so, how do I get CMP to see that? In other words, is CMP only applied to "Known" data sources? Or can I give it my own..create my own weblogic-cmp.xml file.

    So, you have a home-made persistence solution with your own API and you expect CMP (_Container_ Managed Persistence) to be able to hook into that? Unlikely, right?
    Maybe you could implement a JDBC driver on top of your persistence scheme, then you might have a shot.
    Vlad.
    P.S. Entity beans' performance is so bad everyone recommends against using them -- doing persistence over something as slow as HTTP would only make matters worse.

  • XML parsing regressing from Java 1.4 to 1.5

    Hi,
    I have a piece of code using Jakarta digester. This piece of code is prety simple and was working fine until I switched from java 1.4 to java 1.5. However, i didn't changed the Digester jar.
    After investigation, I noticed that the problem disappear if i remove the DOCTYPE entry from the XML file I'm parsing.
    Is there any known regression ?
    Thanks =P
    Stack Trace
    java.net.UnknownHostException: D
         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.NetworkClient.openServer(NetworkClient.java:118)
         at sun.net.ftp.FtpClient.openServer(FtpClient.java:488)
         at sun.net.ftp.FtpClient.openServer(FtpClient.java:475)
         at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:270)
         at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:352)
         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)Error while getting input files description. Process aborted.
         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.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
         at org.apache.commons.digester.Digester.parse(Digester.java:1556)
         at com.wwdm.datahandle.TransformDescriptorFactory.getTransformer(TransformDescriptorFactory.java:99)
         at mainTest.main(mainTest.java:29)
    XML
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE descriptor SYSTEM "file://D:/dtds/WWDM_Input.dtd">
    <descriptor>
    </description>
    ------

    I made an error in my XML while posting... so just to avoid replies telling it cames from there :
    XML
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE descriptor SYSTEM "file://D:/dtds/WWDM_Input.dtd">
    <descriptor>
    </descriptor>

  • Can we use is null in our select statement in ABAP program

    hi,
    I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data. Can anyone resolve this.

    Hi,
    I think you've posted your question on the wrong forum. This is the SAP Business One development forum which is not part of ERP and doesn't include any ABAP or Netweaver programming.
    For a list of forums please see here:
    http://forums.sdn.sap.com/index.jspa
    Kind Regards,
    Owen

  • Can I use more than one USB 6008 in the same program?

    I am working on a project that may require up to six USB-6008 modules.  Before I purchase more I need to know if I can use all six at a time in the same Lab View program.  Can anyone help?
    Solved!
    Go to Solution.

    Hello Nick,
    LabVIEW is able to handel that number of DAQ tasks quite easily, however you must remember that USB has a maximum bandwidth. Therefore you would have to ensure that you have enough USB hubs on your PC. Typically there are between two to four USB slots per hub and each of these will have a maximum throughput rate which will divided between all devices attached to that hub. Therefore although you may have four USB DAQ devices attached to four USB ports if they are on the same hub you may notice greatly reduced rates of data transfer. What I would suggest rather than purchasing six or more USB 6008, why not purchase one PCI card which is able to handel many more inputs with a larger bandwidth.
    Regards
    Andrew George @ NI UK

Maybe you are looking for