You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@apache.org on 2001/05/17 18:18:16 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util/xml XMLParserUtils.java

duftler     01/05/17 09:18:16

  Modified:    java/src/org/apache/soap/util/xml XMLParserUtils.java
  Log:
  Added Apache Software License.
  Cleaned up formatting a bit.
  
  Revision  Changes    Path
  1.2       +110 -54   xml-soap/java/src/org/apache/soap/util/xml/XMLParserUtils.java
  
  Index: XMLParserUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/xml/XMLParserUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLParserUtils.java	2001/03/23 07:46:37	1.1
  +++ XMLParserUtils.java	2001/05/17 16:18:11	1.2
  @@ -1,12 +1,68 @@
  +/*
  + * The Apache Software License, Version 1.1
  + *
  + *
  + * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer. 
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:  
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "SOAP" and "Apache Software Foundation" must
  + *    not be used to endorse or promote products derived from this
  + *    software without prior written permission. For written 
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    nor may "Apache" appear in their name, without prior written
  + *    permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation and was
  + * originally based on software copyright (c) 2000, International
  + * Business Machines, Inc., http://www.apache.org.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
   
   package org.apache.soap.util.xml;
   
   // JAXP packages
   import javax.xml.parsers.*;
  -import org.apache.soap.Constants;
   import org.xml.sax.*;
   import org.xml.sax.helpers.*;
   import org.w3c.dom.*;
  +import org.apache.soap.Constants;
   
   /**
    * XML Parser Utilities
  @@ -15,59 +71,59 @@
    * @author Ruth Bergman (ruth@alum.mit.edu)
    */
   public class XMLParserUtils {
  -
  -    /**
  -     * Returns the current value of the JAXP DocumentBuilderFactory
  -     * (System property "javax.xml.parsers.DocumentBuilderFactory").
  -     * I.E. the factory for the parser that will be used by the program.
  -     *
  -     * @return String name of the factory class
  -     */
  -    public static String getXMLDocBuilderFactoryProp() {
  -	return System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
  -    }
  -
  -    /**
  -     * Sets the system property of the JAXP DocumentBuilderFactory.
  -     *
  -     * @param String name of the factory class
  -     * @return no return value
  -     */
  -    public static void setXMLDocBuilderFactoryProp(String value) {
  -	System.setProperty("javax.xml.parsers.DocumentBuilderFactory",value);
  -    }
  +  /**
  +   * Returns the current value of the JAXP DocumentBuilderFactory
  +   * (System property "javax.xml.parsers.DocumentBuilderFactory").
  +   * I.E. the factory for the parser that will be used by the program.
  +   *
  +   * @return String name of the factory class
  +   */
  +  public static String getXMLDocBuilderFactoryProp() {
  +    return System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
  +  }
  +
  +  /**
  +   * Sets the system property of the JAXP DocumentBuilderFactory.
  +   *
  +   * @param String name of the factory class
  +   * @return no return value
  +   */
  +  public static void setXMLDocBuilderFactoryProp(String value) {
  +    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", value);
  +  }
  +
  +  /**
  +   * Use this method to get a JAXP document builder.  
  +   * This method creates a namespace aware, nonvalidating 
  +   * instance of the XML parser.
  +   *
  +   * @return DocumentBuilder an instance of a document builder, 
  +   * or null if a ParserConfigurationException was thrown.
  +   */
  +  public static DocumentBuilder getXMLDocBuilder() {
  +    // Step 1: create a DocumentBuilderFactory and configure it
  +    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  +
  +    // Optional: set various configuration options
  +    dbf.setNamespaceAware(true);
  +    dbf.setValidating(false);
  +
  +    // At this point the DocumentBuilderFactory instance can be saved
  +    // and reused to create any number of DocumentBuilder instances
  +    // with the same configuration options.
  +
  +    // Step 2: create a DocumentBuilder that satisfies the constraints
  +    // specified by the DocumentBuilderFactory
  +    DocumentBuilder db = null;
  +
  +    try {
  +      db = dbf.newDocumentBuilder();
  +
  +      return db;
  +    } catch (ParserConfigurationException pce) {
  +      System.err.println(pce);
   
  -    /**
  -     * Use this method to get a JAXP document builder.  
  -     * This method creates a namespace aware, nonvalidating 
  -     * instance of the XML parser.
  -     *
  -     * @return DocumentBuilder a instance of a document builder, 
  -     * null if a ParserConfigurationException was thrown.
  -     */
  -    public static DocumentBuilder getXMLDocBuilder() {
  -        // Step 1: create a DocumentBuilderFactory and configure it
  -        DocumentBuilderFactory dbf =
  -            DocumentBuilderFactory.newInstance();
  -
  -        // Optional: set various configuration options
  -	dbf.setNamespaceAware(true);
  -        dbf.setValidating(false);
  -
  -        // At this point the DocumentBuilderFactory instance can be saved
  -        // and reused to create any number of DocumentBuilder instances
  -        // with the same configuration options.
  -
  -        // Step 2: create a DocumentBuilder that satisfies the constraints
  -        // specified by the DocumentBuilderFactory
  -        DocumentBuilder db = null;
  -        try {
  -            db = dbf.newDocumentBuilder();
  -	    return db;
  -        } catch (ParserConfigurationException pce) {
  -            System.err.println(pce);
  -            return null;
  -        }
  +      return null;
       }
  -    
  +  }
   }