How can I parser a String with javax.xml.parsers.DocumentBuilder?

Normally the DocumentBuilder can parse files, InputSource,InputStream or uri. but what if I want to parse an editing String the user created in an EditPane or JTextComponent?

new InputSource(new StringReader(theString))

Similar Messages

  • Java.lang.NullPointerException javax.xml.parsers.DocumentBuilder.parse

    Hi all,
    i have a problem by solving an error in my code. The Code is mainly from Ian Darwin.
    The code i am running works with j2sdk1.4.2_04. But now i have to bring it to work with jdk1.6.0_13.
    The code parses xml documents. With small xml documents the code works. With large xml documents i get the following error while running the produced class file.
    Exception in thread "main" java.lang.NullPointerException
    at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.setChunkIndex(DeferredDocumentImpl.java:1944)
    at com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.appendChild(DeferredDocumentImpl.java:644)
    at com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser.characters(AbstractDOMParser.java:1191)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.characters(XMLDTDValidator.java:862)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:463)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)
    at XParse.parse(XParse.java:38)
    at XParse$JFileChooserrv.<init>(XParse.java:119)
    at XParse.main(XParse.java:213)
    I know what a java.lang.NullPointerException mens. But i don't know where i have to look for. Specially i don't know what or where "com.sun.org.apache...." is.
    Is there a package that a have to add to the environment? Can some one tell my where i can find this package?
    I wrote the code for some years ago, 2006 or so. With the knew jdk1.6.0_13 some thinks chance in the environment. Couldn't find what exactly.
    The code has only 215 lines, but some how i can't add it to this Message, because Maximum allowed is only 7500.
    Is there an other Forum, which may is better for my question?

    Here is the code:
    import java.io.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.Container;
    import javax.swing.JTextArea;
    * This code is mainly from @author Ian Darwin, [email protected]
    public class XParse {
         /** Convert the file */
         public static void parse(File file, boolean validate) {
              try {
                   System.err.println("");
                   String fileName = file.getAbsolutePath();
                   System.err.println("Parsing " + fileName + "...");
                   // Make the document a URL so relative DTD works.
                   //String uri = new File(fileName).getAbsolutePath();
                   //System.err.println(uri);
                   DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
                   if (validate)
                   f.setValidating(true);
                   DocumentBuilder p = f.newDocumentBuilder();
                   p.setErrorHandler(new MyErrorHandler(System.err));
                   //XmlDocument doc = XmlDocument.createXMLDocument(file);
                   boolean vaild =  p.isValidating();
                   if (vaild) {
                        System.out.println("yes parsing");
                        Document doc = p.parse(file); // <<<< ERROR
                   System.out.println("Parsed OK");
              } catch (SAXParseException ex) {
                   System.err.println("+================================+");
                   System.err.println("|       *SAX Parse Error*        |");
                   System.err.println("+================================+");
                   System.err.println(ex.toString());
                   System.err.println("At line " + ex.getLineNumber());
                   System.err.println("+================================+");
              } /**catch (RuntimeException ex) {
                   System.err.println("+================================+");
                   System.err.println("|       *SAX Parse Error*        |");
                   System.err.println("+================================+");
                   System.err.println(ex.toString());
                   //System.err.println("At line " + ex.getLineNumber());
                   //System.err.println("At line " + ex.getMessage());
                   System.err.println("+================================+");
              }**/ catch (SAXException ex) {
                   System.err.println("+================================+");
                   System.err.println("|          *SAX Error*           |");
                   System.err.println("+================================+");
                   System.err.println(ex.toString());
                   System.err.println("+================================+");
              /*}} catch (SAXNotRecognizedException  ex) {
                   System.err.println(" no SAX");*/
              } catch (ParserConfigurationException ex) {
                   System.err.println(" ???");
               } catch (IOException ex) {
                   System.err.println("+================================+");
                   System.err.println("|           *XML Error*          |");
                   System.err.println("+================================+");
                   System.err.println(ex.toString());
    private static class JFileChooserrv {
         JFileChooserrv(JFrame f, boolean vverabreiten) {
              String openfile;
              String verror;
              boolean validate = true;
              final JFrame frame = f;
              String vFilename = "Z:\\Boorberg\\parsen_vista\\daten";
              //String vFilename = "C:\\";
              File vFile = new File(vFilename);
              final JFileChooser chooser = new JFileChooser(vFile);
              JFileFilter filter = new JFileFilter();
              filter.addType("xml");
              filter.addType("sgml");
              filter.addType("html");
              filter.addType("java");
              filter.setDescription("strukturfiles");
              chooser.addChoosableFileFilter(filter);
              boolean vjeas = true;
              chooser.setMultiSelectionEnabled(vjeas);
              int returnVal = chooser.showOpenDialog(frame);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   //Array  filearry[] = chooser.getSelectedFiles();
                   //if (vFile = chooser.getSelectedFiles()) {
                   //File  file[] = chooser.getSelectedFiles();
                   File  vfile[] = chooser.getSelectedFiles();
                   //String openfile = new String();
                   int vlenght = vfile.length;
                   if (vlenght>1) {
                        int x=0;
                        while (x< vlenght) {
                                  parse(vfile[x], validate);
                                  x = x +1;
                   if (vlenght<=1) {
                        File v2file = chooser.getSelectedFile();
                             parse(v2file, validate);
              } else {
                   System.out.println("You did not choose a filesystem           object.");
         System.exit(0);
    private static class JFileFilter extends javax.swing.filechooser.FileFilter {
         protected String description, vnew;
         protected ArrayList<String> exts = new ArrayList<String>();
         protected boolean vtrue;
         public void addType(String s) {
              exts.add(s);
         /** Return true if the given file is accepted by this filter. */
         public boolean accept(File f) {
              // Little trick: if you don't do this, only directory names
              // ending in one of the extentions appear in the window.
              if (f.isDirectory()) {
                   return true;
              } else if (f.isFile()) {
                   Iterator it = exts.iterator();
                   while (it.hasNext()) {
                        if (f.getName().endsWith((String)it.next()))
                             return true;
              // A file that didn't match, or a weirdo (e.g. UNIX device file?).
              return false;
         /** Set the printable description of this filter. */
         public void setDescription(String s) {
              description = s;
         /** Return the printable description of this filter. */
         public String getDescription() {
              return description;
    private static 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 {
                   //System.exit(0);
                //out.println("Warning: " + getParseExceptionInfo(spe));
            public void error(SAXParseException spe) throws SAXException {
                   //System.exit(0);
                String message = "Error: " + getParseExceptionInfo(spe);
                throw new SAXException(message);
            public void fatalError(SAXParseException spe) throws SAXException {
                   //System.exit(0);
                String message = "Fatal Error: " + getParseExceptionInfo(spe);
                throw new SAXException(message);
         public static void main(String[] av) {
              JFrame vframe = new JFrame("chose files to pars");
              boolean vverabreiten = true;
              boolean validate = true;
              JFileChooserrv vdateienwaehlen = new JFileChooserrv(vframe, vverabreiten);
    }The Stack Trace i posted in the last Message. But i couldn't read it, i am not a programmer.

  • How can i read a string with nextToken() of StreamTokenizer

    I need for my class paper to read a string from a file and i used the StreamTokenizer's method nextToken but i can not read a string with it. my code is:
    StreamTokenizer st = new StreamTokenizer(the code that gets the input from the file)
    String line;
    while ((line !=br.readLine()) != null) {
    String surname = (st.nextToken()).trim();
    but it gets me some error of:
    int can not be dereferenced
    what should I do to get the string i need?

    Look at the API for java.io.StreamTokenizer. In particular, look at the return type for nextToken().
    Good luck.

  • Exception with javax.xml.parsers.FactoryConfigurationError

    I have a code segment that is working in a Java standalone application environment. I've taken the same segment and ran it in Lotus Domino's environment, with the following error,
    javax.xml.parsers.FactoryConfigurationError: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
    Can anyone help?

    I changed a switch within the Lotus Domino environment to allow class loader, but now I'm getting a different error,
    javax.xml.parsers.FactoryConfigurationError: Provider org.apache.crimson.jaxp.DocumentBuilderFactoryImpl not found
    Any idea?

  • ParserConfigurationException with javax.xml.parsers.DocumentBuilderFactory

    Like many people, I am trying to just read in the contents of a XML file. My code compiles in WS studio and I publish it to the server. However, I keep getting a ParserConfigurationException when I try to get a DocumentBuilder from the factory. Below is my code:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse( new File(XMLFILE) );
    Any idea why?

    The xmlfile is valid and here is the partial stacktrace
    Root Error-1: javax/xml/parsers/ParserConfigurationException
    java.lang.Exception: javax/xml/parsers/ParserConfigurationException
    at Search5F_Results_jsp_5._jspService(_Search_5F_Results_jsp_5.java:206)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:127)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:390)
    at org.apache.jasper.runtime.JspServlet.serviceJspFile
    Do I need to set some system property?

  • How can I substitute a string with another string in a file

    I have a file. I have a substitute a keyword with another string in all the occurences of a file. How can I do this?

    I'm gonna give you the benifit of the doubt and assume you didn't mean to double post your question.
    As to substitute a keyword with a string one way is to read in the file and run it through a StreamTokenizer class to break it into words. Pull one word at a time, check it, and stick it into a StringBuffer. Once your done with the file overwrite it with what is in the StringBuffer.
    Another way might be to use the RandomAccessFile class, but I'm not really familiar with that because I hardly ever use it.

  • How can I parse a String to Timestamp type??

    Hi, I receive a String time="07.05.2007 12:30:20", I want to parse this String to a Timestamp type, how to do that?

    I use the following code to parse String to Date, but it throw unhandled exception, type parse exception. It seems the parse source "07.05.2007 12:30:10" has problem.
    SimpleDateFormat sdfTest=new SimpleDateFormat("dd.mm.YYYY HH:mm:ss");
         Date newDate=sdfTest.parse("07.05.2007 12:30:10");
    Please give me some suggestion.
    Message was edited by:
    Mellon

  • URGENT:  javax.xml.parsers.DocumentBuilder.parse() method issue

    Hi folks,
    I have an urgent parsing problem. I developed an app with JDK1.4 and now it needs to run on JDK1.3.1. The problem is this:
    If I use the DocumentBuilder.parse() method shipped with JDK1.4 it will parse a document containing namespaces WITHOUT a namespace declaration in the root element. However, since XML support doesn't ship with JDK1.3.1 I need to use JAXP. If I try this with the DocumentBuilder.parse() version shipped with JAXP (latest version) the parse method throws a NullPointerException. If I put the namespace declaration in the document it will parse fine. I tried setting the DocumentBuilderFactory.setNamespaceAware() explicitly to false (should be the default) but no luck. Any ideas other than adding the declaration (long story why I don't want it there...)
    thanks

    example, with declaration of namespace:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root xmlns:inn="http://blablabla/inn/version/1.0/">
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    example, without declaration:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root>
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    this may help...

  • Javax.xml.parsers.DocumentBuilder to skip invalid XML characters?

    Hi,
    I convert XML files into flat files. In doing so I call the API DocumentBuilder.parse(File f). If the XML file f contains an invalid XML character, the API throws a SAXException.
    My question is: while I know that certain invalid XML chars are not part of the data and therefore can be safely ignored in the conversion, is there a way to tell the API to skip those chars?

    Nope. Compliant XML parsers are required to parse the XML as it is and not to "repair" it in any way. Your best option is not to have badly-formed XML in the first place, so if you are the one generating the XML, you should fix that process. But if you have bozo customers generating it, and you can't make them do it right, then pre-process the XML to drop the bad characters.

  • Javax.xml.parsers.SAXParser parser() error

    Hi,
    I've got some code that works fine in the Forte for Java IDE but just will not work when running as a stand-alone Windows application. I think it's to do with the filename having spaces in the pathname?
    Any help would be great!
    Regards.
    Gary Revell
    [email protected]
    [email protected]
    I've attached the code and the error(s) I get
    ------------------CODE FRAGMENT------------------
    // loadCE.java
    // Created on 25 April 2001, 15:43
    // @author RevellG
    // @version V1.0
    // This class is used to load the Standard Call Reporting XML document
    // and to allow the easy interrogation of the contents. The data can
    // then be used to populate fields in the Call Reporting GUI.
    import java.util.Vector;
    import java.io.*;
    import java.util.*;
    import java.util.Collections;
    import org.xml.sax.*;
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    public class loadCallElement extends Object
    private static loadCall loadCall = null;
    private static boolean DEBUG = false;
    // Creates new loadCE
    public loadCallElement(boolean debugFlag )
    this.DEBUG = debugFlag;
    public void parseDoc( String docName ) throws Throwable
    // Use the default (non-validating) parser
    SAXParserFactory factory = null;
    try
    // Parse the input
    factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();
    loadCall = new loadCall(DEBUG);
    saxParser.parse( new File( docName ), loadCall );
    catch (Throwable t)
    // catch ( Exception t )
    System.err.println( t.getMessage() +" - <"+docName+">");
    t.printStackTrace ();
    loadCall.ceTree.clear();
    throw t;
    ------------------Error and Stack Trace---------------
    E:\Support\Call Logs\bin>java -classpath .\SCM_GUI.jar;%CLASSPATH%;%XML_HOME%\jaxp.jar;%XML_HOME%\parser.jar M
    anagerInterface > g.g
    CWD /Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: 550 /Telecom/Support/Call Logs/Logs/
    Open/BBC PICS/001$revellg$qwerty.xml: The system cannot find the path specified.
    - <\\Reoclu1\Telecom\Support\Call Logs\Logs\Open\BBC PICS\001$revellg$qwerty.xml>
    java.io.FileNotFoundException: CWD /Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: 550 /
    Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: The system cannot find the path specified
    at sun.net.ftp.FtpClient.readReply(Unknown Source)
    at sun.net.ftp.FtpClient.issueCommand(Unknown Source)
    at sun.net.ftp.FtpClient.issueCommandCheck(Unknown Source)
    at sun.net.ftp.FtpClient.cd(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    at com.sun.xml.parser.InputEntity.init(InputEntity.java:141)
    at com.sun.xml.parser.Parser.parseInternal(Parser.java:463)
    at com.sun.xml.parser.Parser.parse(Parser.java:284)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:126)
    at loadCallElement.parseDoc(loadCallElement.java:52)
    at SCMView.create(SCMView.java, Compiled Code)
    at EventController$5.actionPerformed(EventController.java:116)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Thanks Jim,
    I've installed JDK V1.3.1 and the problem HAS gone away..... However now JDK V1.3.1 won't install on other Win 2K machines.....
    Gary.

  • Javax.xml.parsers Parser Failes at URGENT..URGENT.

    Hai,
    I am using JAVA PARSER to parse my xml file. My XML file is :
    <QUERY>SELECT * FROM EMP WHERE EMP_DATE > 18/10/2000</QUERY>.
    My Sample Code is:
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.DOMException;
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    fistream = new FileInputStream(fileName);
    document = builder.parse(fistream);
    e=document.getDocumentElement();
    curElm = (Element)nodeList.item(0);
    return_Value =((Text)curElm.getFirstChild()).getData().trim();
    Giving wrong output:
    SELECT * FROM EMP WHERE EMP_DATE
    Activally, I had to get
    SELECT * FROM EMP WHERE EMP_DATE > 18/10/2000.
    I do not know what's went wrong ?
    Please help me. It is very urgent to my project.
    Thanks a lot
    Regards
    Suresh

    hi,
    <, >, &, " and ' are XML control characters and do not belong to the data an XML document reflects. if you want to use these special characters, try a different notation, i.e. < > & " or &apos; as in
    <element>this is an <element> tag</element>
    sincerely, Michael

  • Contents of META-INF/services/javax.xml.parsers.DocumentBuilderFactory?

    I am currently working on an applet that solves Sudoku puzzles, allowing you to build your own in a Constructor and then solve them in a seperate Solver. To do this, we are implementing the puzzles files as XML documents.
    I have the code completely complied and on the server ( [sudoku.unl.edu|sudoku.unl.edu]) and it runs NEARLY perfectly, however when trying to access the server to save the xml code, the apache error_log presents this message: "File does not exist: classes/META-INF/services
    /javax.xml.parsers.DocumentBuilderFactory"
    Looking at the Java Doc here it says that the program should look for that in the jars. I am unsure of exactly how the applet is interacting with the server, but typing "java -version" yields:
    java version "1.6.0_11"
    Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
    Java HotSpot(TM) 64-Bit Server VM (build 11.0-b16, mixed mode)Notably, the code works PERFECTLY in NetBeans, contacting the server using SCP and uploading the file and such, so the code doesn't seem to be the problem, unless I need to direct the DocumentBuilder code somehow. This is the code that I believe is causing the trouble (I have tried to include all relevant imports that are in my code):
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    DocumentBuilderFactory factoryBuilder;
              DocumentBuilder builder;
              Document doc;
              Element docElement;
              try
                   factoryBuilder  = DocumentBuilderFactory.newInstance( );
                   builder = factoryBuilder.newDocumentBuilder();
                   doc = builder.parse( indexLocation );
                   docElement = doc.getDocumentElement();
                   NodeList children = docElement.getChildNodes();          
                   for(int i =0; i < children.getLength(); i++)
                        if(children.item(i).getNodeType() == 1)
                             if((children.item(i).getNodeName()).equals("directory"))
                                  if ((children.item(i).getAttributes().getNamedItem("name").getNodeValue()).equals("UsersInput")) {
                                       Node firstChild = findNodeItem(children.item(i), "Difficulty0.." + this.upperField.getText());
                                       Node secondChild = findNodeItem(firstChild, "Level" + this.levelField.getText());
                                       Node thirdChild = findNodeItem(secondChild, (String)suTypeList.getSelectedItem());
                                       Element newFile = doc.createElement("file");
                                       newFile.setAttribute("name", fileName);                              
                                       thirdChild.appendChild(newFile);                              
                   SshParameters params = new SshParameters("cse.unl.edu", "consystlab","A/tutti");
                // create new Scp instance
                Scp scp = new Scp(params);
                // register event listener
                scp.addListener(this);
                // establish connection
                scp.connect();
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   Transformer transformer = tFactory.newTransformer();
                   DOMSource source = new DOMSource(doc);
                   StringWriter sw=new StringWriter();
                   StreamResult result = new StreamResult(sw);
                   transformer.transform(source, result);
                   String xmlString=sw.toString();
                // upload file
                  scp.upload(xmlString.getBytes(), indexPath, "libraryIndex.xml");
                 // disconnect
                scp.disconnect();
              catch (IOException e)
                   System.out.println("IO ERROR7");
                   System.out.println(e);
              catch (TransformerException tranE){
                   tranE.printStackTrace();               
              catch (ParserConfigurationException e)
                   System.out.println("IO ERROR8");
                   System.out.println(e);
              catch (SAXException e)
                   System.out.println("IO ERROR9");
                   System.out.println(e);
              }So my question is, what exactly are the contents of the file in the META-INF/services folder? I have manually created this file in my classes directory, where the program is searching. When I place text in it, it appends the text with .class and searches for that file, but doesn't seem to do anything with the file. I attempted directing it to the "DocumentBuilderFactory.class" file that I extracted from the classes.jar included with the JDK.
    I feel like all I need is this file to contain the correct content and the code will FINALLY work, but I have not been able to find anything out there on it.
    Thank for you for your help, sorry this was such a long message.
    -Jason

    Thanks!
    Thanks for the fast reply. I don't know if I made my point clear.
    I do not want to determine the parser by myself. I want the client system use the default parser, so I do not have the hit of downloading the fairly large parser jar.
    However, I want it not to do an empty request to the server for nothing. This turn around time kills an Applet. I want a fast loading applet!
    I'll go in trial and error mode, when I find the time next week.
    Thanks again, I appreciate it!
    K<o>

  • How can I search the tree with a given string?

    How can I search the tree with a given string?
    I don't find any function like "search(...)".
    I want to find the tree nodes which include the given string.
    Thanks.

    Try it with .com instead of .ca - fixes it for me (corporate firewall blocks .ca here)
    http://spendolini.blogspot.com/2013/09/working-with-apex-tree.html
    Anyway - it links to an article of mine which describes interacting with the tree: Tom's Blog: Working with the tree in Apex. There is also a demo application on apex.oracle.com: http://apex.oracle.com/pls/apex/f?p=54687:38

  • How can i plot a histogram with using the results of Line Length

    PLS HELP.How can i prepare a histogram with using the results of line length code(It is somewhere in the middle).
    This is a final exam take-home question. I would appreciate if you can help?
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.text.*;
    import java.io.File;
    public class WordAnalyser extends JFrame implements ActionListener
    private JMenuItem jmiAc, jmiSil, jmiCikis, jmiAnaliz, jmiHakkinda, jmiKullanim;
    private JTextArea jta1, jta2;
    private JFileChooser jFileChooser = new JFileChooser();
    File hafizada;
    File aktarilan = new File("Sonuc.txt");
    // Main method
    public static void main(String[] args)
    WordAnalyser frame = new WordAnalyser(); /* Ana ekran olusturulur */
    frame.setSize(400, 300); /* Degerleri belirlenir */
    frame.setVisible(true); /* Gorunebilirligi ayarlanir */
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public WordAnalyser()
    setTitle("Serkan Ozgen Dosya Inceleme Programina Hos Geldiniz");
    JMenuBar mb = new JMenuBar();
    setJMenuBar(mb);
    JMenu fileMenu = new JMenu("Dosya");
    fileMenu.setMnemonic('F');
    mb.add(fileMenu);
    JMenu helpMenu = new JMenu("Degerlendirme");
    helpMenu.setMnemonic('H');
    mb.add(helpMenu);
    JMenu kullanimMenu = new JMenu("Kullanim Kilavuzu");
    mb.add(kullanimMenu);     
    fileMenu.add(jmiAc = new JMenuItem("Ac", 'A'));
    fileMenu.add(jmiSil = new JMenuItem("Sil", 'S'));
    fileMenu.add(jmiCikis = new JMenuItem("Cikis", 'C'));
    helpMenu.add(jmiAnaliz = new JMenuItem("Analiz", 'D'));
    helpMenu.add(jmiHakkinda = new JMenuItem("Hakkinda", 'H'));
    kullanimMenu.add(jmiKullanim = new JMenuItem("Kullanim"));     
    getContentPane().add(new JScrollPane(jta1 = new JTextArea()), BorderLayout.CENTER);
    getContentPane().add(jta2 = new JTextArea(), BorderLayout.SOUTH);
    jmiAc.addActionListener(this);
    jmiSil.addActionListener(this);
    jmiCikis.addActionListener(this);
    jmiAnaliz.addActionListener(this);
    jmiHakkinda.addActionListener(this);
    jmiKullanim.addActionListener(this);
    public void actionPerformed(ActionEvent e)
    String actionCommand = e.getActionCommand();
    if (e.getSource() instanceof JMenuItem)
    if ("Ac".equals(actionCommand))
    Ac();
    else if ("Sil".equals(actionCommand))
    Sil();
    else if ("Cikis".equals(actionCommand))
    System.exit(0);
    else if ("Analiz".equals(actionCommand))
    sayim();
    else if ("Hakkinda".equals(actionCommand))
    JOptionPane.showMessageDialog(this,
    "!!!! Bu program text analizi gerceklestirir. Her hakki saklidir SERKAN OZGEN!!!!",
    "Bu program hakkinda",
    JOptionPane.INFORMATION_MESSAGE);
    else if ("Kullanim".equals(actionCommand))
         JOptionPane.showMessageDialog(this,
         " Ilk once dosya menusunden Ac i tiklayarak analiz etmek istediginiz Dosyayi seciniz (Lutfen uzantisi *.txt \nveya *.log olsun). Daha sonra Degerlendirme menusunden analizi tiklarsaniz dosyanizda kac adet rakam, harf, \ncumle ve kelime oldugunu gorebilirsiniz. Simdiden kolay gelsin",
         "Programin kullanim detaylari",
         JOptionPane.INFORMATION_MESSAGE);
    private void Ac()
    if (jFileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
    hafizada = jFileChooser.getSelectedFile();
    Ac(hafizada);
    // Acilan Dosyayi ana ekranda gostermeye yariyan bir method
    private void Ac(File file)
    try
    // Acilan dosyayi okuma ve ana ekranda gosterme
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
    byte[] b = new byte[in.available()];
    in.read(b, 0, b.length);
    jta1.append(new String(b, 0, b.length));
    in.close();
    catch (IOException ex)
    // Temizle tusunun hangi ekranlara etki edecegini secme
    private void Sil()
    jta1.setText("");
    jta2.setText("");
    private void sayim()
    int buff;
    int sayac = 0;
    int Cumleler = 0;
    int Kelimeler = 0;
    int Karakterler = 0;
    int Satirlar = 0;
    int Rakamlar = 0;     
    boolean start = true;
    int linenum = 0;     
    try
    FileInputStream instream = new FileInputStream(hafizada);
    FileOutputStream outstream = new FileOutputStream(aktarilan);
         BufferedReader infile = new BufferedReader(new InputStreamReader(new FileInputStream(hafizada)));
    PrintStream out = new PrintStream(outstream);
         out.println("---Kelime Avcisinin Sonuclari---");
         String line = infile.readLine();
         while (line != null){
         int len = line.length();
         linenum++;
         line = infile.readLine();
         out.println("Line Length :"     + linenum + "\t" +len);
    while ((buff=instream.read()) != -1)
    switch((char)buff)
    case '?': case '.': case '!': /* Eger "?", "." veya "!" gorurse program cumleleri ve kelimeleri arttirir*/
    if (start == false)
    Cumleler++;
    Kelimeler++;
    start = true;
    break;
    case ' ': case '\t': case ',': case ';': case ':': case'\"': case'\'': /* Eger /t,;:\ ve \" bu isarteleri goruruse program kelimeleri arttirir */
    if (start == false)
    Kelimeler++;
    start = true;
    break;
              case 'n': case '\n': /* Eger \n gorurse satirlari arttirir */
              if (start == false)
                   Satirlar++;
                   Kelimeler++;
                   start = true;
              break;
    default:
    if (((char)buff >= 'a' && (char)buff<='z')|| /*a-z, A-Z veya - degerlerini gorurse karakterler arttirilir */
    ((char)buff >= 'A' && (char)buff<='Z')||
    ((char)buff == '-'))
    Karakterler++;
    if ((Kelimeler % 50) == 49)
    if (start == true)
                   out.println();     
    out.print((Kelimeler+1) + " ");
    out.print((char)buff);
    start = false;
              if ((char)buff >='0' && (char)buff <='9') {  /* 0-9 gorurse rakamlari arttiri */
                   Rakamlar++; }
    }// switch
         }//while
    instream.close();
    out.println();
    out.println();
    out.println("Karakter sayisi: " + Karakterler);
         out.println("Kelime sayisi: " + Kelimeler);
    out.println("Cumle sayisi: " + Cumleler);
         out.println("Satir sayisi: "+ Satirlar);
         out.println("Rakam sayisi: "+ Rakamlar);
    outstream.close();
    try
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(aktarilan));
    byte[] b = new byte[in.available()];
    in.read(b, 0, b.length);
    jta2.append(new String(b, 0, b.length));
    in.close();
    catch (IOException ex)
    catch (Exception e)
    System.out.println(e);
    }

    Why is it that you're not interested in IOExceptions?
    catch (IOException ex)
    } Empty catch blocks is a hallmark of foolish Java code. At least print out the stack trace.
    %

  • How can I return multiple values with PL/SQL Web Services

    Hi,
    I'm new to developping Web Services. I'm doing some tests with JDeveloper and OC4J on my local machine with a Web Services based on a PL/SQL function within a package. Right now that function only returns one value. So the xml response only has one output.
    I'd like to know how can I return multiple values with my PL/SQL Web Service. For example, if I want to return an employee's name and id? And that the xml contains two output : <employee>, <empid>?
    Reginald
    ps : I have searched the forum and I couldn't find an answer to this question, if that has been discussed AND answered before, can you please post the link? Thanks

    Alright, I actually found my answer. Since this was asked I think as a followup somewhere else I'll give my answer.
    It is very simple, all you have to do is create an Object Type and then Return that object type. After that, JDeveloper will take care of everything and you will have an xml response with multiple values. Here
    {color:#ff0000}
    create or replace TYPE person AS OBJECT
    ( id_interv number,
    first_name VARCHAR2(50),
    last_name VARCHAR2(50),
    date_birth date
    );{color}
    Then your function used in your Web Service should look something like this :
    {color:#ff0000}
    function info_emp (p_empno IN VARCHAR2) RETURN person AS
    l_emp person := person(-1,'','','');
    BEGIN
    SELECT first_name
    ,last_name
    ,emp_no
    INTO l_emp.first_name
    ,l_emp.last_name
    ,l_emp.emp_no
    FROM emp
    WHERE upper(emp_no) = upper (emp_no);
    {color}
    {color:#ff0000}
    RETURN l_emp;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    l_emp := person (-1,'n/a','n/a','n/a');
    RETURN l_emp ;
    END info_emp;{color}
    {color:#ff0000}{color:#000000}After that, this is what the xml response looks like :{color}{color}
    &lt;first_name xsi:type="xsd:string"&gt;John&lt;/first_name&gt;
    &lt;last_name xsi:type="xsd:string"&gt;Doe&lt;/last_name&gt;
    &lt;emp_no xsi:type="xsd:string"&gt;0250193&lt;/emp_no&gt;

Maybe you are looking for

  • What is the latest version of firefox?

    I want to know what the latest version of firefox is and it seems impossible to find out. I do not want to know what version I have - I know I do not want to know how to install the latest updates - I know I just want to know what the current version

  • Job CLEAN_REQREQ_UP and BBP_GET_STATUS_2 does not update SC in SRM With PO

    Hello, We are on SRM 5.0 Classic scenario  R3 SAP  ECC 6.0. we recently had a stackupgrade for all our different components. Aswe are in a classic scenario we get a prucahse requisition after a shopping cart is approved. The purchaser then creates a

  • MBP (Early 2008) Airport failure

    Hi there! I have a Problem with my MBP's Airport: I can't seem to connect to any Wireless...! Resetting PRAM and NVRAM doesn't solve the Problem... I compared the Airport Advanced settings with another MBP and they are identical... Network Diagnostic

  • Can I have both iMovie 09 and iMovie 08 installed on the same Mac?

    Hi, This question may seem odd, but... I work at a college. In my role there, I provide training for students and faculty using a variety of technologies (including the iLife suite). I would like to purchase and install iLife 09 for my Mac for person

  • Elements 12 Organizer running on Windows 7 will not launch

    I have Elements 12 for over six months and it has been working fine. I have used Photo editor several times today without a problem. When I try to launch organizer either from within Editor or from the welcome screen it will not launch. It appears to