You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tw...@locus.apache.org on 2000/01/25 23:03:46 UTC

cvs commit: xml-xerces/java/docs faq-write.xml readme.xml

twl         00/01/25 14:03:46

  Modified:    java/docs faq-write.xml readme.xml
  Log:
  update README to include License info
  update FAQs on creating a parser to match current architecture
  
  Revision  Changes    Path
  1.6       +36 -50    xml-xerces/java/docs/faq-write.xml
  
  Index: faq-write.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/docs/faq-write.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- faq-write.xml	2000/01/24 23:43:48	1.5
  +++ faq-write.xml	2000/01/25 22:03:45	1.6
  @@ -2,61 +2,69 @@
   <!DOCTYPE faqs SYSTEM "sbk:/style/dtd/faqs.dtd">
   
   <faqs title="Writing Application FAQs">
  -	<faq title="Constructing a Parser">
  -		<q>How do I construct a parser in &javaparsername;?</q>
  -		<a><p>
  -There are two ways the parser classes can be
  -	  instantiated: The first way is to <em>create a string</em>
  -	  containing the fully qualified name of the parser class. Pass
  -	  this string to the <code>org.xml.sax.helpers.ParserFactory.makeParser()</code>
  -	  method to instantiate it. This method is useful if your application will need to switch between different parser configurations. The code snippet shown below is using this method to instantiate a DOMParser.</p> 
  -
  -<source>import org.xml.sax.Parser;
  -import org.xml.sax.helpers.ParserFactory; 
  -import org.apache.xerces.parsers.DOMParser;
  +	<faq title="Creating a DOM Parser">
  +		<q>How do I create a parser that produces a DOM tree?</q>
  +        <a><p>To work with a parser that produces a DOM tree, you need to
  +        use the <code>DOMParser</code> class from
  +        <code>org.apache.xerces.parsers</code>.  The code sample below
  +        shows you how to create a <code>DOMParser</code> instance and
  +        use it to parse an XML document.</p> 
  +
  +<source>import org.apache.xerces.parsers.DOMParser;
   import org.w3c.dom.Document;
   import org.xml.sax.SAXException;
  -import java.io.IOException; 
  +import java.io.IOException;
   
     ...
   
  -String parserClass = &quot;org.apache.xerces.parsers.DOMParser&quot;;
  -
   String xmlFile = &quot;file:///Xerces-J/data/personal.xml&quot;; 
   
  -Parser parser = ParserFactory.makeParser(parserClass);
  +DOMParser parser = new DOMParser();
   
   try {
       parser.parse(xmlFile);
  +
   } catch (SAXException se) {
       se.printStackTrace();
   } catch (IOException ioe) {
  -	ioe.printStackTrace();
  +    ioe.printStackTrace();
   }
  -// The next line is only for DOM Parsers
   
  -Document doc = ((DOMParser) parser).getDocument(); 
  +Document doc = parser.getDocument();
   
     ...</source>
  -
  -	 <p>The second way to instantiate a parser class is to <em>explicitly
  -	 instantiate</em> the parser class, as shown in this example,
  -	 which is creating a DOM Parser. Use this way when you know
  -	 exactly which parser configuration you need, and you are sure
  -	 that you will not need to switch configurations.</p>
   
  -<source>import org.apache.xerces.parsers.DOMParser;
  -import org.w3c.dom.Document;
  +	<p>Once you have the <code>Document</code> object, you can call any method on it as defined by the DOM specification.</p>
  +     </a>
  +	</faq>
  +	
  +	<faq title="Creating a SAX Parser">
  +		<q>How do I create a parser that uses the SAX API?</q>
  +		<a><p>To work with a parser that uses the SAX API, you need to
  +		use the <code>SAXParser</code> class from
  +		<code>org.apache.xerces.parsers</code>.  You need to be sure
  +		that you provide classes that implement the SAX
  +		<code>DocumentHandler</code> and <code>ErrorHandler</code>
  +		interfaces.  The code sample below shows how to create a
  +		<code>SAXParser</code> instance and use that instance to
  +		parse an XML document.</p>
  +<source>import org.apache.xerces.parsers.SAXParser;
   import org.xml.sax.SAXException;
  +import org.xml.sax.DocumentHandler;
   import java.io.IOException;
   
     ...
   
   String xmlFile = &quot;file:///Xerces-J/data/personal.xml&quot;; 
   
  -DOMParser parser = new DOMParser();
  +SAXParser parser = new SAXParser();
   
  +DocumentHandler documentHandler = ... // you supply a class that implements the DocumentHandler interface
  +ErrorHandler errorHandler = ... // you supply a class that implements the ErrorHandler interface
  +
   try {
  +    parser.setDocumentHandler(documentHandler);
  +    parser.setErrorHandler(errorHandler)
       parser.parse(xmlFile);
   
   } catch (SAXException se) {
  @@ -64,30 +72,8 @@
   } catch (IOException ioe) {
       ioe.printStackTrace();
   }
  -// The next line is only for DOM Parsers
  -Document doc = parser.getDocument();
   
     ...</source>
  -
  -	<p>Once you have the Document object, you can call any method on it as defined by the DOM specification.</p>
  -   </a>
  -	</faq>
  -	
  -	<faq title="Creating a DOM Parser">
  -		<q>How do I create a DOM parser?</q>
  -        <a><p>Use one of the methods in the question above, and use 
  -		<code>org.apache.xerces.parsers.DOMParser</code> as the name of the class. </p>
  -		<p>To access the DOM tree, you can call the
  -		<code>getDocument()</code> method on the parser instance.</p> 
  -		</a>
  -	</faq>
  -	
  -	<faq title="Creating a SAX Parser">
  -		<q>How do I create a SAX parser?</q>
  -		<a><p>Use one of the methods in the question above, and use 
  -		<code>org.apache.xerces.parsers.SAXParser</code> as the name of the class. </p>
  -		<p>Once you have the parser instance, you can use the standard SAX 
  -		methods to set the various handlers provided by SAX. </p>
   		</a>
   	</faq>
   	
  
  
  
  1.4       +3 -5      xml-xerces/java/docs/readme.xml
  
  Index: readme.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/docs/readme.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- readme.xml	1999/12/29 01:07:44	1.3
  +++ readme.xml	2000/01/25 22:03:45	1.4
  @@ -19,14 +19,12 @@
   		whether the APIs that we are providing are the right ones. Please 
   		direct your feedback to the &javaparsername; mailing list.</p>
   
  -        <p>The 1.0.1 release is the first release to benefit from the
  -        xml.apache.org collaboration.  This release includes Assaf Arkin's
  -        serialization and HTML DOM contributions.
  -        </p>
   	</s2>
   	<s2 title="License Information">
   		<p>The &javaparsername; &javaparserversion; release is available in both source code
  -			and precompiled binary (JAR files) form.</p>
  +			and precompiled binary (JAR files) form. &javaparsername;
  +			&javaparserversion; is licensed under the terms of Version
  +			1.1 of the  <jump href="http://xml.apache.org/dist/License.txt">Apache Software License</jump></p>
   	</s2>
   	<s2 title="Applications of the &javaparsername; Parser">
   		<p>The rich generating and validating capabilities allow the &javaparsername;