DocumentBuilder


DocumentBuilder javax.xml.parsers

Java 1.4

This class defines a high-level API to an underlying DOM parser implementation. Obtain a DocumentBuilder from a DocumentBuilderFactory . After obtaining a DocumentBuilder , you can provide org.xml.sax.ErrorHandler and org.xml.sax.EntityResolver objects, if desired. (These classes are defined by the SAX API but are useful for DOM parsers as well.) You may also want to call isNamespaceAware( ) , isXIncludeAware( ) and isValidating( ) to ensure that the parser is configured with the features your application requires. Finally, use one of the parse( ) methods to read an XML document from a stream, file, URL, or org.xml.sax.InputSource object, parse that document, and convert it into a org.w3c.dom.Document tree. Note that DocumentBuilder objects are not typically threadsafe. In Java 5.0, you can call reset( ) to restore the parser to its original state for reuse. Another Java 5.0 method, getSchema( ) returns the Schema object, if any, registered with the DocumentBuilderFactory that created this parser.

If you want to obtain an empty Document object (so that you can build the document tree from scratch, for example) call newDocument( ) . Or use getdOMImplementation( ) to obtain a the org.w3c.dom.DOMImplementation object of the underlying DOM implementation from which you can also create an empty Document .

See the org.w3c.dom package for information on what you can do with a Document object once you have used a DocumentBuilder to create it.

 public abstract class  DocumentBuilder  {  // Protected Constructors  protected  DocumentBuilder  ( );  // Public Instance Methods  public abstract org.w3c.dom.DOMImplementation  getDOMImplementation  ( );  5.0  public javax.xml.validation.Schema  getSchema  ( );        public abstract boolean  isNamespaceAware  ( );        public abstract boolean  isValidating  ( );  5.0  public boolean  isXIncludeAware  ( );        public abstract org.w3c.dom.Document  newDocument  ( );        public org.w3c.dom.Document  parse  (java.io.InputStream  is  )          throws org.xml.sax.SAXException, java.io.IOException;        public org.w3c.dom.Document  parse  (String  uri  )          throws org.xml.sax.SAXException, java.io.IOException;        public abstract org.w3c.dom.Document  parse  (org.xml.sax.InputSource  is  )  throws org.xml.sax.SAXException, java.io.IOException;        public org.w3c.dom.Document  parse  (java.io.File  f  )          throws org.xml.sax.SAXException, java.io.IOException;        public org.w3c.dom.Document  parse  (java.io.InputStream  is  , String  systemId  )  throws org.xml.sax.SAXException, java.io.IOException;  5.0  public void  reset  ( );        public abstract void  setEntityResolver  (org.xml.sax.EntityResolver  er  );        public abstract void  setErrorHandler  (org.xml.sax.ErrorHandler  eh  );   } 

Returned By

DocumentBuilderFactory.newDocumentBuilder( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net