Hi Edward

You have probably read a lot about JAXP. The first time I tried to use
Xerces I did like you but after seeing the examples I changed my point of
view.. Try to use DocumentImpl just when needed.

Get a DOM from a file is as easy as follows ( this is the way I do
it...probably not the best one)
This is a piece of my code

import java.io.*;

import org.apache.xerces.dom.DocumentImpl;
import org.apache.xerces.dom.DOMImplementationImpl;
import org.apache.xerces.dom.DocumentTypeImpl;
import org.apache.xerces.parsers.DOMParser;
import org.apache.xerces.framework.XMLParser;
import org.xml.sax.InputSource;

import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;                    //Many of these import are
not needed
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
public class Test{

 public static void main(String argv[])
 {
     try
      {
       File myFile = new File("c:\\argos\\profile21.xml");
       org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
       parser.setFeature( "http://xml.org/sax/features/validation";, true);
//Just if you want validation with DTD. You have
        // to set the ErrorHandler
       parser.parse(myFile.toString() );
       Document myDoc = parser.getDocument();
       System.out.println(myDoc.getDocumentElement().getNodeName());

      }catch (Exception ex)
      {
       System.out.println("There was an exception in Parse "+ex);
      }

 }
}

You see...nothing about Factorys nor Builders. This is one easy way to do
it....but there are more

Hope this helps


----- Original Message -----
From: "Edward Nesterov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 20, 2001 10:49 PM
Subject: Weird problem. Please He-e-e-e-lp!


> Hi guys!
> I am trying to get the below mentioned code to work with xerces1.4.1.
>
>         1: DocumentBuilderFactory factory    =
> DocumentBuilderFactory.newInstance();
>         2: DocumentBuilder docBuilder          =
> factory.newDocumentBuilder();
>         3: Document doc                                =
> docBuilder.parse(new InputSource(new FileReader("blah")));
>
> At line 2 I'am getting the following exception which looks like a bug.
>
>     Exception in thread "main" java.lang.NoSuchMethodError:
> javax.xml.parsers.DocumentBuilderFactory: method
> isIgnoringElementContentWhitespace()Z not found
>             at
>
org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:1
33)
>
>             at
>
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Documen
tBuilderFactoryImpl.java:92)
>
>             at offerlab.util.soap.TestClient.main(TestClient.java:53)
>
> Did anybody have this problem in the past?
> If yes - please help me to find the way out.
>
> Thanks in advance.
>
> Ed.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to