You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/10/02 04:43:29 UTC

cvs commit: xml-xalan/java/src/trax Examples.java Templates.java Transformer.java

sboag       00/10/01 19:43:26

  Modified:    java/src makexslt4j
               java/src/org/apache/xalan/client XSLTProcessorApplet.java
               java/src/org/apache/xalan/lib Redirect.java
               java/src/org/apache/xalan/processor ProcessorOutputElem.java
               java/src/org/apache/xalan/stree SourceTreeHandler.java
               java/src/org/apache/xalan/templates ElemTemplateElement.java
                        ElemTextLiteral.java ElemValueOf.java
                        OutputFormatExtended.java StylesheetComposed.java
                        StylesheetRoot.java
               java/src/org/apache/xalan/transformer ResultTreeHandler.java
                        TransformerImpl.java
               java/src/org/apache/xalan/utils QName.java
                        SystemIDResolver.java TreeWalker.java
               java/src/org/apache/xalan/xpath/xml TreeWalker.java
               java/src/org/apache/xalan/xslt Process.java
                        StylesheetRoot.java XSLTProcessor.java
               java/src/org/apache/xpath DOM2Helper.java NodeSet.java
               java/src/serialize OutputFormat.java QName.java
                        SerializerFactory.java SerializerHandler.java
                        serializer.properties
               java/src/serialize/helpers HTMLOutputFormat.java
                        TextOutputFormat.java XHTMLOutputFormat.java
                        XMLOutputFormat.java
               java/src/trax Examples.java Templates.java Transformer.java
  Added:       java/src/javax/xml/parsers DocumentBuilder.java
                        DocumentBuilderFactory.java
                        FactoryConfigurationError.java
                        ParserConfigurationException.java SAXParser.java
                        SAXParserFactory.java package.html
               java/src/org/apache/xalan/utils URI.java
               java/src/org/apache/xml/serialize/transition
                        BaseMarkupSerializer.java ElementState.java
                        Encodings.java HTMLSerializer.java HTMLdtd.java
                        IndentPrinter.java LineSeparator.java Method.java
                        Printer.java SerializerFactoryImpl.java
                        TextSerializer.java XHTMLSerializer.java
                        XMLSerializer.java
               java/src/org/w3c/dom Attr.java CDATASection.java
                        CharacterData.java Comment.java DOMException.java
                        DOMImplementation.java Document.java
                        DocumentFragment.java DocumentType.java
                        Element.java Entity.java EntityReference.java
                        NamedNodeMap.java Node.java NodeList.java
                        Notation.java ProcessingInstruction.java Text.java
               java/src/org/w3c/dom/range DocumentRange.java Range.java
                        RangeException.java
               java/src/org/w3c/dom/traversal DocumentTraversal.java
                        NodeFilter.java NodeIterator.java TreeWalker.java
               java/src/org/xml/sax AttributeList.java Attributes.java
                        ContentHandler.java DTDHandler.java
                        DocumentHandler.java EntityResolver.java
                        ErrorHandler.java HandlerBase.java InputSource.java
                        Locator.java Parser.java SAXException.java
                        SAXNotRecognizedException.java
                        SAXNotSupportedException.java
                        SAXParseException.java XMLFilter.java
                        XMLReader.java
               java/src/org/xml/sax/ext DeclHandler.java
                        LexicalHandler.java
               java/src/org/xml/sax/helpers AttributeListImpl.java
                        AttributesImpl.java DefaultHandler.java
                        LocatorImpl.java NamespaceSupport.java
                        ParserAdapter.java ParserFactory.java
                        XMLFilterImpl.java XMLReaderAdapter.java
                        XMLReaderFactory.java
  Removed:     java/src/org/apache/xalan/dtm ChunkedIntArray.java DTM.java
                        DTMException.java DTMLiaison.java
                        DTMNodeVector.java DTMProxy.java DTMProxyMap.java
                        IntMap.java IntToObjectMap.java package.html
  Log:
  Removed Xerces dependencies, in prep for Xerces2.
      Use JAXP for DOM parser.
      For now, duplicated Xerces URI code.
      Created org.apache.xml.serialize.transition package
         (See note to xalan-dev list.  This involves serialize.* interfaceing, whitespace handling mods, more...)
  Fixed tracking of whitespace stripping.
  Fixed interfacing to serializers for bypassing escaping.
  
  Revision  Changes    Path
  1.11      +26 -3     xml-xalan/java/src/makexslt4j
  
  Index: makexslt4j
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/makexslt4j,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- makexslt4j	2000/09/28 16:02:57	1.10
  +++ makexslt4j	2000/10/02 02:43:01	1.11
  @@ -218,7 +218,6 @@
     org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)PrefixResolver.java \
     org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)PrefixResolverDefault.java \
     org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)QName.java \
  -  org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)RawCharacterHandler.java \
     org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)StringKey.java \
     org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)StringToIntTable.java \
     org$(PATHSEP)apache$(PATHSEP)xalan$(PATHSEP)utils$(PATHSEP)StringToStringTable.java \
  @@ -242,6 +241,17 @@
     trax$(PATHSEP)Transformer.java \
     trax$(PATHSEP)TransformException.java \
     trax$(PATHSEP)URIResolver.java \
  +  serialize$(PATHSEP)DOMSerializer.java \
  +  serialize$(PATHSEP)Method.java \
  +  serialize$(PATHSEP)OutputFormat.java \
  +  serialize$(PATHSEP)QName.java \
  +  serialize$(PATHSEP)Serializer.java \
  +  serialize$(PATHSEP)SerializerFactory.java \
  +  serialize$(PATHSEP)SerializerHandler.java \
  +  serialize$(PATHSEP)helpers$(PATHSEP)HTMLOutputFormat.java \
  +  serialize$(PATHSEP)helpers$(PATHSEP)TextOutputFormat.java \
  +  serialize$(PATHSEP)helpers$(PATHSEP)XHTMLOutputFormat.java \
  +  serialize$(PATHSEP)helpers$(PATHSEP)XMLOutputFormat.java \
     synthetic$(PATHSEP)Class.java \
     synthetic$(PATHSEP)SynthesisException.java \
     synthetic$(PATHSEP)reflection$(PATHSEP)Constructor.java \
  @@ -249,8 +259,21 @@
     synthetic$(PATHSEP)reflection$(PATHSEP)Field.java \
     synthetic$(PATHSEP)reflection$(PATHSEP)Member.java \
     synthetic$(PATHSEP)reflection$(PATHSEP)Method.java \
  -  org$(PATHSEP)w3c$(PATHSEP)xslt$(PATHSEP)ExpressionContext.java
  -   
  +  org$(PATHSEP)w3c$(PATHSEP)xslt$(PATHSEP)ExpressionContext.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)BaseMarkupSerializer.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)ElementState.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)Encodings.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)HTMLdtd.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)HTMLSerializer.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)IndentPrinter.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)LineSeparator.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)Method.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)Printer.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)SerializerFactoryImpl.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)TextSerializer.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)XHTMLSerializer.java \
  +  org$(PATHSEP)apache$(PATHSEP)xml$(PATHSEP)serialize$(PATHSEP)transition$(PATHSEP)XMLSerializer.java
  +    
   OBJS = $($(subst /,\\,$(SRCS)):%.java=classes/%.class)
   
   all: sincelast makesubdirs
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/DocumentBuilder.java
  
  Index: DocumentBuilder.java
  ===================================================================
  /*
   * 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 "Xerces" 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) 1999-2000, Pierpaolo
   * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package javax.xml.parsers;
  
  import java.io.File;
  import java.io.InputStream;
  import java.io.IOException;
  import org.xml.sax.EntityResolver;
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.w3c.dom.Document;
  
  /**
   * Instances of <code>DocumentBuilder</code> provide a mechansim for
   * parsing XML documents into a DOM document tree represented by an
   * <code>org.w3c.dom.Document</code> object.
   * <br>
   * A <code>DocumentBuilder</code> instance is obtained from a
   * <code>DocumentBuilderFactory</code> by invoking its
   * <code>newDocumentBuilder()</code> method.
   * <br>
   * <b>NOTE:</b> <code>DocumentBuilder</code> uses several classes from the
   *     SAX API. This does not require that the implementor of the
   *     underlying DOM implementation use a SAX parser to parse XML content
   *     into a <code>org.w3c.dom.Document</code>. It merely requires that
   *     the implementation communicate with the application using these
   *     existing APIs.
   * <br>
   * <br>
   * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
   *   IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
   *   REQUEST 5 FOUND AT
   *   <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
   *   http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
   *   </a><br>
   *   THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
   *   SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
   *   PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
   *   <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
   * <br>
   * <br>
   * <b>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 AUTHOR 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.
   *
   * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
   * @author Copyright &copy; 2000 The Apache Software Foundation.
   * @version 1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:02 $
   */
  public abstract class DocumentBuilder {
  
      /**
       * Implementors of this abstract class are not required to provide a
       * public no-argument constructor, since instantiation is taken care
       * by <code>DocumentBuilderFactory</code> implementations.
       */
      protected DocumentBuilder() {
          super();
      }
  
      /**
       * Parses the contents of the given <code>InputStream</code> and returns
       * a <code>Document</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException If any IO errors occur reading the given
       *                <code>InputStream</code>.
       * @exception  IllegalArgumentException If the given
       *                <code>InputStream</code> is <b>null</b>.
       */
      public Document parse(InputStream stream)
      throws SAXException, IOException, IllegalArgumentException {
          if (stream==null) throw new IllegalArgumentException();
          return(this.parse(new InputSource(stream)));
      }
  
      /**
       * Parses the content of the given URI and returns a <code>Document</code>
       * object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException If any IO errors occur while reading content
       *                located by the given URI.
       * @exception IllegalArgumentException If the given URI is <b>null</b>.
       */
      public Document parse(String uri)
      throws SAXException, IOException, IllegalArgumentException {
          if (uri==null) throw new IllegalArgumentException();
          return(this.parse(new InputSource(uri)));
      }
  
      /**
       * Parses the content of the given <code>File</code> and returns a
       * <code>Document</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException if any IO errors occur while reading content
       *                from the given <code>File</code>.
       * @exception IllegalArgumentException if the given <code>File</code> is
       *                <b>null</b>.
       */
      public Document parse(File file)
      throws SAXException, IOException, IllegalArgumentException {
          if (file==null) throw new IllegalArgumentException();
          // Thanks to Kevin Kress <Ke...@oracle.com> for pointing
          // out this bug.
          return(this.parse(new InputSource(file.getAbsolutePath())));
      }
  
      /**
       * Parses the content of the given <code>InputSource</code> and returns
       * a <code>Document</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException if any IO Errors occur while reading content
       *                from the given <code>InputSource</code>.
       * @exception IllegalArgumentException if the given
       *                <code>InputSource</code> is <b>null</b>.
       */
      public abstract Document parse(InputSource source)
      throws SAXException, IOException, IllegalArgumentException;
  
      /**
       * Creates an new <code>Document</code> instance from the underlying DOM
       * implementation.
       */
      public abstract Document newDocument();
  
      /**
       * Returns whether or not this parser supports XML namespaces.
       */
      public abstract boolean isNamespaceAware();
  
      /**
       * Returns whether or not this parser supports validating XML content.
       */
      public abstract boolean isValidating();
  
      /**
       * Specifies the <code>EntityResolver</code> to be used by this
       * <code>DocumentBuilder</code>.
       * <br>
       * Setting the <code>EntityResolver</code> to <b>null</b>, or not
       * calling this method, will cause the underlying implementation to
       * use its own default implementation and behavior.
       */
      public abstract void setEntityResolver(EntityResolver er);
  
      /**
       * Specifies the <code>ErrorHandler</code> to be used by this
       * <code>DocumentBuilder</code>.
       *
       * Setting the <code>ErrorHandler</code> to <b>null</b>, or not
       * calling this method, will cause the underlying implementation to
       * use its own default implementation and behavior.
       */
      public abstract void setErrorHandler(ErrorHandler eh);
  }
  
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/DocumentBuilderFactory.java
  
  Index: DocumentBuilderFactory.java
  ===================================================================
  /*
   * 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 "Xerces" 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) 1999-2000, Pierpaolo
   * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package javax.xml.parsers;
  
  /**
   * The <code>DocumentBuilderFactory</code> defines a factory API that enables
   * applications to configure and obtain a parser to parse XML documents into
   * a DOM Document tree.
   * <br>
   * <br>
   * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
   *   IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
   *   REQUEST 5 FOUND AT
   *   <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
   *   http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
   *   </a><br>
   *   THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
   *   SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
   *   PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
   *   <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
   * <br>
   * <br>
   * <b>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 AUTHOR 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.
   *
   * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
   * @author Copyright &copy; 2000 The Apache Software Foundation.
   * @version 1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $
   */
  public abstract class DocumentBuilderFactory {
  
      /** Wether the DocumentBuilder to be generated must support namespaces. */
      private boolean namespaces=false;
      /** Wether the DocumentBuilder to be generated must support validataion. */
      private boolean validation=false;
      /** The system property to check for DocumentBuilderFactory class name. */
      private static String property="javax.xml.parsers.DocumentBuilderFactory";
      /** The default DocumentBuilderFactory implementation class name. */
      private static String factory=
                            "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl";
  
      /**
       * Implementors of this abstract class <b>must</b> provide their own
       * public no-argument constructor in order for the static
       * <code>newInstance()</code> method to work correctly.
       * <br>
       * Application programmers should be able to instantiate an implementation
       * of this abstract class directly if they want to use a specfic
       * implementation of this API without using the static newInstance method
       * to obtain the configured or platform default implementation.
       */
      protected DocumentBuilderFactory() {
          super();
      }
  
      /**
       *
       * Returns a new instance of a <code>DocumentBuilderFactory</code>.
       * <br>
       * The implementation of the <code>DocumentBuilderFactory</code>
       * returned depends on the setting of the
       * <code>javax.xml.parsers.DocumentBuilderFactory</code> property or,
       * if the property is not set, a platform specific default.
       *
       * @exception FactoryConfigurationError If the class implementing the
       *                factory cannot be found or instantiated.
       *                An <code>Error</code> is thrown instead of an exception
       *                because the application is not expected to handle or
       *                recover from such events.
       */
      public static DocumentBuilderFactory newInstance() {
  
          // Retrieve the javax.xml.parsers.DocumentBuilderFactory system property
          String n=factory;
          try {
              n=System.getProperty(property, factory);
          } catch (SecurityException e) {
          	// In applets System.getProperty throws a SecurityException.
          	// Thanks to Aaron Buchanan <ab...@inovacorp.com> and to
          	// James Duncan Davidson <ja...@eng.sun.com> for this
          	n=factory;
          }
  
          try {
              // Attempt to load, instantiate and return the factory class
              return (DocumentBuilderFactory)Class.forName(n).newInstance();
  
          } catch (ClassNotFoundException e) {
              // The factory class was not found
              throw new FactoryConfigurationError("Cannot load class "+
                  "DocumentBuilderFactory class \""+n+"\"");
  
          } catch (InstantiationException e) {
              // The factory class wasn't instantiated
              throw new FactoryConfigurationError("Cannot instantiate the "+
                  "specified DocumentBuilderFactory class \""+n+"\"");
  
          } catch (IllegalAccessException e) {
              // The factory class couldn't have been accessed
              throw new FactoryConfigurationError("Cannot access the specified "+
                  "DocumentBuilderFactory class \""+n+"\"");
  
          } catch (ClassCastException e) {
              // The factory class was not a DocumentBuilderFactory
              throw new FactoryConfigurationError("The specified class \""+n+
                  "\" is not instance of \""+
                  "javax.xml.parsers.DocumentBuilderFactory\"");
          }
      }
  
      /**
       * Returns a new configured instance of type <code>DocumentBuilder</code>.
       *
       * @exception ParserConfigurationException If the
       *                <code>DocumentBuilder</code> instance cannot be created
       *                with the requested configuration.
       */
      public abstract DocumentBuilder newDocumentBuilder()
      throws ParserConfigurationException;
  
      /**
       * Configuration method that specifies whether the parsers created by this
       * factory are required to provide XML namespace support or not.
       * <br>
       * <b>NOTE:</b> if a parser cannot be created by this factory that
       *     satisfies the requested namespace awareness value, a
       *     <code>ParserConfigurationException</code> will be thrown when the
       *     program attempts to aquire the parser calling the
       *     <code>newDocumentBuilder()</code> method.
       */
      public void setNamespaceAware(boolean aware) {
          this.namespaces=aware;
      }
  
      /**
       * Configuration method whether specifies if the parsers created by this
       * factory are required to validate the XML documents that they parse.
       * <br>
       * <b>NOTE:</b> if a parser cannot be created by this factory that
       *     satisfies the requested validation capacity, a
       *     <code>ParserConfigurationException</code> will be thrown when
       *     the application attempts to aquire the parser via the
       *     <code>newDocumentBuilder()</code> method.
       */
      public void setValidating(boolean validating) {
          this.validation=validating;
      }
  
      /**
       * Indicates if this <code>DocumentBuilderFactory</code> is configured to
       * produce parsers that are namespace aware or not.
       */
      public boolean isNamespaceAware() {
          return(this.namespaces);
      }
  
      /**
       * Indicates if this <code>DocumentBuilderFactory</code> is configured to
       * produce parsers that validate XML documents as they are parsed.
       */
      public boolean isValidating() {
          return(this.validation);
      }
  }
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/FactoryConfigurationError.java
  
  Index: FactoryConfigurationError.java
  ===================================================================
  /*
   * 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 "Xerces" 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) 1999-2000, Pierpaolo
   * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package javax.xml.parsers;
  
  /**
   * This error is thrown if there is a configuration problem when creating
   * new factory instances.
   * <br>
   * This error will also be thrown when the class of a Factory specified by
   * a system property, or the class of the default system parser factory,
   * cannot be loaded or instantiated.
   * <br>
   * Implementation or Application developers should never need to directly
   * construct or catch errors of this type.
   * <br>
   * <br>
   * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
   *   IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
   *   REQUEST 5 FOUND AT
   *   <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
   *   http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
   *   </a><br>
   *   THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
   *   SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
   *   PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
   *   <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
   * <br>
   * <br>
   * <b>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 AUTHOR 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.
   *
   * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
   * @author Copyright &copy; 2000 The Apache Software Foundation.
   * @version 1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $
   */
  public class FactoryConfigurationError extends Error {
  
      /** The root cause of this <code>FactoryConfigurationError</code>. */
      private Exception exception=null;
  
      /**
       * Constructs a new <code>FactoryConfigurationError</code> with no
       * detail message.
       */
      public FactoryConfigurationError() {
          this(null,null);
      }
  
      /**
       * Constructs a new <code>FactoryConfigurationError</code> with the
       * given detail message.
       */
      public FactoryConfigurationError(String msg) {
          this(null,msg);
      }
  
      /**
       * Constructs a new <code>FactoryConfigurationError</code> with the
       * given <code>Exception</code> as a root cause.
       */
      public FactoryConfigurationError(Exception e) {
          this(e,null);
      }
  
      /**
       * Constructs a new <code>FactoryConfigurationError</code> with the
       * given <code>Exception</code> as a root cause and the given detail
       * message.
       */
      public FactoryConfigurationError(Exception e, String msg) {
          super(msg);
          this.exception=e;
      }
  
      /**
       * Returns the root cause of this <code>FactoryConfigurationError</code>
       * or <b>null</b> if there is none.
       */
      public Exception getException() {
          return(this.exception);
      }
  }
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/ParserConfigurationException.java
  
  Index: ParserConfigurationException.java
  ===================================================================
  /*
   * 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 "Xerces" 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) 1999-2000, Pierpaolo
   * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package javax.xml.parsers;
  
  /**
   * This exception is thrown if a factory cannot configure a parser given its
   * current configuration parameters.
   * <br>
   * For example, if a parser factory cannot create parsers that validate,
   * but have been configured to do so, it will throw this exception when a
   * parser is requested to via the parser creation methods.
   * <br>
   * Application developers are not expected to construct instances of this
   * exception type, but must catch them in code that obtains parser instances
   * from a factory.
   * <br>
   * <br>
   * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
   *   IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
   *   REQUEST 5 FOUND AT
   *   <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
   *   http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
   *   </a><br>
   *   THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
   *   SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
   *   PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
   *   <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
   * <br>
   * <br>
   * <b>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 AUTHOR 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.
   *
   * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
   * @author Copyright &copy; 2000 The Apache Software Foundation.
   * @version 1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $
   */
  public class ParserConfigurationException extends Exception {
  
      /**
       * Constructs a new <code>ParserConfigurationException</code> with no
       * detail message.
       */
      public ParserConfigurationException() {
          super();
      }
  
      /**
       * Constructs a new <code>ParserConfigurationException</code> with the
       * given detail message.
       */
      public ParserConfigurationException(String msg) {
          super(msg);
      }
  }
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/SAXParser.java
  
  Index: SAXParser.java
  ===================================================================
  /*
   * 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 "Xerces" 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) 1999-2000, Pierpaolo
   * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package javax.xml.parsers;
  
  import java.io.File;
  import java.io.InputStream;
  import java.io.IOException;
  import org.xml.sax.HandlerBase;
  import org.xml.sax.InputSource;
  import org.xml.sax.Parser;
  import org.xml.sax.SAXException;
  
  /**
   * Implementation instances of the <code>SAXParser</code> abstract class
   * contain an implementation of the <code>org.xml.sax.Parser</code> interface
   * and enables content from a variety of sources to be parsed using the
   * contained parser.
   * <br>
   * Instances of <code>SAXParser</code> are obtained from a
   * <code>SAXParserFactory</code> by invoking its <code>newSAXParser()</code>
   * method.
   * <br>
   * <br>
   * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
   *   IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
   *   REQUEST 5 FOUND AT
   *   <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
   *   http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
   *   </a><br>
   *   THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
   *   SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
   *   PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
   *   <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
   * <br>
   * <br>
   * <b>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 AUTHOR 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.
   *
   * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
   * @author Copyright &copy; 2000 The Apache Software Foundation.
   * @version 1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $
   */
  public abstract class SAXParser {
  
      /**
       * Implementations should provide a protected constructor so that 
       * their factory implementation can instantiate instances of the 
       * implementation class.
       * <br>
       * Application programmers should not be able to directly construct 
       * implementation subclasses of this abstract subclass. The only way a 
       * application should be able to obtain a reference to a SAXParser 
       * implementation instance is by using the appropriate methods of the 
       * <code>SAXParserFactory</code>.
       */
      protected SAXParser() {
          super();
      }
  
      /**
       * Parses the contents of the given <code>InputStream</code> as an XML
       * document using the specified <code>HandlerBase</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException If any IO errors occur reading the given
       *                <code>InputStream</code>.
       * @exception  IllegalArgumentException If the given
       *                <code>InputStream</code> is <b>null</b>.
       */
      public void parse(InputStream stream, HandlerBase base)
      throws SAXException, IOException, IllegalArgumentException {
          if (stream==null) throw new IllegalArgumentException();
          this.parse(new InputSource(stream),base);
      }
  
      /**
       * Parses the content of the given URI as an XML document using the
       * specified <code>HandlerBase</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException If any IO errors occur while reading content
       *                located by the given URI.
       * @exception IllegalArgumentException If the given URI is <b>null</b>.
       */
      public void parse(String uri, HandlerBase base)
      throws SAXException, IOException, IllegalArgumentException {
          if (uri==null) throw new IllegalArgumentException();
          this.parse(new InputSource(uri),base);
      }
  
      /**
       * Parses the content of the given <code>File</code> as an XML document
       * using the specified <code>HandlerBase</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException if any IO errors occur while reading content
       *                from the given <code>File</code>.
       * @exception IllegalArgumentException if the given <code>File</code> is
       *                <b>null</b>.
       */
      public void parse(File file, HandlerBase base)
      throws SAXException, IOException, IllegalArgumentException {
          if (file==null) throw new IllegalArgumentException();
          String path = file.getAbsolutePath();
          if (File.separatorChar != '/') {
              path = path.replace(File.separatorChar, '/');
          }
          if (!path.startsWith("/")) {
              path = "/" + path;
          }
          if (!path.endsWith("/") && file.isDirectory()) {
              path = path + "/";
          }
          java.net.URL url = new java.net.URL("file", "", path);
          this.parse(new InputSource(url.toString()),base);
      }
  
      /**
       * Parses the content of the given <code>InputSource</code> as an XML
       * document using the specified <code>HandlerBase</code> object.
       *
       * @exception SAXException If there is a problem parsing the given XML
       *                content.
       * @exception IOException if any IO Errors occur while reading content
       *                from the given <code>InputSource</code>.
       * @exception IllegalArgumentException if the given
       *                <code>InputSource</code> is <b>null</b>.
       */
      public void parse(InputSource source, HandlerBase base)
      throws SAXException, IOException, IllegalArgumentException {
          if (source==null) throw new IllegalArgumentException();
  
          // Get the SAX parser instance
          Parser p=this.getParser();
  
          // Set the various handler instances
          if (base!=null) {
              p.setDocumentHandler(base);
              p.setDTDHandler(base);
              p.setEntityResolver(base);
              p.setErrorHandler(base);
          }
  
          // Parse the specified source
          p.parse(source);
      }
  
      /**
       * Returns the underlying <code>Parser</code> object which is wrapped by
       * this <code>SAXParser</code> implementation.
       *
       * @exception SAXException If the initialization of the underlying parser
       *                fails. <b>NOTE:</b> This Exception is specified on page
       *                21 of the specification, but later on omissed in this
       *                method documentation on page 23. Wich one is correct?
       */
      public abstract Parser getParser()
      throws SAXException;
  
      /**
       * Returns whether or not this parser supports XML namespaces.
       */
      public abstract boolean isNamespaceAware();
  
      /**
       * Returns whether or not this parser supports validating XML content.
       */
      public abstract boolean isValidating();
  }
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/SAXParserFactory.java
  
  Index: SAXParserFactory.java
  ===================================================================
  /*
   * 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 "Xerces" 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) 1999-2000, Pierpaolo
   * Fumagalli <ma...@betaversion.org>, http://www.apache.org.
   * For more information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package javax.xml.parsers;
  
  import org.xml.sax.SAXException;
  
  /**
   * The <code>SAXParserFactory</code> defines a factory API that enables
   * applications to configure and obtain a SAX based parser to parse XML
   * documents.
   * <br>
   * <br>
   * <b>ATTENTION:</b> THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
   *   IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
   *   REQUEST 5 FOUND AT
   *   <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
   *   http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
   *   </a><br>
   *   THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
   *   SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
   *   PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
   *   <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
   * <br>
   * <br>
   * <b>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 AUTHOR 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.
   *
   * @author <a href="pier@betaversion.org">Pierpaolo Fumagalli</a>
   * @author Copyright &copy; 2000 The Apache Software Foundation.
   * @version 1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $
   */
  public abstract class SAXParserFactory {
  
      /** Wether the SAXParser to be generated must support namespaces. */
      private boolean namespaces=false;
      /** Wether the SAXParser to be generated must support validataion. */
      private boolean validation=false;
      /** The system property to check for the SAXParserFactory class name. */
      private static String property="javax.xml.parsers.SAXParserFactory";
      /** The default SAXParserFactory implementation class name. */
      private static String factory="org.apache.xerces.jaxp.SAXParserFactoryImpl";
  
      /**
       * Implementors of this abstract class <b>must</b> provide their own
       * public no-argument constructor in order for the static
       * <code>newInstance()</code> method to work correctly.
       * <br>
       * Application programmers should be able to instantiate an implementation
       * of this abstract class directly if they want to use a specfic
       * implementation of this API without using the static newInstance method
       * to obtain the configured or platform default implementation.
       */
      protected SAXParserFactory() {
          super();
      }
  
      /**
       * Returns a new instance of a <code>SAXParserFactory</code>.
       * <br>
       * The implementation of the SAX-ParserFactory returned depends on the
       * setting of the <code>javax.xml.parsers.SAXParserFactory</code>
       * system property or, if the property is not set, a platform specific
       * default.
       *
       * @exception FactoryConfigurationError If the class implementing the
       *                factory cannot be found or instantiated.
       *                An <code>Error</code> is thrown instead of an exception
       *                because the application is not expected to handle or
       *                recover from such events.
       */
      public static SAXParserFactory newInstance() {
  
          // Retrieve the javax.xml.parsers.SAXParserFactory system property
          String n=factory;
          try {
              n=System.getProperty(property, factory);
          } catch (SecurityException e) {
          	// In applets System.getProperty throws a SecurityException.
          	// Thanks to Aaron Buchanan <ab...@inovacorp.com> and to
          	// James Duncan Davidson <ja...@eng.sun.com> for this
          	n=factory;
          }
  
          try {
              // Attempt to load, instantiate and return the factory class
              return (SAXParserFactory)Class.forName(n).newInstance();
  
          } catch (ClassNotFoundException e) {
              // The factory class was not found
              throw new FactoryConfigurationError("Cannot load class "+
                  "SAXParserFactory class \""+n+"\"");
  
          } catch (InstantiationException e) {
              // The factory class wasn't instantiated
              throw new FactoryConfigurationError("Cannot instantiate the "+
                  "specified SAXParserFactory class \""+n+"\"");
  
          } catch (IllegalAccessException e) {
              // The factory class couldn't have been accessed
              throw new FactoryConfigurationError("Cannot access the specified "+
                  "SAXParserFactory class \""+n+"\"");
  
          } catch (ClassCastException e) {
              // The factory class was not a SAXParserFactory
              throw new FactoryConfigurationError("The specified class \""+n+
                  "\" is not instance of \"javax.xml.parsers.SAXParserFactory\"");
          }
      }
  
      /**
       * Returns a new configured instance of type <code>SAXParser</code>.
       *
       * @exception ParserConfigurationException If the <code>SAXParser</code>
       *                instance cannot be created with the requested
       *                configuration.
       * @exception SAXException If the initialization of the underlying parser
       *                fails.
       */
      public abstract SAXParser newSAXParser()
      throws ParserConfigurationException, SAXException;
  
      /**
       * Configuration method that specifies whether the parsers created by this
       * factory are required to provide XML namespace support or not.
       * <br>
       * <b>NOTE:</b> if a parser cannot be created by this factory that
       *     satisfies the requested namespace awareness value, a
       *     <code>ParserConfigurationException</code> will be thrown when the
       *     program attempts to aquire the parser calling the
       *     <code>newSaxParser()</code> method.
       */
      public void setNamespaceAware(boolean aware) {
          this.namespaces=aware;
      }
  
      /**
       * Configuration method whether specifies if the parsers created by this
       * factory are required to validate the XML documents that they parse.
       * <br>
       * <b>NOTE:</b> if a parser cannot be created by this factory that
       *     satisfies the requested validation capacity, a
       *     <code>ParserConfigurationException</code> will be thrown when
       *     the application attempts to aquire the parser via the
       *     <code>newSaxParser()</code> method.
       */
      public void setValidating(boolean validating) {
          this.validation=validating;
      }
  
      /**
       * Indicates if this <code>SAXParserFactory</code> is configured to
       * produce parsers that are namespace aware or not.
       */
      public boolean isNamespaceAware() {
          return(this.namespaces);
      }
  
      /**
       * Indicates if this <code>SAXParserFactory</code> is configured to
       * produce parsers that validate XML documents as they are parsed.
       */
      public boolean isValidating() {
          return(this.validation);
      }
  }
  
  
  
  1.1                  xml-xalan/java/src/javax/xml/parsers/package.html
  
  Index: package.html
  ===================================================================
  <!-- CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $ -->
  <html>
   <body>
    This package provides a Plugability mechanism to allow a compliant SAX or
    DOM parser to be used indipendently by an application.
  
    <dl>
     <dt><b>Version: </b><dd>1.0 CVS $Revision: 1.1 $ $Date: 2000/10/02 02:43:03 $</dd>
     <dt><b>Author: </b>
       <dd><a href="pier@betaversion.org">Pierpaolo Fumagalli</a></dd>
     <dt><b>Copyright:</b>
       <dd>Copyright &copy; 2000 The Apache Software Foundation.</dd>
    </dl>
  
    <b>ATTENTION:</b>THIS IMPLEMENTATION OF THE "JAVAX.XML.PARSER" CLASSES
    IS NOT THE OFFICIAL REFERENCE IMPLEMENTATION OF THE JAVA SPECIFICATION
    REQUEST 5 FOUND AT
    <a href="http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html">
    http://java.sun.com/aboutJava/communityprocess/jsr/jsr_005_xml.html
    </a>
    <br>
    THIS IMPLEMENTATION IS CONFORMANT TO THE "JAVA API FOR XML PARSING"
    SPECIFICATION VERSION 1.0 PUBLIC RELEASE 1 BY JAMES DUNCAN DAVIDSON
    PUBLISHED BY SUN MICROSYSTEMS ON FEB. 18, 2000 AND FOUND AT
    <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>
    <br>
    <br>
    <b>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 AUTHOR 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.
   </body>
  </html>
  
  
  
  1.3       +15 -21    xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java
  
  Index: XSLTProcessorApplet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSLTProcessorApplet.java	2000/08/02 19:08:12	1.2
  +++ XSLTProcessorApplet.java	2000/10/02 02:43:04	1.3
  @@ -75,9 +75,6 @@
   import org.apache.xalan.stree.SourceTreeHandler;
   import org.apache.xalan.transformer.TransformerImpl;
   
  -// Needed Xerces classes
  -import org.apache.xerces.parsers.DOMParser;
  -
   // Needed TRaX classes
   import trax.Result;
   import trax.Processor;
  @@ -100,9 +97,9 @@
   import org.w3c.dom.Document;
   
   // Needed Serializer classes
  -import org.apache.xml.serialize.OutputFormat;
  -import org.apache.xml.serialize.Serializer;
  -import org.apache.xml.serialize.SerializerFactory;
  +import serialize.OutputFormat;
  +import serialize.Serializer;
  +import serialize.SerializerFactory;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -294,14 +291,6 @@
      
     protected void initLiaison()
     {
  -    try
  -    { 
  -    }
  -    catch(Exception se)
  -    {
  -      se.printStackTrace();
  -      throw new RuntimeException(se.getMessage());
  -    }
     }
     
    /**
  @@ -433,10 +422,13 @@
   	    Templates templates = m_templatesBuilder.getTemplates();
   	    TransformerImpl transformer = (TransformerImpl)templates.newTransformer();
         
  -	    Result result = new Result(pw);
  -	    org.xml.sax.ContentHandler handler = 
  -		   new org.apache.xml.serialize.HTMLSerializer(pw, new OutputFormat()).asContentHandler();
  -	  
  +      // Result result = new Result(pw);
  +      serialize.Serializer serializer 
  +        = serialize.SerializerFactory.getSerializer( "HTML" );
  +      serializer.setWriter(pw);
  +      org.xml.sax.ContentHandler handler = serializer.asContentHandler();
  +       // new org.apache.xml.serialize.HTMLSerializer(pw, new OutputFormat()).asContentHandler();
  +                                       
           transformer.setContentHandler(handler);
   	    transformer.setParent(m_reader);
           transform(transformer, new InputSource(xmlbuf));
  @@ -735,9 +727,11 @@
         
         if(null != m_key)
           transformer.setParameter(m_key, null, m_expression);
  -	  Result result = new Result(pw);
  -	  org.xml.sax.ContentHandler handler = 
  -		 new org.apache.xml.serialize.HTMLSerializer(pw, new OutputFormat()).asContentHandler();
  +      // Result result = new Result(pw);
  +      serialize.Serializer serializer 
  +        = serialize.SerializerFactory.getSerializer( "HTML" );
  +      serializer.setWriter(pw);
  +      org.xml.sax.ContentHandler handler = serializer.asContentHandler();
   	  
         transformer.setContentHandler(handler);
   	  transformer.setParent(m_reader);
  
  
  
  1.4       +1 -1      xml-xalan/java/src/org/apache/xalan/lib/Redirect.java
  
  Index: Redirect.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Redirect.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Redirect.java	2000/08/01 04:46:48	1.3
  +++ Redirect.java	2000/10/02 02:43:06	1.4
  @@ -61,7 +61,7 @@
   import java.net.URL;
   import org.w3c.dom.*;
   import org.xml.sax.ContentHandler;
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   import org.apache.xalan.extensions.XSLProcessorContext;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xalan.templates.StylesheetRoot;
  
  
  
  1.2       +1 -1      xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java
  
  Index: ProcessorOutputElem.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorOutputElem.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProcessorOutputElem.java	2000/06/19 16:52:07	1.1
  +++ ProcessorOutputElem.java	2000/10/02 02:43:06	1.2
  @@ -56,7 +56,7 @@
    */
   package org.apache.xalan.processor;
   
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   import java.util.Hashtable;
   import org.apache.xalan.templates.OutputFormatExtended;
   import org.apache.xalan.templates.StylesheetRoot;
  
  
  
  1.8       +24 -5     xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java
  
  Index: SourceTreeHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SourceTreeHandler.java	2000/08/11 23:54:57	1.7
  +++ SourceTreeHandler.java	2000/10/02 02:43:07	1.8
  @@ -1,5 +1,6 @@
   package org.apache.xalan.stree;
   
  +import java.util.Stack;
   import org.w3c.dom.Node;
   import org.xml.sax.ContentHandler;
   import org.apache.xalan.utils.DOMBuilder;
  @@ -132,8 +133,7 @@
       ((DocumentImpl)m_root).setUseMultiThreading(getUseMultiThreading());
   
       m_sourceTreeHandler = new StreeDOMBuilder(m_root);
  -    setShouldStripWhitespace(false);
  -    
  +    pushShouldStripWhitespace(false);    
       if(m_useMultiThreading && (null != m_transformer))
       {
         /*
  @@ -158,6 +158,7 @@
     {
       ((Parent)m_root).setComplete(true);    
       m_sourceTreeHandler.endDocument();
  +    popShouldStripWhitespace();    
       
       if(!m_useMultiThreading && (null != m_transformer))
       {
  @@ -172,6 +173,7 @@
                               String name, Attributes atts)
       throws SAXException
     {
  +    pushShouldStripWhitespace(getShouldStripWhitespace());
       m_sourceTreeHandler.startElement(ns, localName, name, atts);
     }
   
  @@ -184,6 +186,7 @@
     {
       ((Parent)m_sourceTreeHandler.getCurrentNode()).setComplete(true);
       m_sourceTreeHandler.endElement(ns, localName, name);
  +    popShouldStripWhitespace();    
     }
   
     private boolean m_isCData = false;
  @@ -440,16 +443,32 @@
     {
     }
     
  -  private boolean m_shouldStripWhitespace = false;
  +  static private Boolean S_TRUE = new Boolean(true);
  +  static private Boolean S_FALSE = new Boolean(false);
  +                                              
  +  private Stack m_shouldStripWhitespace = new Stack();
     
     boolean getShouldStripWhitespace()
  +  {
  +    return (m_shouldStripWhitespace.empty() ? 
  +            false : (m_shouldStripWhitespace.peek() == S_TRUE));
  +  }
  +  
  +  void pushShouldStripWhitespace(boolean shouldStrip)
     {
  -    return m_shouldStripWhitespace;
  +    m_shouldStripWhitespace.push(shouldStrip ? S_TRUE : S_FALSE);
     }
     
  +  void popShouldStripWhitespace()
  +  {
  +    m_shouldStripWhitespace.pop();
  +  }
  +  
     void setShouldStripWhitespace(boolean shouldStrip)
     {
  -    m_shouldStripWhitespace = shouldStrip;
  +    popShouldStripWhitespace();
  +    pushShouldStripWhitespace(shouldStrip);
     }
  +
   
   }
  
  
  
  1.8       +2 -2      xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java
  
  Index: ElemTemplateElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTemplateElement.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ElemTemplateElement.java	2000/09/20 23:33:10	1.7
  +++ ElemTemplateElement.java	2000/10/02 02:43:07	1.8
  @@ -81,8 +81,8 @@
   import trax.Templates;
   
   // Serializer imports
  -import org.apache.xml.serialize.OutputFormat;
  -import org.apache.xml.serialize.Serializer;
  +import serialize.OutputFormat;
  +import serialize.Serializer;
   
   // DOM Imports
   import org.w3c.dom.Node;
  
  
  
  1.2       +5 -5      xml-xalan/java/src/org/apache/xalan/templates/ElemTextLiteral.java
  
  Index: ElemTextLiteral.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTextLiteral.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ElemTextLiteral.java	2000/06/19 16:52:50	1.1
  +++ ElemTextLiteral.java	2000/10/02 02:43:07	1.2
  @@ -191,14 +191,14 @@
     {
       if(TransformerImpl.S_DEBUG)
         transformer.getTraceManager().fireTraceEvent(sourceNode, mode, this);
  -
  -    if(!m_disableOutputEscaping)
  +    if(m_disableOutputEscaping)
       {
  -      transformer.getResultTreeHandler().characters(m_ch, 0, m_ch.length);
  +      transformer.getResultTreeHandler().startNonEscaping();
       }
  -    else
  +    transformer.getResultTreeHandler().characters(m_ch, 0, m_ch.length);
  +    if(m_disableOutputEscaping)
       {
  -      transformer.getResultTreeHandler().charactersRaw(m_ch, 0, m_ch.length);
  +      transformer.getResultTreeHandler().endNonEscaping();
       }
     }
   }
  
  
  
  1.3       +10 -8     xml-xalan/java/src/org/apache/xalan/templates/ElemValueOf.java
  
  Index: ElemValueOf.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemValueOf.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemValueOf.java	2000/07/05 14:40:21	1.2
  +++ ElemValueOf.java	2000/10/02 02:43:07	1.3
  @@ -226,13 +226,14 @@
           int len = s.length();
           if(len > 0)
           {
  -          if(!m_disableOutputEscaping)
  +          if(m_disableOutputEscaping)
             {
  -            transformer.getResultTreeHandler().characters(s.toCharArray(), 0, s.length());
  +            transformer.getResultTreeHandler().startNonEscaping();
             }
  -          else
  +          transformer.getResultTreeHandler().characters(s.toCharArray(), 0, s.length());
  +          if(m_disableOutputEscaping)
             {
  -            transformer.getResultTreeHandler().charactersRaw(s.toCharArray(), 0, s.length());
  +            transformer.getResultTreeHandler().endNonEscaping();
             }
           }
         }
  @@ -257,13 +258,14 @@
               int len = s.length();
               if(len > 0)
               {
  -              if(!m_disableOutputEscaping)
  +              if(m_disableOutputEscaping)
                 {
  -                transformer.getResultTreeHandler().characters(s.toCharArray(), 0, s.length());
  +                transformer.getResultTreeHandler().startNonEscaping();
                 }
  -              else
  +              transformer.getResultTreeHandler().characters(s.toCharArray(), 0, s.length());
  +              if(m_disableOutputEscaping)
                 {
  -                transformer.getResultTreeHandler().charactersRaw(s.toCharArray(), 0, s.length());
  +                transformer.getResultTreeHandler().endNonEscaping();
                 }
               }
             }
  
  
  
  1.5       +44 -23    xml-xalan/java/src/org/apache/xalan/templates/OutputFormatExtended.java
  
  Index: OutputFormatExtended.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/OutputFormatExtended.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- OutputFormatExtended.java	2000/07/18 01:32:22	1.4
  +++ OutputFormatExtended.java	2000/10/02 02:43:07	1.5
  @@ -56,7 +56,7 @@
    */
   package org.apache.xalan.templates;
   
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   import java.util.Vector;
   import org.w3c.dom.Document;
   
  @@ -125,11 +125,16 @@
      */
     public OutputFormatExtended( String method, String encoding, boolean indenting )
     {
  -    super(method, encoding, indenting);
  +    // super(method, encoding, indenting);
  +    if(null != method)
  +      super.setMethod(method);
  +    if(null != encoding)
  +      super.setEncoding(encoding);
  +    super.setIndent(indenting);
       m_shouldRecordHasBeenSet = true;
     }
   
  -  /**
  +  /*
      * Constructs a new output format with the proper method,
      * document type identifiers and media type for the specified
      * document.
  @@ -137,11 +142,12 @@
      * @param doc The document to output
      * @see #whichMethod
      */
  -  public OutputFormatExtended( Document doc )
  -  {
  -    super(doc);
  -    m_shouldRecordHasBeenSet = true;
  -  }
  +  // public OutputFormatExtended( Document doc )
  +  // {
  +    // super(doc);
  +    // super();
  +    // m_shouldRecordHasBeenSet = true;
  +  // }
     
     /**
      * Constructs a new output format with the proper method,
  @@ -157,11 +163,11 @@
      * @see #setIndenting
      * @see #whichMethod
      */
  -  public OutputFormatExtended( Document doc, String encoding, boolean indenting )
  -  {
  -    super(doc, encoding, indenting);
  -    m_shouldRecordHasBeenSet = true;
  -  }
  +  // public OutputFormatExtended( Document doc, String encoding, boolean indenting )
  +  // {
  +    // super(doc, encoding, indenting);
  +    // m_shouldRecordHasBeenSet = true;
  +  // }
     
     /**
      * The doctype-public attribute.
  @@ -170,7 +176,8 @@
     {
       if(m_shouldRecordHasBeenSet)
         m_doctypePublicHasBeenSet = true;
  -    super.setDoctype(publicId, this.getDoctypeSystem());
  +    super.setDoctypePublicId(publicId);
  +    // super.setDoctype(publicId, this.getDoctypeSystem());
     }
   
     /**
  @@ -180,7 +187,8 @@
     {
       if(m_shouldRecordHasBeenSet)
         m_doctypeSystemHasBeenSet = true;
  -    super.setDoctype(this.getDoctypePublic(), systemId);
  +    // super.setDoctype(this.getDoctypePublic(), systemId);
  +    super.setDoctypeSystemId(systemId);
     }
     
     /**
  @@ -200,12 +208,23 @@
     {
       if(m_shouldRecordHasBeenSet)
         m_cdataElementsHasBeenSet = true;
  -    // TO DO: I have to work something out with Assaf!
       int n = elements.size();
  -    String elems[] = new String[n];
  +    serialize.QName[] qnames = new QName[n];
       for(int i = 0; i < n; i++)
  -      elems[i] = elements.elementAt(i).toString();
  -    super.setCDataElements(elems);
  +    {
  +      qnames[i] = (QName)elements.elementAt(i);
  +    }
  +    super.setCDataElements(qnames);
  +  }
  +  
  +  /**
  +   * The cdata-section-elements attribute.
  +   */
  +  public void setCdataSectionElements(serialize.QName[] elements)
  +  {
  +    if(m_shouldRecordHasBeenSet)
  +      m_cdataElementsHasBeenSet = true;
  +    super.setCDataElements(elements);
     }
     
     /**
  @@ -271,7 +290,7 @@
     {
       // System.out.println("setIndent( "+indent+" )");
       // setPreserveSpace(false);
  -    setIndenting(indent);
  +    setIndent(indent);
     }
   
     /**
  @@ -287,7 +306,9 @@
       // System.out.println("setIndent( int indent )");
       if(m_shouldRecordHasBeenSet)
         m_indentHasBeenSet = true;
  -    super.setIndent(indent);
  +    // For the moment, there doesn't seem to be a way 
  +    // to set the indenting amount.
  +    // super.setIndent(indent);
     }
   
     /**
  @@ -305,7 +326,7 @@
       if(m_shouldRecordHasBeenSet)
         m_indentingHasBeenSet = true;
       setPreserveSpace(!on);
  -    super.setIndenting(on);
  +    super.setIndent(on);
     }
   
     /**
  @@ -370,7 +391,7 @@
      *
      * @param nonEscapingElements List of unescaped element tag names
      */
  -  public void setNonEscapingElements( String[] nonEscapingElements )
  +  public void setNonEscapingElements( serialize.QName[] nonEscapingElements )
     {
       // TODO: Need to work on this.
       if(m_shouldRecordHasBeenSet)
  
  
  
  1.8       +1 -1      xml-xalan/java/src/org/apache/xalan/templates/StylesheetComposed.java
  
  Index: StylesheetComposed.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetComposed.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StylesheetComposed.java	2000/09/20 23:33:10	1.7
  +++ StylesheetComposed.java	2000/10/02 02:43:07	1.8
  @@ -62,7 +62,7 @@
   import trax.ProcessorException;
   import org.apache.xpath.XPath;
   import org.apache.xalan.utils.QName;
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xpath.XPathContext;
   import org.w3c.dom.Node;
  
  
  
  1.8       +10 -11    xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java
  
  Index: StylesheetRoot.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StylesheetRoot.java	2000/08/10 23:30:48	1.7
  +++ StylesheetRoot.java	2000/10/02 02:43:07	1.8
  @@ -63,7 +63,7 @@
   import org.xml.sax.*;
   import org.xml.sax.helpers.*;
   
  -import org.apache.xml.serialize.*;
  +import serialize.*;
   
   import org.apache.xalan.utils.*;
   import org.apache.xpath.*;
  @@ -152,13 +152,14 @@
       OutputFormat cloned = new OutputFormatExtended();
       cloned.setPreserveSpace(true);
       cloned.setCDataElements(m_outputFormatComposed.getCDataElements());
  -    cloned.setDoctype(m_outputFormatComposed.getDoctypePublic(), m_outputFormatComposed.getDoctypeSystem());
  +    cloned.setDoctypePublicId(m_outputFormatComposed.getDoctypePublicId());
  +    // cloned.setDoctype(m_outputFormatComposed.getDoctypePublic(), m_outputFormatComposed.getDoctypeSystem());
       cloned.setEncoding(m_outputFormatComposed.getEncoding());
       // System.out.println("getOutputFormat - m_outputFormatComposed.getIndent(): "+ m_outputFormatComposed.getIndent());
  +    // cloned.setIndent(m_outputFormatComposed.getIndent());
       cloned.setIndent(m_outputFormatComposed.getIndent());
  -    cloned.setIndenting(m_outputFormatComposed.getIndenting());
  -    cloned.setLineSeparator(m_outputFormatComposed.getLineSeparator());
  -    cloned.setLineWidth(m_outputFormatComposed.getLineWidth());
  +    // cloned.setLineSeparator(m_outputFormatComposed.getLineSeparator());
  +    // cloned.setLineWidth(m_outputFormatComposed.getLineWidth());
       cloned.setMediaType(m_outputFormatComposed.getMediaType());
       cloned.setMethod(m_outputFormatComposed.getMethod());
       cloned.setNonEscapingElements(m_outputFormatComposed.getNonEscapingElements());
  @@ -281,19 +282,17 @@
         if(of.cdataElementsHasBeenSet())
           m_outputFormatComposed.setCDataElements(of.getCDataElements());
         if(of.doctypePublicHasBeenSet())
  -        m_outputFormatComposed.setDoctype(of.getDoctypePublic(), 
  -                                          m_outputFormatComposed.getDoctypeSystem());
  +        m_outputFormatComposed.setDoctypePublicId(of.getDoctypePublicId());
         if(of.doctypeSystemHasBeenSet())
  -        m_outputFormatComposed.setDoctype(m_outputFormatComposed.getDoctypePublic(), 
  -                                          of.getDoctypeSystem());
  +        m_outputFormatComposed.setDoctypePublicId(of.getDoctypeSystemId());
         if(of.encodingHasBeenSet())
           m_outputFormatComposed.setEncoding(of.getEncoding());
         if(of.indentHasBeenSet())
           m_outputFormatComposed.setIndent(of.getIndent());
         if(of.indentingHasBeenSet())
         {
  -        boolean indent = of.getIndenting();
  -        m_outputFormatComposed.setIndenting(indent);
  +        boolean indent = of.getIndent();
  +        m_outputFormatComposed.setIndent(indent);
           m_outputFormatComposed.setPreserveSpace(!indent);
         }
         if(of.mediaTypeHasBeenSet())
  
  
  
  1.11      +72 -106   xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java
  
  Index: ResultTreeHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ResultTreeHandler.java	2000/09/27 16:21:41	1.10
  +++ ResultTreeHandler.java	2000/10/02 02:43:08	1.11
  @@ -68,7 +68,6 @@
   import org.xml.sax.helpers.NamespaceSupport;
   import org.apache.xalan.utils.DOMBuilder;
   import org.apache.xalan.utils.TreeWalker;
  -import org.apache.xalan.utils.RawCharacterHandler;
   import org.apache.xalan.utils.MutableAttrListImpl;
   import org.apache.xalan.utils.StringToStringTable;
   import org.apache.xalan.utils.QName;
  @@ -77,13 +76,14 @@
   import org.apache.xalan.templates.Stylesheet;
   import org.apache.xalan.templates.StylesheetRoot;
   import org.apache.xalan.templates.ElemTemplateElement;
  -import org.apache.xml.serialize.SerializerFactory;
  -import org.apache.xml.serialize.OutputFormat;
  -import org.apache.xml.serialize.Method;
  +import serialize.SerializerFactory;
  +import serialize.OutputFormat;
  +import serialize.Method;
   import org.apache.xalan.trace.GenerateEvent;
   import org.apache.xpath.objects.XObject;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.DOMHelper;
  +import serialize.SerializerHandler;
   
   /**
    * This class is a layer between the direct calls to the result 
  @@ -95,7 +95,7 @@
    * can call startElement.
    */
   public class ResultTreeHandler 
  -  implements ContentHandler, RawCharacterHandler, LexicalHandler
  +  implements ContentHandler, SerializerHandler, LexicalHandler
   {
     /**
      * Create a new result tree handler.  The real content 
  @@ -501,69 +501,15 @@
       if(m_haveDocContent)
       {
         flushPending();
  -      /*
  -      if((null != m_stylesheetRoot.getCDataSectionElems()) &&
  -      !m_cdataStack.isEmpty() && (m_cdataStack.peek() == TRUE))
  -      {
  -      boolean isLexHandler = (m_flistener instanceof LexicalHandler);
  -      if(isLexHandler)
  -      ((LexicalHandler)m_flistener).startCDATA();
  -
  -      m_flistener.characters(ch, start, length);
  -
  -      if(isLexHandler)
  -      ((LexicalHandler)m_flistener).endCDATA();
  -
  -      if(null != m_traceListeners)
  -      fireGenerateEvent(new GenerateEvent(m_transformer,
  -      GenerateEvent.EVENTTYPE_CDATA,
  -      ch, start, length));
  -      }
  -      else
  -      */
       } 
       
       getContentHandler().characters(ch, start, length);
       m_transformer.getTraceManager().fireGenerateEvent(new GenerateEvent(m_transformer,
                                                                           GenerateEvent.EVENTTYPE_CHARACTERS,
                                                                           ch, start, length));
  -    
  -    
     }
   
     /**
  -   * Bottleneck the characters event.
  -   */
  -  public void charactersRaw (char ch[], int start, int length)
  -    throws SAXException
  -  {
  -    m_haveDocContent = true;
  -    flushPending();
  -    /*
  -    if(m_flistener instanceof org.apache.xml.serialize.BaseSerializer)
  -    {
  -    ((org.apache.xml.serialize.BaseSerializer)m_flistener).characters(new String( ch, start, length ), false, true);
  -    }
  -    else
  -    */
  -    if(getContentHandler() instanceof RawCharacterHandler)
  -    {
  -      ((RawCharacterHandler)getContentHandler()).charactersRaw(ch, start, length);
  -    }
  -    else if(getContentHandler() instanceof DOMBuilder)
  -    {
  -      ((DOMBuilder)getContentHandler()).charactersRaw(ch, start, length);
  -    }
  -    else
  -    {
  -      getContentHandler().characters(ch, start, length);
  -    }
  -    m_transformer.getTraceManager().fireGenerateEvent(new GenerateEvent(m_transformer,
  -                                                      GenerateEvent.EVENTTYPE_CHARACTERS,
  -                                                      ch, start, length));
  -  }
  -
  -  /**
      * Bottleneck the ignorableWhitespace event.
      */
     public void ignorableWhitespace (char ch[], int start, int length)
  @@ -695,55 +641,75 @@
         ((LexicalHandler)getContentHandler()).endDTD();
       }
     }
  -  
  +    
     /**
  -   * Tell if a given element name should output it's text
  -   * as cdata.
  -   * TODO: This is handling the cdata elems as strings instead
  -   * of qnames... this needs to be fixed.
  -   */
  -  boolean isCDataResultElem(String elementName)
  -  {
  -    boolean is = false;
  -    /*
  -    OutputFormat outputFormat = m_stylesheetRoot.getOutput();
  -    if(null == outputFormat)
  -      return is;
  -    String[] cdataElems = outputFormat.getCDataElements();
  -    if(null != cdataElems)
  -    {
  -      String elemNS = null;
  -      String elemLocalName = null;
  -      int indexOfNSSep = elementName.indexOf(':');
  -      if(indexOfNSSep > 0)
  -      {
  -        String prefix = elementName.substring(0, indexOfNSSep);
  -        if(prefix.equals("xml"))
  -        {
  -          elemNS = QName.S_XMLNAMESPACEURI;
  -        }
  -        else
  -        {
  -          elemNS = getURI(prefix);
  -        }
  -        if(null == elemNS)
  -        {
  -          throw new RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{prefix}));//"Prefix must resolve to a namespace: "+prefix);
  -        }
  -      }
  -      elemLocalName = (indexOfNSSep < 0) ? elementName : elementName.substring(indexOfNSSep+1);
  -      int n = cdataElems.length;
  -      for(int i = 0; i < n; i++)
  -      {
  -        // This needs to be a qname!
  -        QName qname = cdataElems[i];
  -        is = qname.equals(elemNS, elemLocalName);
  -        if(is)
  -          break;
  -      }
  +   * Starts an un-escaping section. All characters printed within an
  +   * un-escaping section are printed as is, without escaping special
  +   * characters into entity references. Only XML and HTML serializers
  +   * need to support this method.
  +   * <p>
  +   * The contents of the un-escaping section will be delivered through
  +   * the regular <tt>characters</tt> event.
  +   */
  +  public void startNonEscaping()
  +    throws SAXException
  +  {
  +    flushPending();
  +    if(getContentHandler() instanceof SerializerHandler)
  +    {
  +      ((SerializerHandler)getContentHandler()).startNonEscaping();
  +    }
  +  }
  +
  +  /**
  +   * Ends an un-escaping section.
  +   *
  +   * @see #startNonEscaping
  +   */
  +  public void endNonEscaping()
  +    throws SAXException
  +  {
  +    flushPending();
  +    if(getContentHandler() instanceof SerializerHandler)
  +    {
  +      ((SerializerHandler)getContentHandler()).endNonEscaping();
  +    }
  +  }
  +
  +  /**
  +   * Starts a whitespace preserving section. All characters printed
  +   * within a preserving section are printed without indentation and
  +   * without consolidating multiple spaces. This is equivalent to
  +   * the <tt>xml:space=&quot;preserve&quot;</tt> attribute. Only XML
  +   * and HTML serializers need to support this method.
  +   * <p>
  +   * The contents of the whitespace preserving section will be delivered
  +   * through the regular <tt>characters</tt> event.
  +   */
  +  public void startPreserving()
  +    throws SAXException
  +  {
  +    flushPending();
  +    if(getContentHandler() instanceof SerializerHandler)
  +    {
  +      ((SerializerHandler)getContentHandler()).startPreserving();
  +    }
  +  }
  +
  +
  +  /**
  +   * Ends a whitespace preserving section.
  +   *
  +   * @see #startPreserving
  +   */
  +  public void endPreserving()
  +    throws SAXException
  +  {
  +    flushPending();
  +    if(getContentHandler() instanceof SerializerHandler)
  +    {
  +      ((SerializerHandler)getContentHandler()).endPreserving();
       }
  -    */
  -    return is;
     }
   
     /**
  
  
  
  1.21      +13 -11    xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- TransformerImpl.java	2000/09/20 23:33:12	1.20
  +++ TransformerImpl.java	2000/10/02 02:43:08	1.21
  @@ -107,10 +107,10 @@
   import org.apache.xpath.DOM2Helper;
   
   // Serializer Imports
  -import org.apache.xml.serialize.OutputFormat;
  -import org.apache.xml.serialize.Serializer;
  -import org.apache.xml.serialize.SerializerFactory;
  -import org.apache.xml.serialize.Method;
  +import serialize.OutputFormat;
  +import serialize.Serializer;
  +import serialize.SerializerFactory;
  +import serialize.Method;
   
   // DOM Imports
   import org.w3c.dom.Attr;
  @@ -508,16 +508,16 @@
         String method = format.getMethod();
         if(null == method)
           method = Method.XML;
  -      SerializerFactory sfactory = SerializerFactory.getSerializerFactory(method);
         
         try
         {
           // System.out.println("createResultContentHandler -- format.getIndenting: "
           //                   +format.getIndenting());
  -        Serializer serializer 
  -          = (null != outputTarget.getCharacterStream()) ?
  -            sfactory.makeSerializer(outputTarget.getCharacterStream(), format) :
  -            sfactory.makeSerializer(outputTarget.getByteStream(), format);
  +        Serializer serializer = SerializerFactory.getSerializer(format);
  +        if(null != outputTarget.getCharacterStream())
  +          serializer.setWriter(outputTarget.getCharacterStream());
  +        else
  +          serializer.setOutputStream(outputTarget.getByteStream());
           handler = serializer.asContentHandler();
         }
         catch(UnsupportedEncodingException uee)
  @@ -901,11 +901,13 @@
       StringWriter sw;
       try
       {
  -      SerializerFactory sfactory = SerializerFactory.getSerializerFactory("text");
  +      // SerializerFactory sfactory 
  +      //  = SerializerFactory.getSerializerFactory("text");
         sw = new StringWriter();
         OutputFormat format = new OutputFormat();
         format.setPreserveSpace(true);
  -      Serializer serializer = sfactory.makeSerializer(sw, format);
  +      Serializer serializer = SerializerFactory.getSerializer(format);
  +      serializer.setWriter(sw);
         shandler = serializer.asContentHandler();
       }
       catch(IOException ioe)
  
  
  
  1.3       +40 -65    xml-xalan/java/src/org/apache/xalan/utils/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/utils/QName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QName.java	2000/07/05 14:44:04	1.2
  +++ QName.java	2000/10/02 02:43:09	1.3
  @@ -75,37 +75,28 @@
    * is used as the name of the object. The default namespace is not used for 
    * unprefixed names."
    */
  -public class QName implements java.io.Serializable
  +public class QName extends serialize.QName implements java.io.Serializable
   {
     /**
      * The XML namespace.
      */
     public static final String S_XMLNAMESPACEURI = "http://www.w3.org/XML/1998/namespace";
     
  -  /**
  -   * The namespace, which may be null.
  -   */
  -  private String m_namespace;
     
     /**
      * Get the namespace of the qualified name.
      */
     public String getNamespace()
     {
  -    return m_namespace;
  +    return getNamespaceURI();
     }
     
     /**
  -   * The local name.
  -   */
  -  private String m_localpart;
  -  
  -  /**
      * Get the local part of the qualified name.
      */
     public String getLocalPart()
     {
  -    return m_localpart;
  +    return getLocalName();
     }
   
     /**
  @@ -119,27 +110,8 @@
     public int hashCode()
     {
       return m_hashCode;
  -  }
  -  
  -  /**
  -   * Override equals and agree that we're equal if 
  -   * the passed object is a string and it matches 
  -   * the name of the arg.
  -   */
  -  public boolean equals(Object obj)
  -  {
  -    if(obj instanceof QName)
  -    {
  -      QName qname = (QName)obj;
  -      return m_localpart.equals(qname.m_localpart) 
  -             && (((null != m_namespace) && (null != qname.m_namespace)) 
  -             ? m_namespace.equals(qname.m_namespace)
  -               : ((null == m_namespace) && (null == qname.m_namespace)));
  -    }
  -          
  -    return false;
     }
  -  
  +    
     /**
      * Override equals and agree that we're equal if 
      * the passed object is a string and it matches 
  @@ -147,10 +119,11 @@
      */
     public boolean equals(String ns, String localPart)
     {
  -      return m_localpart.equals(localPart) 
  -             && (((null != m_namespace) && (null != ns)) 
  -             ? m_namespace.equals(ns)
  -               : ((null == m_namespace) && (null == ns)));
  +    String thisnamespace = getNamespaceURI();
  +    return getLocalName().equals(localPart) 
  +           && (((null != thisnamespace) && (null != ns)) 
  +               ? thisnamespace.equals(ns)
  +                 : ((null == thisnamespace) && (null == ns)));
     }
   
   
  @@ -161,10 +134,12 @@
      */
     public boolean equals(QName qname)
     {
  -    return m_localpart.equals(qname.m_localpart) 
  -           && (((null != m_namespace) && (null != qname.m_namespace)) 
  -           ? m_namespace.equals(qname.m_namespace)
  -             : ((null == m_namespace) && (null == qname.m_namespace)));
  +    String thisnamespace = getNamespaceURI();
  +    String thatnamespace = qname.getNamespaceURI();
  +    return getLocalName().equals(qname.getLocalName()) 
  +           && (((null != thisnamespace) && (null != thatnamespace)) 
  +           ? thisnamespace.equals(thatnamespace)
  +             : ((null == thisnamespace) && (null == thatnamespace)));
     }
     
     /**
  @@ -173,9 +148,7 @@
      */
     public QName(String localName)
     {
  -    m_namespace = null;
  -    
  -    m_localpart = localName;
  +    super(null, localName);
       m_hashCode = toString().hashCode();
     }
     
  @@ -184,9 +157,7 @@
      */
     public QName(String ns, String localName)
     {
  -    m_namespace = ns;
  -    
  -    m_localpart = localName;
  +    super(null, localName);
       m_hashCode = toString().hashCode();
     }
     
  @@ -236,15 +207,16 @@
      */
     public QName(String qname, Stack namespaces)
     {
  -    m_namespace = null;
  +    String namespace = null;
  +    String prefix = null;
   
       int indexOfNSSep = qname.indexOf(':');
       if(indexOfNSSep > 0)
       {
  -      String prefix = qname.substring(0, indexOfNSSep);
  +      prefix = qname.substring(0, indexOfNSSep);
         if(prefix.equals("xml"))
         {
  -        m_namespace = S_XMLNAMESPACEURI;
  +        namespace = S_XMLNAMESPACEURI;
         }
         else if(prefix.equals("xmlns"))
         {
  @@ -260,7 +232,7 @@
             {
               if((null != ns.m_prefix) && prefix.equals(ns.m_prefix))
               {
  -              m_namespace = ns.m_uri;
  +              namespace = ns.m_uri;
                 i = -1;
                 break;
               }
  @@ -268,12 +240,14 @@
             }
           }
         }  
  -      if(null == m_namespace)
  +      if(null == namespace)
         {
           throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{prefix})); //"Prefix must resolve to a namespace: "+prefix);
         }
       }
  -    m_localpart = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep+1);
  +    _localName = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep+1);
  +    _namespaceURI = namespace;
  +    _prefix = prefix;
       m_hashCode = toString().hashCode();
     }
     
  @@ -284,7 +258,7 @@
      */
     public QName(String qname, Element namespaceContext, PrefixResolver resolver)
     {
  -    m_namespace = null;
  +    _namespaceURI = null;
   
       int indexOfNSSep = qname.indexOf(':');
       if(indexOfNSSep > 0)
  @@ -292,15 +266,16 @@
         if(null != namespaceContext)
         {
           String prefix = qname.substring(0, indexOfNSSep);
  +        _prefix = prefix;
           if(prefix.equals("xml"))
           {
  -          m_namespace = S_XMLNAMESPACEURI;
  +          _namespaceURI = S_XMLNAMESPACEURI;
           }
           else
           {
  -          m_namespace = resolver.getNamespaceForPrefix(prefix, namespaceContext);
  +          _namespaceURI = resolver.getNamespaceForPrefix(prefix, namespaceContext);
           }  
  -        if(null == m_namespace)
  +        if(null == _namespaceURI)
           {
             throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{prefix})); //"Prefix must resolve to a namespace: "+prefix);
           }
  @@ -311,7 +286,7 @@
         }
       }
       
  -    m_localpart = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep+1);
  +    _localName = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep+1);
       m_hashCode = toString().hashCode();
     }
     
  @@ -322,7 +297,7 @@
      */
     public QName(String qname, PrefixResolver resolver)
     {
  -    m_namespace = null;
  +    _namespaceURI = null;
   
       int indexOfNSSep = qname.indexOf(':');
       if(indexOfNSSep > 0)
  @@ -330,19 +305,19 @@
         String prefix = qname.substring(0, indexOfNSSep);
         if(prefix.equals("xml"))
         {
  -        m_namespace = S_XMLNAMESPACEURI;
  +        _namespaceURI = S_XMLNAMESPACEURI;
         }
         else
         {
  -        m_namespace = resolver.getNamespaceForPrefix(prefix);
  +        _namespaceURI = resolver.getNamespaceForPrefix(prefix);
         }  
  -      if(null == m_namespace)
  +      if(null == _namespaceURI)
         {
           throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_PREFIX_MUST_RESOLVE, new Object[]{prefix})); //"Prefix must resolve to a namespace: "+prefix);
         }
       }
       
  -    m_localpart = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep+1);
  +    _localName = (indexOfNSSep < 0) ? qname : qname.substring(indexOfNSSep+1);
       m_hashCode = toString().hashCode();
     }
     
  @@ -352,9 +327,9 @@
      */
     public String toString()
     {
  -    return (null != this.m_namespace) 
  -           ? (this.m_namespace + ":" + this.m_localpart) 
  -             : this.m_localpart;
  +    return (null != this._namespaceURI) 
  +           ? (this._namespaceURI + ":" + this._localName) 
  +             : this._localName;
     }
   
   }
  
  
  
  1.5       +2 -2      xml-xalan/java/src/org/apache/xalan/utils/SystemIDResolver.java
  
  Index: SystemIDResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/utils/SystemIDResolver.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SystemIDResolver.java	2000/08/04 15:53:34	1.4
  +++ SystemIDResolver.java	2000/10/02 02:43:09	1.5
  @@ -57,8 +57,8 @@
   package org.apache.xalan.utils;
   
   import org.xml.sax.SAXException;
  -import org.apache.xerces.utils.URI;
  -import org.apache.xerces.utils.URI.MalformedURIException;
  +import org.apache.xalan.utils.URI;
  +import org.apache.xalan.utils.URI.MalformedURIException;
   
   public class SystemIDResolver
   {
  
  
  
  1.5       +12 -6     xml-xalan/java/src/org/apache/xalan/utils/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/utils/TreeWalker.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TreeWalker.java	2000/08/08 00:27:34	1.4
  +++ TreeWalker.java	2000/10/02 02:43:10	1.5
  @@ -63,6 +63,8 @@
   import org.apache.xpath.DOMHelper;
   import org.apache.xalan.utils.NodeConsumer;
   
  +import serialize.SerializerHandler;
  +
   /**
    * <meta name="usage" content="advanced"/>
    * This class does a pre-order walk of the DOM tree, calling a ContentHandler
  @@ -214,7 +216,7 @@
           ProcessingInstruction pi = (ProcessingInstruction)node;
           String name = pi.getNodeName();
           // String data = pi.getData();
  -        if(name.equals("xslt-next-is-raw") && name.equals("formatter-to-dom"))
  +        if(name.equals("xslt-next-is-raw"))
           {
             nextIsRaw = true;
           }
  @@ -248,14 +250,18 @@
           if(nextIsRaw)
           {
             nextIsRaw = false;
  -          if(this.m_contentHandler instanceof RawCharacterHandler)
  +          boolean isSerH = (m_contentHandler instanceof SerializerHandler);
  +          SerializerHandler serH = isSerH ? ((SerializerHandler)this.m_contentHandler) : null;
  +          if(isSerH)
             {
  -            ((RawCharacterHandler)this.m_contentHandler).charactersRaw(data.toCharArray(), 0, data.length());
  +            serH.startNonEscaping();
             }
  -          else
  +          this.m_contentHandler.characters(data.toCharArray(), 0, data.length());
             {
  -            System.out.println("Warning: can't output raw characters!");
  -            this.m_contentHandler.characters(data.toCharArray(), 0, data.length());
  +            if(isSerH)
  +            {
  +              serH.endNonEscaping();
  +            }
             }
           }
           else
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xalan/utils/URI.java
  
  Index: URI.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999,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 "Xerces" 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) 1999, iClick Inc., 
   * http://www.apache.org.  For more information on the Apache Software 
   * Foundation, please see <http://www.apache.org/>.
   */
  
  package org.apache.xalan.utils;
  
  import java.io.IOException;
  import java.io.Serializable;
  
  /**********************************************************************
  * A class to represent a Uniform Resource Identifier (URI). This class
  * is designed to handle the parsing of URIs and provide access to 
  * the various components (scheme, host, port, userinfo, path, query
  * string and fragment) that may constitute a URI. 
  * <p>
  * Parsing of a URI specification is done according to the URI 
  * syntax described in RFC 2396 
  * <http://www.ietf.org/rfc/rfc2396.txt?number=2396>. Every URI consists 
  * of a scheme, followed by a colon (':'), followed by a scheme-specific
  * part. For URIs that follow the "generic URI" syntax, the scheme-
  * specific part begins with two slashes ("//") and may be followed
  * by an authority segment (comprised of user information, host, and 
  * port), path segment, query segment and fragment. Note that RFC 2396
  * no longer specifies the use of the parameters segment and excludes
  * the "user:password" syntax as part of the authority segment. If 
  * "user:password" appears in a URI, the entire user/password string
  * is stored as userinfo.
  * <p>
  * For URIs that do not follow the "generic URI" syntax (e.g. mailto),
  * the entire scheme-specific part is treated as the "path" portion
  * of the URI.
  * <p>
  * Note that, unlike the java.net.URL class, this class does not provide
  * any built-in network access functionality nor does it provide any 
  * scheme-specific functionality (for example, it does not know a 
  * default port for a specific scheme). Rather, it only knows the 
  * grammar and basic set of operations that can be applied to a URI.
  *
  * @version  $Id: URI.java,v 1.1 2000/10/02 02:43:10 sboag Exp $
  *
  **********************************************************************/
  public class URI implements Serializable {
  
    /*******************************************************************
    * MalformedURIExceptions are thrown in the process of building a URI
    * or setting fields on a URI when an operation would result in an 
    * invalid URI specification. 
    *
    ********************************************************************/
    public static class MalformedURIException extends IOException {
  
     /******************************************************************
      * Constructs a <code>MalformedURIException</code> with no specified
      * detail message.
      ******************************************************************/
      public MalformedURIException() {
        super();
      }
  
      /*****************************************************************
      * Constructs a <code>MalformedURIException</code> with the 
      * specified detail message. 
      *
      * @param p_msg the detail message.
      ******************************************************************/
      public MalformedURIException(String p_msg) {
        super(p_msg);
      }
    }
  
    /** reserved characters */
    private static final String RESERVED_CHARACTERS = ";/?:@&=+$,";
  
    /** URI punctuation mark characters - these, combined with 
        alphanumerics, constitute the "unreserved" characters */
    private static final String MARK_CHARACTERS = "-_.!~*'() ";
  
    /** scheme can be composed of alphanumerics and these characters */
    private static final String SCHEME_CHARACTERS = "+-.";
  
    /** userinfo can be composed of unreserved, escaped and these 
        characters */
    private static final String USERINFO_CHARACTERS = ";:&=+$,";
  
    /** Stores the scheme (usually the protocol) for this URI. */
    private String m_scheme = null;
  
    /** If specified, stores the userinfo for this URI; otherwise null */
    private String m_userinfo = null;
  
    /** If specified, stores the host for this URI; otherwise null */
    private String m_host = null;
  
    /** If specified, stores the port for this URI; otherwise -1 */
    private int m_port = -1;
  
    /** If specified, stores the path for this URI; otherwise null */
    private String m_path = null;
  
    /** If specified, stores the query string for this URI; otherwise 
        null.  */
    private String m_queryString = null;
  
    /** If specified, stores the fragment for this URI; otherwise null */
    private String m_fragment = null;
  
    private static boolean DEBUG = false;
  
    /**
    * Construct a new and uninitialized URI.
    */
    public URI() {
    }
  
   /**
    * Construct a new URI from another URI. All fields for this URI are 
    * set equal to the fields of the URI passed in.
    *
    * @param p_other the URI to copy (cannot be null)
    */
    public URI(URI p_other) {
      initialize(p_other);
    }
  
   /**
    * Construct a new URI from a URI specification string. If the 
    * specification follows the "generic URI" syntax, (two slashes 
    * following the first colon), the specification will be parsed 
    * accordingly - setting the scheme, userinfo, host,port, path, query
    * string and fragment fields as necessary. If the specification does 
    * not follow the "generic URI" syntax, the specification is parsed 
    * into a scheme and scheme-specific part (stored as the path) only.
    *
    * @param p_uriSpec the URI specification string (cannot be null or
    *                  empty)
    *
    * @exception MalformedURIException if p_uriSpec violates any syntax
    *                                   rules
    */
    public URI(String p_uriSpec) throws MalformedURIException {
      this((URI)null, p_uriSpec);
    }
  
   /**
    * Construct a new URI from a base URI and a URI specification string.
    * The URI specification string may be a relative URI. 
    *
    * @param p_base the base URI (cannot be null if p_uriSpec is null or
    *               empty)
    * @param p_uriSpec the URI specification string (cannot be null or
    *                  empty if p_base is null)
    *
    * @exception MalformedURIException if p_uriSpec violates any syntax
    *                                  rules
    */
    public URI(URI p_base, String p_uriSpec) throws MalformedURIException {
      initialize(p_base, p_uriSpec);
    }
  
   /**
    * Construct a new URI that does not follow the generic URI syntax.
    * Only the scheme and scheme-specific part (stored as the path) are
    * initialized.
    *
    * @param p_scheme the URI scheme (cannot be null or empty)
    * @param p_schemeSpecificPart the scheme-specific part (cannot be
    *                             null or empty)
    *
    * @exception MalformedURIException if p_scheme violates any 
    *                                  syntax rules
    */
    public URI(String p_scheme, String p_schemeSpecificPart) 
               throws MalformedURIException {
      if (p_scheme == null || p_scheme.trim().length() == 0) {
        throw new MalformedURIException(
              "Cannot construct URI with null/empty scheme!");
      }
      if (p_schemeSpecificPart == null || 
          p_schemeSpecificPart.trim().length() == 0) {
        throw new MalformedURIException(
            "Cannot construct URI with null/empty scheme-specific part!");
      }
      setScheme(p_scheme);
      setPath(p_schemeSpecificPart);
    }
  
   /**
    * Construct a new URI that follows the generic URI syntax from its
    * component parts. Each component is validated for syntax and some
    * basic semantic checks are performed as well.  See the individual
    * setter methods for specifics.
    *
    * @param p_scheme the URI scheme (cannot be null or empty)
    * @param p_host the hostname or IPv4 address for the URI
    * @param p_path the URI path - if the path contains '?' or '#',
    *               then the query string and/or fragment will be
    *               set from the path; however, if the query and 
    *               fragment are specified both in the path and as 
    *               separate parameters, an exception is thrown
    * @param p_queryString the URI query string (cannot be specified
    *                      if path is null)
    * @param p_fragment the URI fragment (cannot be specified if path
    *                   is null)
    *
    * @exception MalformedURIException if any of the parameters violates 
    *                                  syntax rules or semantic rules
    */
    public URI(String p_scheme, String p_host, String p_path,
               String p_queryString, String p_fragment) 
           throws MalformedURIException {
      this(p_scheme, null, p_host, -1, p_path, p_queryString, p_fragment);
    }
  
   /**
    * Construct a new URI that follows the generic URI syntax from its
    * component parts. Each component is validated for syntax and some
    * basic semantic checks are performed as well.  See the individual
    * setter methods for specifics.
    *
    * @param p_scheme the URI scheme (cannot be null or empty)
    * @param p_userinfo the URI userinfo (cannot be specified if host 
    *                   is null)
    * @param p_host the hostname or IPv4 address for the URI
    * @param p_port the URI port (may be -1 for "unspecified"; cannot 
    *               be specified if host is null)
    * @param p_path the URI path - if the path contains '?' or '#',
    *               then the query string and/or fragment will be
    *               set from the path; however, if the query and 
    *               fragment are specified both in the path and as 
    *               separate parameters, an exception is thrown
    * @param p_queryString the URI query string (cannot be specified
    *                      if path is null)
    * @param p_fragment the URI fragment (cannot be specified if path
    *                   is null)
    *
    * @exception MalformedURIException if any of the parameters violates 
    *                                  syntax rules or semantic rules
    */
    public URI(String p_scheme, String p_userinfo, 
               String p_host, int p_port, String p_path,
               String p_queryString, String p_fragment) 
           throws MalformedURIException {
      if (p_scheme == null || p_scheme.trim().length() == 0) {
        throw new MalformedURIException("Scheme is required!");
      }
  
      if (p_host == null) {
        if (p_userinfo != null) {
          throw new MalformedURIException(
               "Userinfo may not be specified if host is not specified!");
        }
        if (p_port != -1) {
          throw new MalformedURIException(      
               "Port may not be specified if host is not specified!");
        }
      }
  
      if (p_path != null) { 
        if (p_path.indexOf('?') != -1 && p_queryString != null) {
          throw new MalformedURIException(
            "Query string cannot be specified in path and query string!");
        }
  
        if (p_path.indexOf('#') != -1 && p_fragment != null) {
          throw new MalformedURIException(
            "Fragment cannot be specified in both the path and fragment!");
        }
      }
  
      setScheme(p_scheme);
      setHost(p_host);
      setPort(p_port);
      setUserinfo(p_userinfo);
      setPath(p_path);
      setQueryString(p_queryString);
      setFragment(p_fragment);
    }
  
   /**
    * Initialize all fields of this URI from another URI.
    *
    * @param p_other the URI to copy (cannot be null)
    */
    private void initialize(URI p_other) {
      m_scheme = p_other.getScheme();
      m_userinfo = p_other.getUserinfo();
      m_host = p_other.getHost();
      m_port = p_other.getPort();
      m_path = p_other.getPath();
      m_queryString = p_other.getQueryString();
      m_fragment = p_other.getFragment();
    }
  
   /**
    * Initializes this URI from a base URI and a URI specification string.
    * See RFC 2396 Section 4 and Appendix B for specifications on parsing
    * the URI and Section 5 for specifications on resolving relative URIs
    * and relative paths.
    *
    * @param p_base the base URI (may be null if p_uriSpec is an absolute
    *               URI)
    * @param p_uriSpec the URI spec string which may be an absolute or
    *                  relative URI (can only be null/empty if p_base
    *                  is not null)
    *
    * @exception MalformedURIException if p_base is null and p_uriSpec
    *                                  is not an absolute URI or if
    *                                  p_uriSpec violates syntax rules 
    */
    private void initialize(URI p_base, String p_uriSpec) 
                           throws MalformedURIException {
      if (p_base == null && 
          (p_uriSpec == null || p_uriSpec.trim().length() == 0)) {
        throw new MalformedURIException(
                    "Cannot initialize URI with empty parameters.");
        }
  
      // just make a copy of the base if spec is empty
      if (p_uriSpec == null || p_uriSpec.trim().length() == 0) {
        initialize(p_base);
        return;
      }
  
      String uriSpec = p_uriSpec.trim();
      int uriSpecLen = uriSpec.length();
      int index = 0;
  
      // check for scheme
      if (uriSpec.indexOf(':') == -1) {
        if (p_base == null) {
          throw new MalformedURIException("No scheme found in URI.");
        }
      }
      else {
        initializeScheme(uriSpec);
        index = m_scheme.length()+1;
      }
  
      // two slashes means generic URI syntax, so we get the authority
      if (((index+1) < uriSpecLen) && 
          (uriSpec.substring(index).startsWith("//"))) {
        index += 2;
        int startPos = index;
  
        // get authority - everything up to path, query or fragment
        char testChar = '\0';
        while (index < uriSpecLen) {
          testChar = uriSpec.charAt(index);
          if (testChar == '/' || testChar == '?' || testChar == '#') {
            break;
          }
          index++;
        }
  
        // if we found authority, parse it out, otherwise we set the
        // host to empty string
        if (index > startPos) {
          initializeAuthority(uriSpec.substring(startPos, index));
        }
        else {
          m_host = "";
        }
      }
  
      initializePath(uriSpec.substring(index));
  
      // Resolve relative URI to base URI - see RFC 2396 Section 5.2
      // In some cases, it might make more sense to throw an exception
      // (when scheme is specified is the string spec and the base URI
      // is also specified, for example), but we're just following the
      // RFC specifications 
      if (p_base != null) {
  
        // check to see if this is the current doc - RFC 2396 5.2 #2
        // note that this is slightly different from the RFC spec in that
        // we don't include the check for query string being null
        // - this handles cases where the urispec is just a query
        // string or a fragment (e.g. "?y" or "#s") - 
        // see <http://www.ics.uci.edu/~fielding/url/test1.html> which
        // identified this as a bug in the RFC
        if (m_path.length() == 0 && m_scheme == null && 
            m_host == null) {
          m_scheme = p_base.getScheme();
          m_userinfo = p_base.getUserinfo();
          m_host = p_base.getHost();
          m_port = p_base.getPort();
          m_path = p_base.getPath();
  
          if (m_queryString == null) {
            m_queryString = p_base.getQueryString();
          }
          return;
        }
  
        // check for scheme - RFC 2396 5.2 #3
        // if we found a scheme, it means absolute URI, so we're done
        if (m_scheme == null) {
          m_scheme = p_base.getScheme();
        }
        else {
          return;
        }
  
        // check for authority - RFC 2396 5.2 #4
        // if we found a host, then we've got a network path, so we're done
        if (m_host == null) {
          m_userinfo = p_base.getUserinfo();
          m_host = p_base.getHost();
          m_port = p_base.getPort();
        }
        else {
          return;
        }
  
        // check for absolute path - RFC 2396 5.2 #5
        if (m_path.length() > 0 && 
            m_path.startsWith("/")) {
          return;
        }
  
        // if we get to this point, we need to resolve relative path
        // RFC 2396 5.2 #6
        String path = new String();
        String basePath = p_base.getPath();
  
        // 6a - get all but the last segment of the base URI path
        if (basePath != null) {
          int lastSlash = basePath.lastIndexOf('/');
          if (lastSlash != -1) {
            path = basePath.substring(0, lastSlash+1);
          }
        }
  
        // 6b - append the relative URI path
        path = path.concat(m_path);
  
        // 6c - remove all "./" where "." is a complete path segment
        index = -1;
        while ((index = path.indexOf("/./")) != -1) {
          path = path.substring(0, index+1).concat(path.substring(index+3));
        }
  
        // 6d - remove "." if path ends with "." as a complete path segment
        if (path.endsWith("/.")) {
          path = path.substring(0, path.length()-1);
        }
  
        // 6e - remove all "<segment>/../" where "<segment>" is a complete 
        // path segment not equal to ".."
        index = -1;
        int segIndex = -1;
        String tempString = null;
  
        while ((index = path.indexOf("/../")) > 0) {
          tempString = path.substring(0, path.indexOf("/../"));
          segIndex = tempString.lastIndexOf('/');
          if (segIndex != -1) {
            if (!tempString.substring(segIndex++).equals("..")) {
              path = path.substring(0, segIndex).concat(path.substring(index+4));
             }
          }
        }
  
        // 6f - remove ending "<segment>/.." where "<segment>" is a 
        // complete path segment
        if (path.endsWith("/..")) {
          tempString = path.substring(0, path.length()-3);
          segIndex = tempString.lastIndexOf('/');
          if (segIndex != -1) {
            path = path.substring(0, segIndex+1);
          }
        }
        m_path = path;
      }
    }
  
   /**
    * Initialize the scheme for this URI from a URI string spec.
    *
    * @param p_uriSpec the URI specification (cannot be null)
    *
    * @exception MalformedURIException if URI does not have a conformant
    *                                  scheme
    */
    private void initializeScheme(String p_uriSpec) 
                   throws MalformedURIException {
      int uriSpecLen = p_uriSpec.length();
      int index = 0;
      String scheme = null;
      char testChar = '\0';
  
      while (index < uriSpecLen) {
        testChar = p_uriSpec.charAt(index);
        if (testChar == ':' || testChar == '/' || 
            testChar == '?' || testChar == '#') {
          break;
        }
        index++;
      }
      scheme = p_uriSpec.substring(0, index);
  
      if (scheme.length() == 0) {
        throw new MalformedURIException("No scheme found in URI.");
      }
      else {
        setScheme(scheme);
      }
    }
  
   /**
    * Initialize the authority (userinfo, host and port) for this 
    * URI from a URI string spec.
    *
    * @param p_uriSpec the URI specification (cannot be null)
    *
    * @exception MalformedURIException if p_uriSpec violates syntax rules
    */
    private void initializeAuthority(String p_uriSpec) 
                   throws MalformedURIException {
      int index = 0;
      int start = 0;
      int end = p_uriSpec.length();
      char testChar = '\0';
      String userinfo = null;
  
      // userinfo is everything up @
      if (p_uriSpec.indexOf('@', start) != -1) {
        while (index < end) {
          testChar = p_uriSpec.charAt(index);
          if (testChar == '@') {
            break;
          }
          index++;
        }
        userinfo = p_uriSpec.substring(start, index);
        index++;
      }
  
      // host is everything up to ':'
      String host = null;
      start = index;
      while (index < end) { 
        testChar = p_uriSpec.charAt(index);
        if (testChar == ':') {
          break;
        }
        index++;
      }
      host = p_uriSpec.substring(start, index);
      int port = -1;
      if (host.length() > 0) {
        // port
        if (testChar == ':') {
          index++;
          start = index;
          while (index < end) {
            index++;
          }
          String portStr = p_uriSpec.substring(start, index);
          if (portStr.length() > 0) {
            for (int i = 0; i < portStr.length(); i++) {
              if (!isDigit(portStr.charAt(i))) {
                throw new MalformedURIException(
                     portStr + 
                     " is invalid. Port should only contain digits!");
              }
            } 
            try {
              port = Integer.parseInt(portStr);
            }
            catch (NumberFormatException nfe) {
              // can't happen
            }
          }
        }
      }
      setHost(host);
      setPort(port);
      setUserinfo(userinfo);
    }
  
   /**
    * Initialize the path for this URI from a URI string spec.
    *
    * @param p_uriSpec the URI specification (cannot be null)
    *
    * @exception MalformedURIException if p_uriSpec violates syntax rules
    */
    private void initializePath(String p_uriSpec) 
                   throws MalformedURIException {
      if (p_uriSpec == null) {
        throw new MalformedURIException(
                  "Cannot initialize path from null string!");
      }
  
      int index = 0;
      int start = 0;
      int end = p_uriSpec.length();
      char testChar = '\0';
  
      // path - everything up to query string or fragment
      while (index < end) {
        testChar = p_uriSpec.charAt(index);
        if (testChar == '?' || testChar == '#') {
          break;
        }
        // check for valid escape sequence
        if (testChar == '%') { 
           if (index+2 >= end ||
              !isHex(p_uriSpec.charAt(index+1)) ||
              !isHex(p_uriSpec.charAt(index+2))) {
            throw new MalformedURIException(
                  "Path contains invalid escape sequence!");
           }
        }
        else if (!isReservedCharacter(testChar) && 
                 !isUnreservedCharacter(testChar)) {
          throw new MalformedURIException(
                    "Path contains invalid character: " + testChar);
        }
        index++;
      }
      m_path = p_uriSpec.substring(start, index);
  
      // query - starts with ? and up to fragment or end
      if (testChar == '?') { 
        index++;
        start = index;
        while (index < end) {
          testChar = p_uriSpec.charAt(index);
          if (testChar == '#') {
            break;
          }
          if (testChar == '%') { 
             if (index+2 >= end ||
                !isHex(p_uriSpec.charAt(index+1)) ||
                !isHex(p_uriSpec.charAt(index+2))) {
              throw new MalformedURIException(
                      "Query string contains invalid escape sequence!");
             }
          }
          else if (!isReservedCharacter(testChar) && 
                   !isUnreservedCharacter(testChar)) {
            throw new MalformedURIException(
                  "Query string contains invalid character:" + testChar);
          }
          index++;
        }
        m_queryString = p_uriSpec.substring(start, index);
      }
  
      // fragment - starts with #
      if (testChar == '#') { 
        index++;
        start = index;
        while (index < end) {
          testChar = p_uriSpec.charAt(index);
  
          if (testChar == '%') { 
             if (index+2 >= end ||
                !isHex(p_uriSpec.charAt(index+1)) ||
                !isHex(p_uriSpec.charAt(index+2))) {
              throw new MalformedURIException(
                      "Fragment contains invalid escape sequence!");
             }
          }
          else if (!isReservedCharacter(testChar) && 
                   !isUnreservedCharacter(testChar)) {
            throw new MalformedURIException(
                  "Fragment contains invalid character:"+testChar);
          }
          index++;
        }
        m_fragment = p_uriSpec.substring(start, index);
      }
    }
  
   /**
    * Get the scheme for this URI.
    *
    * @return the scheme for this URI
    */
    public String getScheme() {
      return m_scheme;
    }
  
   /**
    * Get the scheme-specific part for this URI (everything following the
    * scheme and the first colon). See RFC 2396 Section 5.2 for spec.
    *
    * @return the scheme-specific part for this URI
    */
    public String getSchemeSpecificPart() {
      StringBuffer schemespec = new StringBuffer();
  
      if (m_userinfo != null || m_host != null || m_port != -1) {
        schemespec.append("//");
      }
  
      if (m_userinfo != null) {
        schemespec.append(m_userinfo);
        schemespec.append('@');
      }
  
      if (m_host != null) {
        schemespec.append(m_host);
      }
  
      if (m_port != -1) {
        schemespec.append(':');
        schemespec.append(m_port);
      }
  
      if (m_path != null) {
        schemespec.append((m_path));
      }
  
      if (m_queryString != null) {
        schemespec.append('?');
        schemespec.append(m_queryString);
      }
  
      if (m_fragment != null) {
        schemespec.append('#');
        schemespec.append(m_fragment);
      }
  
      return schemespec.toString();
    }
  
   /**
    * Get the userinfo for this URI.
    *
    * @return the userinfo for this URI (null if not specified).
    */
    public String getUserinfo() {
      return m_userinfo;
    }
  
    /**
    * Get the host for this URI.
    *
    * @return the host for this URI (null if not specified).
    */
    public String getHost() {
      return m_host;
    }
  
   /**
    * Get the port for this URI.
    *
    * @return the port for this URI (-1 if not specified).
    */
    public int getPort() {
      return m_port;
    }
  
   /**
    * Get the path for this URI (optionally with the query string and
    * fragment). 
    *
    * @param p_includeQueryString if true (and query string is not null),
    *                             then a "?" followed by the query string 
    *                             will be appended 
    * @param p_includeFragment if true (and fragment is not null),
    *                             then a "#" followed by the fragment
    *                             will be appended
    *
    * @return the path for this URI possibly including the query string
    *         and fragment
    */
    public String getPath(boolean p_includeQueryString, 
                          boolean p_includeFragment) {
      StringBuffer pathString = new StringBuffer(m_path);
  
      if (p_includeQueryString && m_queryString != null) {
        pathString.append('?');
        pathString.append(m_queryString);
      }
  
      if (p_includeFragment && m_fragment != null) {
        pathString.append('#');
        pathString.append(m_fragment);
      }
      return pathString.toString();
    }
  
   /**
    * Get the path for this URI. Note that the value returned is the path
    * only and does not include the query string or fragment.
    *
    * @return the path for this URI.
    */
    public String getPath() {
      return m_path;
    }
  
   /**
    * Get the query string for this URI.
    *
    * @return the query string for this URI. Null is returned if there
    *         was no "?" in the URI spec, empty string if there was a 
    *         "?" but no query string following it.
    */
    public String getQueryString() {
      return m_queryString;
    }
  
   /**
    * Get the fragment for this URI.
    *
    * @return the fragment for this URI. Null is returned if there
    *         was no "#" in the URI spec, empty string if there was a 
    *         "#" but no fragment following it.
    */
    public String getFragment() {
      return m_fragment;
    }
  
   /**
    * Set the scheme for this URI. The scheme is converted to lowercase
    * before it is set.
    *
    * @param p_scheme the scheme for this URI (cannot be null)
    *
    * @exception MalformedURIException if p_scheme is not a conformant
    *                                  scheme name
    */
    public void setScheme(String p_scheme) throws MalformedURIException {
      if (p_scheme == null) {
        throw new MalformedURIException(
                  "Cannot set scheme from null string!");
      }
      if (!isConformantSchemeName(p_scheme)) {
        throw new MalformedURIException("The scheme is not conformant.");
      }
  
      m_scheme = p_scheme.toLowerCase();
    }
  
   /**
    * Set the userinfo for this URI. If a non-null value is passed in and 
    * the host value is null, then an exception is thrown.
    *
    * @param p_userinfo the userinfo for this URI
    *
    * @exception MalformedURIException if p_userinfo contains invalid
    *                                  characters
    */
    public void setUserinfo(String p_userinfo) throws MalformedURIException {
      if (p_userinfo == null) {
        m_userinfo = null;
      }
      else {
        if (m_host == null) {
          throw new MalformedURIException(
                       "Userinfo cannot be set when host is null!");
        }
  
        // userinfo can contain alphanumerics, mark characters, escaped
        // and ';',':','&','=','+','$',','
        int index = 0;
        int end = p_userinfo.length();
        char testChar = '\0';
        while (index < end) {
          testChar = p_userinfo.charAt(index);
          if (testChar == '%') {
            if (index+2 >= end ||
                !isHex(p_userinfo.charAt(index+1)) ||
                !isHex(p_userinfo.charAt(index+2))) {
              throw new MalformedURIException(
                    "Userinfo contains invalid escape sequence!");
            }
          }
          else if (!isUnreservedCharacter(testChar) &&
                   USERINFO_CHARACTERS.indexOf(testChar) == -1) {
            throw new MalformedURIException(
                    "Userinfo contains invalid character:"+testChar);
          }
          index++;
        }
      }
      m_userinfo = p_userinfo;
    }
  
    /**
    * Set the host for this URI. If null is passed in, the userinfo
    * field is also set to null and the port is set to -1.
    *
    * @param p_host the host for this URI
    *
    * @exception MalformedURIException if p_host is not a valid IP 
    *                                  address or DNS hostname.
    */
    public void setHost(String p_host) throws MalformedURIException {
      if (p_host == null || p_host.trim().length() == 0) {
        m_host = p_host;
        m_userinfo = null;
        m_port = -1;
      }
      else if (!isWellFormedAddress(p_host)) {
        throw new MalformedURIException("Host is not a well formed address!");
      } 
      m_host = p_host;
    }
  
   /**
    * Set the port for this URI. -1 is used to indicate that the port is
    * not specified, otherwise valid port numbers are  between 0 and 65535.
    * If a valid port number is passed in and the host field is null,
    * an exception is thrown.
    *
    * @param p_port the port number for this URI
    *
    * @exception MalformedURIException if p_port is not -1 and not a 
    *                                  valid port number 
    */
    public void setPort(int p_port) throws MalformedURIException {
      if (p_port >= 0 && p_port <= 65535) {
        if (m_host == null) {
          throw new MalformedURIException(
                        "Port cannot be set when host is null!");
        }
      }
      else if (p_port != -1) {
        throw new MalformedURIException("Invalid port number!");
      }
      m_port = p_port;
    }
  
   /**
    * Set the path for this URI. If the supplied path is null, then the
    * query string and fragment are set to null as well. If the supplied 
    * path includes a query string and/or fragment, these fields will be
    * parsed and set as well. Note that, for URIs following the "generic
    * URI" syntax, the path specified should start with a slash.
    * For URIs that do not follow the generic URI syntax, this method 
    * sets the scheme-specific part.
    *
    * @param p_path the path for this URI (may be null)
    *
    * @exception MalformedURIException if p_path contains invalid
    *                                  characters
    */
    public void setPath(String p_path) throws MalformedURIException {
      if (p_path == null) {
        m_path = null;
        m_queryString = null;
        m_fragment = null;
      }
      else {
        initializePath(p_path);
      }
    }
  
   /**
    * Append to the end of the path of this URI. If the current path does
    * not end in a slash and the path to be appended does not begin with 
    * a slash, a slash will be appended to the current path before the 
    * new segment is added. Also, if the current path ends in a slash
    * and the new segment begins with a slash, the extra slash will be
    * removed before the new segment is appended.
    *
    * @param p_addToPath the new segment to be added to the current path
    *
    * @exception MalformedURIException if p_addToPath contains syntax
    *                                  errors
    */
    public void appendPath(String p_addToPath) 
                           throws MalformedURIException {
      if (p_addToPath == null || p_addToPath.trim().length() == 0) {
        return;
      }
  
      if (!isURIString(p_addToPath)) {
        throw new MalformedURIException(
                "Path contains invalid character!");
      }
  
      if (m_path == null || m_path.trim().length() == 0) {
        if (p_addToPath.startsWith("/")) {
          m_path = p_addToPath;
        }
        else {
          m_path = "/" + p_addToPath;
        }
      }
      else if (m_path.endsWith("/")) {
        if (p_addToPath.startsWith("/")) {
          m_path = m_path.concat(p_addToPath.substring(1));
        }
        else {
          m_path = m_path.concat(p_addToPath);
        }
      }
      else {
        if (p_addToPath.startsWith("/")) {
          m_path = m_path.concat(p_addToPath);
        }
        else {
          m_path = m_path.concat("/" + p_addToPath);
        }
      }
    }
  
   /**
    * Set the query string for this URI. A non-null value is valid only
    * if this is an URI conforming to the generic URI syntax and 
    * the path value is not null.
    *
    * @param p_queryString the query string for this URI
    *
    * @exception MalformedURIException if p_queryString is not null and this  
    *                                  URI does not conform to the generic
    *                                  URI syntax or if the path is null
    */
    public void setQueryString(String p_queryString) throws MalformedURIException {
      if (p_queryString == null) {
        m_queryString = null;
      }
      else if (!isGenericURI()) {
        throw new MalformedURIException(
                "Query string can only be set for a generic URI!");
      }
      else if (getPath() == null) {
        throw new MalformedURIException(
                "Query string cannot be set when path is null!");
      }
      else if (!isURIString(p_queryString)) {
        throw new MalformedURIException(
                "Query string contains invalid character!");
      }
      else {
        m_queryString = p_queryString;
      }
    }
  
   /**
    * Set the fragment for this URI. A non-null value is valid only
    * if this is a URI conforming to the generic URI syntax and 
    * the path value is not null.
    *
    * @param p_fragment the fragment for this URI
    *
    * @exception MalformedURIException if p_fragment is not null and this  
    *                                  URI does not conform to the generic
    *                                  URI syntax or if the path is null
    */
    public void setFragment(String p_fragment) throws MalformedURIException {
      if (p_fragment == null) {
        m_fragment = null;
      }
      else if (!isGenericURI()) {
        throw new MalformedURIException(
           "Fragment can only be set for a generic URI!");
      }
      else if (getPath() == null) {
        throw new MalformedURIException(
                "Fragment cannot be set when path is null!");
      }
      else if (!isURIString(p_fragment)) {
        throw new MalformedURIException(
                "Fragment contains invalid character!");
      }
      else {
        m_fragment = p_fragment;
      }
    }
  
   /**
    * Determines if the passed-in Object is equivalent to this URI.
    *
    * @param p_test the Object to test for equality.
    *
    * @return true if p_test is a URI with all values equal to this
    *         URI, false otherwise
    */
    public boolean equals(Object p_test) {
      if (p_test instanceof URI) {
        URI testURI = (URI) p_test;
        if (((m_scheme == null && testURI.m_scheme == null) ||
             (m_scheme != null && testURI.m_scheme != null &&
              m_scheme.equals(testURI.m_scheme))) &&
            ((m_userinfo == null && testURI.m_userinfo == null) ||
             (m_userinfo != null && testURI.m_userinfo != null &&
              m_userinfo.equals(testURI.m_userinfo))) &&
            ((m_host == null && testURI.m_host == null) ||
             (m_host != null && testURI.m_host != null &&
              m_host.equals(testURI.m_host))) &&
              m_port == testURI.m_port &&
            ((m_path == null && testURI.m_path == null) ||
             (m_path != null && testURI.m_path != null &&
              m_path.equals(testURI.m_path))) &&
            ((m_queryString == null && testURI.m_queryString == null) ||
             (m_queryString != null && testURI.m_queryString != null &&
              m_queryString.equals(testURI.m_queryString))) &&
            ((m_fragment == null && testURI.m_fragment == null) ||
             (m_fragment != null && testURI.m_fragment != null &&
              m_fragment.equals(testURI.m_fragment)))) {
          return true;
        }
      }
      return false;
    }
  
   /**
    * Get the URI as a string specification. See RFC 2396 Section 5.2.
    *
    * @return the URI string specification
    */
    public String toString() {
      StringBuffer uriSpecString = new StringBuffer();
  
      if (m_scheme != null) {
        uriSpecString.append(m_scheme);
        uriSpecString.append(':');
      }
      uriSpecString.append(getSchemeSpecificPart());
      return uriSpecString.toString();
    }
  
   /**
    * Get the indicator as to whether this URI uses the "generic URI"
    * syntax.
    *
    * @return true if this URI uses the "generic URI" syntax, false
    *         otherwise
    */
    public boolean isGenericURI() {
      // presence of the host (whether valid or empty) means 
      // double-slashes which means generic uri
      return (m_host != null);
    }
  
   /**
    * Determine whether a scheme conforms to the rules for a scheme name.
    * A scheme is conformant if it starts with an alphanumeric, and 
    * contains only alphanumerics, '+','-' and '.'.
    *
    * @return true if the scheme is conformant, false otherwise
    */
    public static boolean isConformantSchemeName(String p_scheme) {
      if (p_scheme == null || p_scheme.trim().length() == 0) {
        return false;
      }
  
      if (!isAlpha(p_scheme.charAt(0))) {
        return false;
      }
  
      char testChar;
      for (int i = 1; i < p_scheme.length(); i++) {
        testChar = p_scheme.charAt(i);
        if (!isAlphanum(testChar) && 
            SCHEME_CHARACTERS.indexOf(testChar) == -1) {
          return false;
        }
      }
  
      return true;
    }
  
   /**
    * Determine whether a string is syntactically capable of representing
    * a valid IPv4 address or the domain name of a network host. A valid
    * IPv4 address consists of four decimal digit groups separated by a
    * '.'. A hostname consists of domain labels (each of which must 
    * begin and end with an alphanumeric but may contain '-') separated
    & by a '.'. See RFC 2396 Section 3.2.2.
    *
    * @return true if the string is a syntactically valid IPv4 address 
    *              or hostname
    */
    public static boolean isWellFormedAddress(String p_address) {
      if (p_address == null) {
        return false;
      }
  
      String address = p_address.trim();
      int addrLength = address.length();
      if (addrLength == 0 || addrLength > 255) {
        return false;
      }
  
      if (address.startsWith(".") || address.startsWith("-")) {
        return false;
      }
  
      // rightmost domain label starting with digit indicates IP address
      // since top level domain label can only start with an alpha
      // see RFC 2396 Section 3.2.2
      int index = address.lastIndexOf('.');
      if (address.endsWith(".")) {
        index = address.substring(0, index).lastIndexOf('.');
      }
  
      if (index+1 < addrLength && isDigit(p_address.charAt(index+1))) {
        char testChar;
        int numDots = 0;
  
        // make sure that 1) we see only digits and dot separators, 2) that
        // any dot separator is preceded and followed by a digit and 
        // 3) that we find 3 dots
        for (int i = 0; i < addrLength; i++) {
          testChar = address.charAt(i);
          if (testChar == '.') {
            if (!isDigit(address.charAt(i-1)) || 
                (i+1 < addrLength && !isDigit(address.charAt(i+1)))) {
              return false;
            }
            numDots++;
          }
          else if (!isDigit(testChar)) {
            return false;
          }
        }
        if (numDots != 3) {
          return false;
        }
      }
      else {
        // domain labels can contain alphanumerics and '-"
        // but must start and end with an alphanumeric
        char testChar;
    
        for (int i = 0; i < addrLength; i++) {
          testChar = address.charAt(i);
          if (testChar == '.') {
            if (!isAlphanum(address.charAt(i-1))) {
              return false;
            } 
            if (i+1 < addrLength && !isAlphanum(address.charAt(i+1))) {
              return false;
            }
          }
          else if (!isAlphanum(testChar) && testChar != '-') {
            return false;
          }
        }
      }
      return true;
    }
  
  
   /**
    * Determine whether a char is a digit.
    *
    * @return true if the char is betweeen '0' and '9', false otherwise
    */
    private static boolean isDigit(char p_char) {
      return p_char >= '0' && p_char <= '9';
    }
  
   /**
    * Determine whether a character is a hexadecimal character.
    *
    * @return true if the char is betweeen '0' and '9', 'a' and 'f'
    *         or 'A' and 'F', false otherwise
    */
    private static boolean isHex(char p_char) {
      return (isDigit(p_char) || 
              (p_char >= 'a' && p_char <= 'f') || 
              (p_char >= 'A' && p_char <= 'F'));
    }
  
   /**
    * Determine whether a char is an alphabetic character: a-z or A-Z
    *
    * @return true if the char is alphabetic, false otherwise
    */
    private static boolean isAlpha(char p_char) {
      return ((p_char >= 'a' && p_char <= 'z') || 
              (p_char >= 'A' && p_char <= 'Z' )); 
    }
  
   /**
    * Determine whether a char is an alphanumeric: 0-9, a-z or A-Z
    *
    * @return true if the char is alphanumeric, false otherwise
    */
    private static boolean isAlphanum(char p_char) {
      return (isAlpha(p_char) || isDigit(p_char)); 
    }
  
   /**
    * Determine whether a character is a reserved character:
    * ';', '/', '?', ':', '@', '&', '=', '+', '$' or ',' 
    *
    * @return true if the string contains any reserved characters
    */
    private static boolean isReservedCharacter(char p_char) {
      return RESERVED_CHARACTERS.indexOf(p_char) != -1;
    }
  
   /**
    * Determine whether a char is an unreserved character.
    *
    * @return true if the char is unreserved, false otherwise
    */
    private static boolean isUnreservedCharacter(char p_char) {
      return (isAlphanum(p_char) || 
              MARK_CHARACTERS.indexOf(p_char) != -1);
    }
  
   /**
    * Determine whether a given string contains only URI characters (also
    * called "uric" in RFC 2396). uric consist of all reserved
    * characters, unreserved characters and escaped characters.
    *
    * @return true if the string is comprised of uric, false otherwise
    */
    private static boolean isURIString(String p_uric) {
      if (p_uric == null) {
        return false;
      }
      int end = p_uric.length();
      char testChar = '\0';
      for (int i = 0; i < end; i++) {
        testChar = p_uric.charAt(i);
        if (testChar == '%') {
          if (i+2 >= end ||
              !isHex(p_uric.charAt(i+1)) ||
              !isHex(p_uric.charAt(i+2))) {
            return false;
          }
          else {
            i += 2;
            continue;
          }
        }
        if (isReservedCharacter(testChar) || 
            isUnreservedCharacter(testChar)) {
            continue;
        }
        else {
          return false;
        }
      }
      return true;
    }
  }
  
  
  
  1.2       +1 -1      xml-xalan/java/src/org/apache/xalan/xpath/xml/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xpath/xml/TreeWalker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TreeWalker.java	2000/07/25 16:05:41	1.1
  +++ TreeWalker.java	2000/10/02 02:43:11	1.2
  @@ -61,7 +61,7 @@
   import org.xml.sax.ext.LexicalHandler;
   
   import org.apache.xalan.utils.AttList;
  -import org.apache.xalan.utils.RawCharacterHandler;
  +
   /**
    * <meta name="usage" content="advanced"/>
    * This class does a pre-order walk of the DOM tree, calling the FormatterListener
  
  
  
  1.5       +16 -7     xml-xalan/java/src/org/apache/xalan/xslt/Process.java
  
  Index: Process.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/Process.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Process.java	2000/07/18 01:38:20	1.4
  +++ Process.java	2000/10/02 02:43:11	1.5
  @@ -76,6 +76,8 @@
   import java.util.Properties;
   import java.util.Enumeration;
   
  +import java.util.Date;
  +
   // Needed Xalan classes
   import org.apache.xalan.res.XSLMessages;
   
  @@ -94,9 +96,6 @@
   import org.apache.xalan.trace.TraceListener;
   import org.apache.xalan.trace.TraceManager;
   
  -// Needed Xerces classes
  -import org.apache.xerces.parsers.DOMParser;
  -
   // Needed TRaX classes
   import trax.Result;
   import trax.Processor;
  @@ -117,9 +116,9 @@
   import org.w3c.dom.Document;
   
   // Needed Serializer classes
  -import org.apache.xml.serialize.OutputFormat;
  -import org.apache.xml.serialize.Serializer;
  -import org.apache.xml.serialize.SerializerFactory;
  +import serialize.OutputFormat;
  +import serialize.Serializer;
  +import serialize.SerializerFactory;
   
   
   /**
  @@ -190,6 +189,7 @@
      *    -TEXT (Use simple Text formatter)
      *    -HTML (Use HTML formatter)
      *    -PARAM name expression (Set a stylesheet parameter)
  +   *    -DIAG put out timing diagnostics
      * </pre>
      *  <p>Use -IN to specify the XML source document. To specify the XSL stylesheet, use -XSL
      *  or -LXCIN. To compile an XSL stylesheet for future use as -LXCIN input, use -LXCOUT.</p>
  @@ -206,6 +206,7 @@
       Runtime.getRuntime().traceMethodCalls(false); // turns Java tracing off
       boolean doStackDumpOnError = false;
       boolean setQuietMode = false;
  +    boolean doDiag = false;
   
       // Runtime.getRuntime().traceMethodCalls(false);
       // Runtime.getRuntime().traceInstructions(false);
  @@ -408,6 +409,10 @@
             i++;
             // Handled above
           }
  +        else if("-DIAG".equalsIgnoreCase(argv[i]))
  +        {
  +          doDiag = true;
  +        }
           else if("-XML".equalsIgnoreCase(argv[i]))
           {
             outputType = "xml";
  @@ -436,6 +441,7 @@
         // The main XSL transformation occurs here!
         try
         {
  +        long start = System.currentTimeMillis();
           if(null != dumpFileName)
           {
             dumpWriter = new PrintWriter( new FileWriter(dumpFileName) );
  @@ -538,7 +544,10 @@
             diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL, null)); //"XSL Process was not successful.");
             System.exit(-1);
           }
  -        
  +        long stop = System.currentTimeMillis();
  +        long millisecondsDuration = stop - start;
  +        if(doDiag)
  +          diagnosticsWriter.println("\n\n========\nTransform of "+inFileName+" via "+xslFileName+" took "+millisecondsDuration+" ms");
         }
         catch(SAXParseException spe)
         {
  
  
  
  1.2       +1 -1      xml-xalan/java/src/org/apache/xalan/xslt/StylesheetRoot.java
  
  Index: StylesheetRoot.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/StylesheetRoot.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StylesheetRoot.java	2000/07/25 16:05:44	1.1
  +++ StylesheetRoot.java	2000/10/02 02:43:11	1.2
  @@ -63,7 +63,7 @@
   import org.xml.sax.*;
   import org.xml.sax.helpers.*;
   import trax.ProcessorException;
  -import org.apache.xml.serialize.*;
  +import serialize.*;
   
   /**
    * <meta name="usage" content="general"/> 
  
  
  
  1.2       +1 -1      xml-xalan/java/src/org/apache/xalan/xslt/XSLTProcessor.java
  
  Index: XSLTProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLTProcessor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XSLTProcessor.java	2000/07/25 16:05:44	1.1
  +++ XSLTProcessor.java	2000/10/02 02:43:11	1.2
  @@ -79,7 +79,7 @@
   import org.xml.sax.SAXException;
   import java.io.OutputStream;
   import java.io.UnsupportedEncodingException;
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   import org.xml.sax.ext.LexicalHandler;
   
   /**
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/BaseMarkupSerializer.java
  
  Index: BaseMarkupSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  // Aug 25, 2000:
  //   Fixed processing instruction printing inside element content
  //   to not escape content. Reported by Mikael Staldal
  //   <d9...@d.kth.se>
  // Aug 25, 2000:
  //   Added ability to omit comments.
  //   Contributed by Anupam Bagchi <ab...@jtcsv.com>
  // Aug 26, 2000:
  //   Fixed bug in newline handling when preserving spaces.
  //   Contributed by Mike Dusseault <md...@home.com>
  // Aug 29, 2000:
  //   Fixed state.unescaped not being set to false when
  //   entering element state.
  //   Reported by Lowell Vaughn <lv...@agillion.com>
  
  
  package org.apache.xml.serialize.transition;
  
  
  import java.io.Writer;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.util.Vector;
  import java.util.Hashtable;
  import java.util.StringTokenizer;
  
  import org.w3c.dom.*;
  import org.xml.sax.DocumentHandler;
  import org.xml.sax.DTDHandler;
  import org.xml.sax.Locator;
  import org.xml.sax.SAXException;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.Attributes;
  import org.xml.sax.ext.LexicalHandler;
  import org.xml.sax.ext.DeclHandler;
  
  import serialize.OutputFormat;
  import serialize.Serializer;
  import serialize.DOMSerializer;
  import serialize.SerializerHandler;
  
  /**
   * Base class for a serializer supporting both DOM and SAX pretty
   * serializing of XML/HTML/XHTML documents. Derives classes perform
   * the method-specific serializing, this class provides the common
   * serializing mechanisms.
   * <p>
   * The serializer must be initialized with the proper writer and
   * output format before it can be used by calling {@link #init}.
   * The serializer can be reused any number of times, but cannot
   * be used concurrently by two threads.
   * <p>
   * If an output stream is used, the encoding is taken from the
   * output format (defaults to <tt>UTF-8</tt>). If a writer is
   * used, make sure the writer uses the same encoding (if applies)
   * as specified in the output format.
   * <p>
   * The serializer supports both DOM and SAX. DOM serializing is done
   * by calling {@link #serialize} and SAX serializing is done by firing
   * SAX events and using the serializer as a document handler.
   * This also applies to derived class.
   * <p>
   * If an I/O exception occurs while serializing, the serializer
   * will not throw an exception directly, but only throw it
   * at the end of serializing (either DOM or SAX's {@link
   * org.xml.sax.DocumentHandler#endDocument}.
   * <p>
   * For elements that are not specified as whitespace preserving,
   * the serializer will potentially break long text lines at space
   * boundaries, indent lines, and serialize elements on separate
   * lines. Line terminators will be regarded as spaces, and
   * spaces at beginning of line will be stripped.
   * <p>
   * When indenting, the serializer is capable of detecting seemingly
   * element content, and serializing these elements indented on separate
   * lines. An element is serialized indented when it is the first or
   * last child of an element, or immediate following or preceding
   * another element.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see Serializer
   * @see DOMSerializer
   */
  public abstract class BaseMarkupSerializer
    implements ContentHandler, DocumentHandler, LexicalHandler,
    DTDHandler, DeclHandler, DOMSerializer, 
    Serializer, SerializerHandler
  {
  
  
      /**
       * Identifies the last printable character in the Unicode range
       * that is supported by the encoding used with this serializer.
       * For 8-bit encodings this will be either 0x7E or 0xFF.
       * For 16-bit encodings this will be 0xFFFF. Characters that are
       * not printable will be escaped using character references.
       */
      private int              _lastPrintable = 0x7E;
  
  
      /**
       * Holds array of all element states that have been entered.
       * The array is automatically resized. When leaving an element,
       * it's state is not removed but reused when later returning
       * to the same nesting level.
       */
      private ElementState[]  _elementStates;
  
  
      /**
       * The index of the next state to place in the array,
       * or one plus the index of the current state. When zero,
       * we are in no state.
       */
      private int             _elementStateCount;
  
  
      /**
       * Vector holding comments and PIs that come before the root
       * element (even after it), see {@link #serializePreRoot}.
       */
      private Vector          _preRoot;
  
  
      /**
       * If the document has been started (header serialized), this
       * flag is set to true so it's not started twice.
       */
      protected boolean       _started;
  
  
      /**
       * True if the serializer has been prepared. This flag is set
       * to false when the serializer is reset prior to using it,
       * and to true after it has been prepared for usage.
       */
      private boolean         _prepared;
  
  
      /**
       * Association between namespace URIs (keys) and prefixes (values).
       * Accumulated here prior to starting an element and placing this
       * list in the element state.
       */
      protected Hashtable     _prefixes;
  
  
      /**
       * The system identifier of the document type, if known.
       */
      protected String        _docTypePublicId;
  
  
      /**
       * The system identifier of the document type, if known.
       */
      protected String        _docTypeSystemId;
  
  
      /**
       * The output format associated with this serializer. This will never
       * be a null reference. If no format was passed to the constructor,
       * the default one for this document type will be used. The format
       * object is never changed by the serializer.
       */
      protected OutputFormat   _format;
  
  
      /**
       * The printer used for printing text parts.
       */
      protected Printer       _printer;
  
  
      /**
       * True if indenting printer.
       */
      protected boolean       _indenting;
  
  
      /**
       * The underlying writer.
       */
      private Writer          _writer;
  
  
      /**
       * The output stream.
       */
      private OutputStream    _output;
  
  
      //--------------------------------//
      // Constructor and initialization //
      //--------------------------------//
  
  
      /**
       * Protected constructor can only be used by derived class.
       * Must initialize the serializer before serializing any document,
       * see {@link #init}.
       */
      protected BaseMarkupSerializer( OutputFormat format )
      {
          int i;
  
          _elementStates = new ElementState[ 10 ];
          for ( i = 0 ; i < _elementStates.length ; ++i )
              _elementStates[ i ] = new ElementState();
          _format = format;
      }
      
      /**
       * Protected constructor can only be used by derived class.
       * Must initialize the serializer before serializing any document,
       * see {@link #init}.
       */
      protected BaseMarkupSerializer()
      {
        _elementStates = new ElementState[ 10 ];
        for ( int i = 0 ; i < _elementStates.length ; ++i )
          _elementStates[ i ] = new ElementState();
      }
  
  
      public DocumentHandler asDocumentHandler()
          throws IOException
      {
          prepare();
          return this;
      }
  
  
      public ContentHandler asContentHandler()
          throws IOException
      {
          prepare();
          return this;
      }
  
  
      public DOMSerializer asDOMSerializer()
          throws IOException
      {
          prepare();
          return this;
      }
  
  
      /**
       * Specifies an output stream to which the document should be
       * serialized. This method should not be called while the
       * serializer is in the process of serializing a document.
       * <p>
       * The encoding specified in the {@link OutputFormat} is used, or
       * if no encoding was specified, the default for the selected
       * output method.
       *
       * @param output The output stream
       */
      public void setOutputStream( OutputStream output )
      {
          String encoding;
  
          if ( output == null )
              throw new NullPointerException( "SER001 Argument 'output' is null." );
          _output = output;
          _writer = null;
          reset();
      }
  
  
      /**
       * Specifies a writer to which the document should be serialized.
       * This method should not be called while the serializer is in
       * the process of serializing a document.
       * <p>
       * The encoding specified for the {@link OutputFormat} must be
       * identical to the output format used with the writer.
       *
       * @param writer The output writer stream
       */
      public void setWriter( Writer writer )
      {
          if ( writer == null )
              throw new NullPointerException( "SER001 Argument 'writer' is null." );
          _writer = writer;
          _output = null;
          reset();
      }
  
      /**
       * Specifies an output format for this serializer. It the
       * serializer has already been associated with an output format,
       * it will switch to the new format. This method should not be
       * called while the serializer is in the process of serializing
       * a document.
       *
       * @param format The output format to use
       */
      public void setOutputFormat( OutputFormat format )
      {
          if ( format == null )
              throw new NullPointerException( "SER001 Argument 'format' is null." );
          _format = format;
          reset();
      }
      
      /**
       * Returns the output format for this serializer.
       *
       * @return The output format in use
       */
      public OutputFormat getOutputFormat()
      {
          return _format;
      }
  
  
      public boolean reset()
      {
          if ( _elementStateCount > 1 )
              throw new IllegalStateException( "Serializer reset in the middle of serialization" );
          _prepared = false;
          return true;
      }
  
  
      protected void prepare()
          throws IOException
      {
          if ( _prepared )
              return;
  
          if ( _writer == null && _output == null )
              throw new IOException( "SER002 No writer supplied for serializer" );
          // If the output stream has been set, use it to construct
          // the writer. It is possible that the serializer has been
          // reused with the same output stream and different encoding.
          if ( _output != null ) {
              if ( _format.getEncoding() == null )
                  _writer = new OutputStreamWriter( _output );
              else
                  _writer = Encodings.getWriter( _output, _format.getEncoding() );
          }
          // Determine the last printable character.
          if ( _format.getEncoding() == null )
              _lastPrintable = Encodings.getLastPrintable();
          else
              _lastPrintable = Encodings.getLastPrintable( _format.getEncoding() );
  
          if ( _format.getIndent() ) {
              _indenting = true;
              _printer = new IndentPrinter( _writer, _format );
          } else {
              _indenting = false;
              _printer = new Printer( _writer, _format );
          }
  
          ElementState state;
  
          _elementStateCount = 0;
          state = _elementStates[ 0 ];
          state.namespaceURI = null;
          state.localName = null;
          state.rawName = null;
          state.preserveSpace = _format.getPreserveSpace();
          state.empty = true;
          state.afterElement = false;
          state.doCData = state.inCData = false;
          state.prefixes = null;
  
          _docTypePublicId = _format.getDoctypePublicId();
          _docTypeSystemId = _format.getDoctypeSystemId();
          _started = false;
          _prepared = true;
      }
  
  
  
      //----------------------------------//
      // DOM document serializing methods //
      //----------------------------------//
  
  
      /**
       * Serializes the DOM element using the previously specified
       * writer and output format. Throws an exception only if
       * an I/O exception occured while serializing.
       *
       * @param elem The element to serialize
       * @throws IOException An I/O exception occured while
       *   serializing
       */
      public void serialize( Element elem )
          throws IOException
      {
          prepare();
          serializeNode( elem );
          _printer.flush();
          if ( _printer.getException() != null )
              throw _printer.getException();
      }
  
  
      /**
       * Serializes the DOM document fragmnt using the previously specified
       * writer and output format. Throws an exception only if
       * an I/O exception occured while serializing.
       *
       * @param elem The element to serialize
       * @throws IOException An I/O exception occured while
       *   serializing
       */
      public void serialize( DocumentFragment frag )
          throws IOException
      {
          prepare();
          serializeNode( frag );
          _printer.flush();
          if ( _printer.getException() != null )
              throw _printer.getException();
      }
  
  
      /**
       * Serializes the DOM document using the previously specified
       * writer and output format. Throws an exception only if
       * an I/O exception occured while serializing.
       *
       * @param doc The document to serialize
       * @throws IOException An I/O exception occured while
       *   serializing
       */
      public void serialize( Document doc )
          throws IOException
      {
          prepare();
          serializeNode( doc );
          serializePreRoot();
          _printer.flush();
          if ( _printer.getException() != null )
              throw _printer.getException();
      }
  
  
      //------------------------------------------//
      // SAX document handler serializing methods //
      //------------------------------------------//
  
  
      public void startDocument()
          throws SAXException
      {
          try {
              prepare();
          } catch ( IOException except ) {
              throw new SAXException( except.toString() );
          }
          // Nothing to do here. All the magic happens in startDocument(String)
      }
      
      
      public void characters( char[] chars, int start, int length )
      {
          ElementState state;
  
          state = content();
          // Check if text should be print as CDATA section or unescaped
          // based on elements listed in the output format (the element
          // state) or whether we are inside a CDATA section or entity.
  
          if ( state.inCData || state.doCData ) {
              int          saveIndent;
  
              // Print a CDATA section. The text is not escaped, but ']]>'
              // appearing in the code must be identified and dealt with.
              // The contents of a text node is considered space preserving.
              if ( ! state.inCData ) {
                  _printer.printText( "<![CDATA[" );
                  state.inCData = true;
              }
              saveIndent = _printer.getNextIndent();
              _printer.setNextIndent( 0 );
              for ( int index = 0 ; index < length ; ++index ) {
                  if ( index + 2 < length && chars[ index ] == ']' &&
                       chars[ index + 1 ] == ']' && chars[ index + 2 ] == '>' ) {
  
                      printText( chars, start, index + 2, true, true );
                      _printer.printText( "]]><![CDATA[" );
                      start += index + 2;
                      length -= index + 2;
                      index = 0;
                  }
              }
              if ( length > 0 )
                  printText( chars, start, length, true, true );
              _printer.setNextIndent( saveIndent );
  
          } else {
  
              int saveIndent;
  
              if ( state.preserveSpace ) {
                  // If preserving space then hold of indentation so no
                  // excessive spaces are printed at line breaks, escape
                  // the text content without replacing spaces and print
                  // the text breaking only at line breaks.
                  saveIndent = _printer.getNextIndent();
                  _printer.setNextIndent( 0 );
                  printText( chars, start, length, true, state.unescaped );
                  _printer.setNextIndent( saveIndent );
              } else {
                  printText( chars, start, length, false, state.unescaped );
              }
          }
      }
  
  
      public void ignorableWhitespace( char[] chars, int start, int length )
      {
          int i;
  
          content();
  
          // Print ignorable whitespaces only when indenting, after
          // all they are indentation. Cancel the indentation to
          // not indent twice.
          if ( _indenting ) {
              _printer.setThisIndent( 0 );
              for ( i = start ; length-- > 0 ; ++i )
                  _printer.printText( chars[ i ] );
          }
      }
  
  
      public void processingInstruction( String target, String code )
      {
          int          index;
          StringBuffer buffer;
          ElementState state;
  
          state = content();
          buffer = new StringBuffer( 40 );
  
          // Create the processing instruction textual representation.
          // Make sure we don't have '?>' inside either target or code.
          index = target.indexOf( "?>" );
          if ( index >= 0 )
              buffer.append( "<?" ).append( target.substring( 0, index ) );
          else
              buffer.append( "<?" ).append( target );
          if ( code != null ) {
              buffer.append( ' ' );
              index = code.indexOf( "?>" );
              if ( index >= 0 )
                  buffer.append( code.substring( 0, index ) );
              else
                  buffer.append( code );
          }
          buffer.append( "?>" );
  
          // If before the root element (or after it), do not print
          // the PI directly but place it in the pre-root vector.
          if ( isDocumentState() ) {
              if ( _preRoot == null )
                  _preRoot = new Vector();
              _preRoot.addElement( buffer.toString() );
          } else {
              _printer.indent();
              printText( buffer.toString(), true, true );
              _printer.unindent();
          }
      }
  
  
      public void comment( char[] chars, int start, int length )
      {
          comment( new String( chars, start, length ) );
      }
  
  
      public void comment( String text )
      {
          StringBuffer buffer;
          int          index;
          ElementState state;
          
          // -sb
          // if ( _format.getOmitComments() )
          //    return;
  
          state  = content();
          buffer = new StringBuffer( 40 );
          // Create the processing comment textual representation.
          // Make sure we don't have '-->' inside the comment.
          index = text.indexOf( "-->" );
          if ( index >= 0 )
              buffer.append( "<!--" ).append( text.substring( 0, index ) ).append( "-->" );
          else
              buffer.append( "<!--" ).append( text ).append( "-->" );
  
          // If before the root element (or after it), do not print
          // the comment directly but place it in the pre-root vector.
          if ( isDocumentState() ) {
              if ( _preRoot == null )
                  _preRoot = new Vector();
              _preRoot.addElement( buffer.toString() );
          } else {
              _printer.indent();
              printText( buffer.toString(), false, true );
              _printer.unindent();
          }
      }
  
  
      public void startCDATA()
      {
          ElementState state;
  
          state = getElementState();
          state.doCData = true;
      }
  
  
      public void endCDATA()
      {
          ElementState state;
  
          state = getElementState();
          state.doCData = false;
      }
  
  
      public void startNonEscaping()
      {
          ElementState state;
  
          state = getElementState();
          state.unescaped = true;
      }
  
  
      public void endNonEscaping()
      {
          ElementState state;
  
          state = getElementState();
          state.unescaped = false;
      }
  
  
      public void startPreserving()
      {
          ElementState state;
  
          state = getElementState();
          state.preserveSpace = true;
      }
  
  
      public void endPreserving()
      {
          ElementState state;
  
          state = getElementState();
          state.preserveSpace = false;
      }
  
  
      /**
       * Called at the end of the document to wrap it up.
       * Will flush the output stream and throw an exception
       * if any I/O error occured while serializing.
       *
       * @throws SAXException An I/O exception occured during
       *  serializing
       */
      public void endDocument()
          throws SAXException
      {
          // Print all the elements accumulated outside of
          // the root element.
          serializePreRoot();
          // Flush the output, this is necessary for buffered output.
          _printer.flush();
          // If an exception was thrown during serializing, this would
          // be the best time to report it.
          if ( _printer.getException() != null )
              throw new SAXException( _printer.getException() );
      }
  
  
      public void startEntity( String name )
      {
          // ???
      }
  
  
      public void endEntity( String name )
      {
          // ???
      }
  
  
      public void setDocumentLocator( Locator locator )
      {
          // Nothing to do
      }
  
  
      //-----------------------------------------//
      // SAX content handler serializing methods //
      //-----------------------------------------//
  
  
      public void skippedEntity ( String name )
          throws SAXException
      {
          endCDATA();
          content();
          _printer.printText( '&' );
          _printer.printText( name );
          _printer.printText( ';' );
      }
  
  
      public void startPrefixMapping( String prefix, String uri )
          throws SAXException
      {
          if ( _prefixes == null )
              _prefixes = new Hashtable();
          _prefixes.put( uri, prefix == null ? "" : prefix );
      }
  
  
      public void endPrefixMapping( String prefix )
          throws SAXException
      {
      }
  
  
      //------------------------------------------//
      // SAX DTD/Decl handler serializing methods //
      //------------------------------------------//
  
  
      public void startDTD( String name, String publicId, String systemId )
      {
          _printer.enterDTD();
          _docTypePublicId = publicId;
          _docTypeSystemId = systemId;
      }
  
  
      public void endDTD()
      {
          // Nothing to do here, all the magic occurs in startDocument(String).
      }
  
  
      public void elementDecl( String name, String model )
      {
          _printer.enterDTD();
          _printer.printText( "<!ELEMENT " );
          _printer.printText( name );
          _printer.printText( ' ' );
          _printer.printText( model );
          _printer.printText( '>' );
          if ( _indenting )
              _printer.breakLine();
      }
  
  
      public void attributeDecl( String eName, String aName, String type,
                                 String valueDefault, String value )
      {
          _printer.enterDTD();
          _printer.printText( "<!ATTLIST " );
          _printer.printText( eName );
          _printer.printText( ' ' );
          _printer.printText( aName );
          _printer.printText( ' ' );
          _printer.printText( type );
          if ( valueDefault != null ) {
              _printer.printText( ' ' );
              _printer.printText( valueDefault );
          }
          if ( value != null ) {
              _printer.printText( " \"" );
              printEscaped( value );
              _printer.printText( '"' );
          }
          _printer.printText( '>' );
          if ( _indenting )
              _printer.breakLine();
      }
  
  
      public void internalEntityDecl( String name, String value )
      {
          _printer.enterDTD();
          _printer.printText( "<!ENTITY " );
          _printer.printText( name );
          _printer.printText( " \"" );
          printEscaped( value );
          _printer.printText( "\">" );
          if ( _indenting )
              _printer.breakLine();
      }
  
  
      public void externalEntityDecl( String name, String publicId, String systemId )
      {
          _printer.enterDTD();
          unparsedEntityDecl( name, publicId, systemId, null );
      }
  
  
      public void unparsedEntityDecl( String name, String publicId,
                                      String systemId, String notationName )
      {
          _printer.enterDTD();
          if ( publicId == null ) {
              _printer.printText( "<!ENTITY " );
              _printer.printText( name );
              _printer.printText( " SYSTEM " );
              printDoctypeURL( systemId );
          } else {
              _printer.printText( "<!ENTITY " );
              _printer.printText( name );
              _printer.printText( " PUBLIC " );
              printDoctypeURL( publicId );
              _printer.printText( ' ' );
              printDoctypeURL( systemId );
          }
          if ( notationName != null ) {
              _printer.printText( " NDATA " );
              _printer.printText( notationName );
          }
          _printer.printText( '>' );
          if ( _indenting )
              _printer.breakLine();
      }
  
  
      public void notationDecl( String name, String publicId, String systemId )
      {
          _printer.enterDTD();
          if ( publicId != null ) {
              _printer.printText( "<!NOTATION " );
              _printer.printText( name );
              _printer.printText( " PUBLIC " );
              printDoctypeURL( publicId );
              if ( systemId != null ) {
                  _printer.printText( ' ' );
                  printDoctypeURL( systemId );
              }
          } else {
              _printer.printText( "<!NOTATION " );
              _printer.printText( name );
              _printer.printText( " SYSTEM " );
              printDoctypeURL( systemId );
          }
          _printer.printText( '>' );
          if ( _indenting )
              _printer.breakLine();
      }
  
  
      //------------------------------------------//
      // Generic node serializing methods methods //
      //------------------------------------------//
  
  
      /**
       * Serialize the DOM node. This method is shared across XML, HTML and XHTML
       * serializers and the differences are masked out in a separate {@link
       * #serializeElement}.
       *
       * @param node The node to serialize
       * @see #serializeElement
       */
      protected void serializeNode( Node node )
      {
          // Based on the node type call the suitable SAX handler.
          // Only comments entities and documents which are not
          // handled by SAX are serialized directly.
          switch ( node.getNodeType() ) {
          case Node.TEXT_NODE : {
              String text;
  
              text = node.getNodeValue();
              if ( text != null )
                  characters( node.getNodeValue() );
              break;
          }
  
          case Node.CDATA_SECTION_NODE : {
              String text;
  
              text = node.getNodeValue();
              if ( text != null ) {
                  startCDATA();
                  characters( node.getNodeValue() );
                  endCDATA();
              }
              break;
          }
  
          case Node.COMMENT_NODE : {
              String text;
  
              // -sb
              // if ( ! _format.getOmitComments() ) 
              {
                text = node.getNodeValue();
                if ( text != null )
                  comment( node.getNodeValue() );
              }
              break;
          }
  
          case Node.ENTITY_REFERENCE_NODE : {
              Node         child;
  
              endCDATA();
              content();
              child = node.getFirstChild();
              while ( child != null ) {
                  serializeNode( child );
                  child = child.getNextSibling();
              }
              break;
          }
  
          case Node.PROCESSING_INSTRUCTION_NODE :
              processingInstruction( node.getNodeName(), node.getNodeValue() );
              break;
  
          case Node.ELEMENT_NODE :
              serializeElement( (Element) node );
              break;
  
          case Node.DOCUMENT_NODE : {
              DocumentType      docType;
              DOMImplementation domImpl;
              NamedNodeMap      map;
              Entity            entity;
              Notation          notation;
              int               i;
  
              // If there is a document type, use the SAX events to
              // serialize it.
              docType = ( (Document) node ).getDoctype();
              if (docType != null) {
                  // DOM Level 2 (or higher)
                  domImpl = ( (Document) node ).getImplementation();
                  try {
                      String internal;
  
                      startDTD( docType.getName(), docType.getPublicId(), docType.getSystemId() );
                      internal = docType.getInternalSubset();
                      if ( internal != null && internal.length() > 0 )
                          _printer.printText( internal );
                      endDTD();
                  }
                  // DOM Level 1 -- does implementation have methods?
                  catch (NoSuchMethodError nsme) {
                      Class docTypeClass = docType.getClass();
  
                      String docTypePublicId = null;
                      String docTypeSystemId = null;
                      try {
                          java.lang.reflect.Method getPublicId = docTypeClass.getMethod("getPublicId", null);
                          if (getPublicId.getReturnType().equals(String.class)) {
                              docTypePublicId = (String)getPublicId.invoke(docType, null);
                          }
                      }
                      catch (Exception e) {
                          // ignore
                      }
                      try {
                          java.lang.reflect.Method getSystemId = docTypeClass.getMethod("getSystemId", null);
                          if (getSystemId.getReturnType().equals(String.class)) {
                              docTypeSystemId = (String)getSystemId.invoke(docType, null);
                          }
                      }
                      catch (Exception e) {
                          // ignore
                      }
                      startDTD( docType.getName(), docTypePublicId, docTypeSystemId);
                      endDTD();
                  }
              }
              // !! Fall through
          }
          case Node.DOCUMENT_FRAGMENT_NODE : {
              Node         child;
  
              // By definition this will happen if the node is a document,
              // document fragment, etc. Just serialize its contents. It will
              // work well for other nodes that we do not know how to serialize.
              child = node.getFirstChild();
              while ( child != null ) {
                  serializeNode( child );
                  child = child.getNextSibling();
              }
              break;
          }
  
          default:
              break;
          }
      }
  
  
      /**
       * Must be called by a method about to print any type of content.
       * If the element was just opened, the opening tag is closed and
       * will be matched to a closing tag. Returns the current element
       * state with <tt>empty</tt> and <tt>afterElement</tt> set to false.
       *
       * @return The current element state
       */
      protected ElementState content()
      {
          ElementState state;
  
          state = getElementState();
          if ( ! isDocumentState() ) {
              // Need to close CData section first
              if ( state.inCData && ! state.doCData ) {
                  _printer.printText( "]]>" );
                  state.inCData = false;
              }
              // If this is the first content in the element,
              // change the state to not-empty and close the
              // opening element tag.
              if ( state.empty ) {
                  _printer.printText( '>' );
                  state.empty = false;
              }
              // Except for one content type, all of them
              // are not last element. That one content
              // type will take care of itself.
              state.afterElement = false;
          }
          return state;
      }
  
  
      /**
       * Called to print the text contents in the prevailing element format.
       * Since this method is capable of printing text as CDATA, it is used
       * for that purpose as well. White space handling is determined by the
       * current element state. In addition, the output format can dictate
       * whether the text is printed as CDATA or unescaped.
       *
       * @param text The text to print
       * @param unescaped True is should print unescaped
       */
      protected void characters( String text )
      {
          ElementState state;
  
          state = content();
          // Check if text should be print as CDATA section or unescaped
          // based on elements listed in the output format (the element
          // state) or whether we are inside a CDATA section or entity.
  
          if ( state.inCData || state.doCData ) {
              StringBuffer buffer;
              int          index;
              int          saveIndent;
  
              // Print a CDATA section. The text is not escaped, but ']]>'
              // appearing in the code must be identified and dealt with.
              // The contents of a text node is considered space preserving.
              buffer = new StringBuffer( text.length() );
              if ( ! state.inCData ) {
                  buffer.append( "<![CDATA[" );
                  state.inCData = true;
              }
              index = text.indexOf( "]]>" );
              while ( index >= 0 ) {
                  buffer.append( text.substring( 0, index + 2 ) ).append( "]]><![CDATA[" );
                  text = text.substring( index + 2 );
                  index = text.indexOf( "]]>" );
              }
              buffer.append( text );
              saveIndent = _printer.getNextIndent();
              _printer.setNextIndent( 0 );
              printText( buffer.toString(), true, true );
              _printer.setNextIndent( saveIndent );
  
          } else {
  
              int saveIndent;
  
              if ( state.preserveSpace ) {
                  // If preserving space then hold of indentation so no
                  // excessive spaces are printed at line breaks, escape
                  // the text content without replacing spaces and print
                  // the text breaking only at line breaks.
                  saveIndent = _printer.getNextIndent();
                  _printer.setNextIndent( 0 );
                  printText( text, true, state.unescaped );
                  _printer.setNextIndent( saveIndent );
              } else {
                  printText( text, false, state.unescaped );
              }
          }
      }
  
  
      /**
       * Returns the suitable entity reference for this character value,
       * or null if no such entity exists. Calling this method with <tt>'&amp;'</tt>
       * will return <tt>"&amp;amp;"</tt>.
       *
       * @param ch Character value
       * @return Character entity name, or null
       */
      protected abstract String getEntityRef( char ch );
  
  
      /**
       * Called to serializee the DOM element. The element is serialized based on
       * the serializer's method (XML, HTML, XHTML).
       *
       * @param elem The element to serialize
       */
      protected abstract void serializeElement( Element elem );
  
  
      /**
       * Comments and PIs cannot be serialized before the root element,
       * because the root element serializes the document type, which
       * generally comes first. Instead such PIs and comments are
       * accumulated inside a vector and serialized by calling this
       * method. Will be called when the root element is serialized
       * and when the document finished serializing.
       */
      protected void serializePreRoot()
      {
          int i;
  
          if ( _preRoot != null ) {
              for ( i = 0 ; i < _preRoot.size() ; ++i ) {
                  printText( (String) _preRoot.elementAt( i ), true, true );
                  _printer.breakLine();
              }
              _preRoot.removeAllElements();
          }
      }
  
  
      //---------------------------------------------//
      // Text pretty printing and formatting methods //
      //---------------------------------------------//
  
  
      /**
       * Called to print additional text with whitespace handling.
       * If spaces are preserved, the text is printed as if by calling
       * {@link #printText(String)} with a call to {@link #breakLine}
       * for each new line. If spaces are not preserved, the text is
       * broken at space boundaries if longer than the line width;
       * Multiple spaces are printed as such, but spaces at beginning
       * of line are removed.
       *
       * @param text The text to print
       * @param preserveSpace Space preserving flag
       * @param unescaped Print unescaped
       */
      protected final void printText( char[] chars, int start, int length,
                                      boolean preserveSpace, boolean unescaped )
      {
          int index;
          char ch;
  
          if ( preserveSpace ) {
              // Preserving spaces: the text must print exactly as it is,
              // without breaking when spaces appear in the text and without
              // consolidating spaces. If a line terminator is used, a line
              // break will occur.
              while ( length-- > 0 ) {
                  ch = chars[ start ];
                  ++start;
                  if ( ch == '\n' || ch == '\r' || unescaped )
                      _printer.printText( ch );
                  else
                      printEscaped( ch );
              }
          } else {
              // Not preserving spaces: print one part at a time, and
              // use spaces between parts to break them into different
              // lines. Spaces at beginning of line will be stripped
              // by printing mechanism. Line terminator is treated
              // no different than other text part.
              while ( length-- > 0 ) {
                  ch = chars[ start ];
                  ++start;
                  if ( ch == ' ' || ch == '\f' || ch == '\t' || ch == '\n' || ch == '\r' )
                      _printer.printSpace();
                  else if ( unescaped )
                      _printer.printText( ch );
                  else
                      printEscaped( ch );
              }
          }
      }
  
  
      protected final void printText( String text, boolean preserveSpace, boolean unescaped )
      {
          int index;
          char ch;
  
          if ( preserveSpace ) {
              // Preserving spaces: the text must print exactly as it is,
              // without breaking when spaces appear in the text and without
              // consolidating spaces. If a line terminator is used, a line
              // break will occur.
              for ( index = 0 ; index < text.length() ; ++index ) {
                  ch = text.charAt( index );
                  if ( ch == '\n' || ch == '\r' || unescaped ) 
                      _printer.printText( ch );
                  else
                      printEscaped( ch );
              }
          } else {
              // Not preserving spaces: print one part at a time, and
              // use spaces between parts to break them into different
              // lines. Spaces at beginning of line will be stripped
              // by printing mechanism. Line terminator is treated
              // no different than other text part.
              for ( index = 0 ; index < text.length() ; ++index ) {
                  ch = text.charAt( index );
                  if ( ch == ' ' || ch == '\f' || ch == '\t' || ch == '\n' || ch == '\r' )
                      _printer.printSpace();
                  else if ( unescaped )
                      _printer.printText( ch );
                  else
                      printEscaped( ch );
              }
          }
      }
  
  
      /**
       * Print a document type public or system identifier URL.
       * Encapsulates the URL in double quotes, escapes non-printing
       * characters and print it equivalent to {@link #printText}.
       *
       * @param url The document type url to print
       */
      protected void printDoctypeURL( String url )
      {
          int                i;
  
          _printer.printText( '"' );
          for( i = 0 ; i < url.length() ; ++i ) {
              if ( url.charAt( i ) == '"' ||  url.charAt( i ) < 0x20 || url.charAt( i ) > 0x7F ) {
                  _printer.printText( '%' );
                  _printer.printText( Integer.toHexString( url.charAt( i ) ) );
              } else
                  _printer.printText( url.charAt( i ) );
          }
          _printer.printText( '"' );
      }
  
      protected void printEscaped( char ch )
      {
          String charRef;
  
          // If there is a suitable entity reference for this
          // character, print it. The list of available entity
          // references is almost but not identical between
          // XML and HTML.
          charRef = getEntityRef( ch );
          if ( charRef != null ) {
              _printer.printText( '&' );
              _printer.printText( charRef );
              _printer.printText( ';' );
          } else if ( ( ch >= ' ' && ch <= _lastPrintable && ch != 0xF7 ) ||
                      ch == '\n' || ch == '\r' || ch == '\t' ) {
              // If the character is not printable, print as character reference.
              // Non printables are below ASCII space but not tab or line
              // terminator, ASCII delete, or above a certain Unicode threshold.
              _printer.printText( ch );
          } else {
              _printer.printText( "&#" );
              _printer.printText( Integer.toString( ch ) );
              _printer.printText( ';' );
          }
      }
  
  
      /**
       * Escapes a string so it may be printed as text content or attribute
       * value. Non printable characters are escaped using character references.
       * Where the format specifies a deault entity reference, that reference
       * is used (e.g. <tt>&amp;lt;</tt>).
       *
       * @param source The string to escape
       */
      protected void printEscaped( String source )
      {
          for ( int i = 0 ; i < source.length() ; ++i )
              printEscaped( source.charAt( i ) );
      }
  
  
      //--------------------------------//
      // Element state handling methods //
      //--------------------------------//
  
  
      /**
       * Return the state of the current element.
       *
       * @return Current element state
       */
      protected ElementState getElementState()
      {
          return _elementStates[ _elementStateCount ];
      }
  
  
      /**
       * Enter a new element state for the specified element.
       * Tag name and space preserving is specified, element
       * state is initially empty.
       *
       * @return Current element state, or null
       */
      protected ElementState enterElementState( String namespaceURI, String localName,
                                                String rawName, boolean preserveSpace )
      {
          ElementState state;
  
          if ( _elementStateCount + 1 == _elementStates.length ) {
              ElementState[] newStates;
  
              // Need to create a larger array of states. This does not happen
              // often, unless the document is really deep.
              newStates = new ElementState[ _elementStates.length + 10 ];
              for ( int i = 0 ; i < _elementStates.length ; ++i )
                  newStates[ i ] = _elementStates[ i ];
              for ( int i = _elementStates.length ; i < newStates.length ; ++i )
                  newStates[ i ] = new ElementState();
              _elementStates = newStates;
          }
  
          ++_elementStateCount;
          state = _elementStates[ _elementStateCount ];
          state.namespaceURI = namespaceURI;
          state.localName = localName;
          state.rawName = rawName;
          state.preserveSpace = preserveSpace;
          state.empty = true;
          state.afterElement = false;
          state.doCData = state.inCData = false;
          state.unescaped = false;
          state.prefixes = _prefixes;
  
          _prefixes = null;
          return state;
      }
  
  
      /**
       * Leave the current element state and return to the
       * state of the parent element. If this was the root
       * element, return to the state of the document.
       *
       * @return Previous element state
       */
      protected ElementState leaveElementState()
      {
          if ( _elementStateCount > 0 ) {
              _prefixes = _elementStates[ _elementStateCount ].prefixes;
              -- _elementStateCount;
              return _elementStates[ _elementStateCount ];
          } else
              throw new IllegalStateException( "Internal error: element state is zero" );
      }
  
  
      /**
       * Returns true if in the state of the document.
       * Returns true before entering any element and after
       * leaving the root element.
       *
       * @return True if in the state of the document
       */
      protected boolean isDocumentState()
      {
          return _elementStateCount == 0;
      }
  
  
      /**
       * Returns the namespace prefix for the specified URI.
       * If the URI has been mapped to a prefix, returns the
       * prefix, otherwise returns null.
       *
       * @param namespaceURI The namespace URI
       * @return The namespace prefix if known, or null
       */
      protected String getPrefix( String namespaceURI )
      {
          String    prefix;
  
          if ( _prefixes != null ) {
              prefix = (String) _prefixes.get( namespaceURI );
              if ( prefix != null )
                  return prefix;
          }
          if ( _elementStateCount == 0 )
              return null;
          else {
              for ( int i = _elementStateCount ; i > 0 ; --i ) {
                  if ( _elementStates[ i ].prefixes != null ) {
                      prefix = (String) _elementStates[ i ].prefixes.get( namespaceURI );
                      if ( prefix != null )
                          return prefix;
                  }
              }
          }
          return null;
      }
  
  
  }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/ElementState.java
  
  Index: ElementState.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.util.Hashtable;
  
  
  /**
   * Holds the state of the currently serialized element.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see BaseMarkupSerializer
   */
  class ElementState
  {
  
  
      /**
       * The element's raw tag name (local or prefix:local).
       */
      String rawName;
  
  
      /**
       * The element's local tag name.
       */
      String localName;
  
  
      /**
       * The element's namespace URI.
       */
      String namespaceURI;
  
  
      /**
       * True if element is space preserving.
       */
      boolean preserveSpace;
  
  
      /**
       * True if element is empty. Turns false immediately
       * after serializing the first contents of the element.
       */
      boolean empty;
  
  
      /**
       * True if the last serialized node was an element node.
       */
      boolean afterElement;
  
  
      /**
       * True if textual content of current element should be
       * serialized as CDATA section.
       */
      boolean doCData;
  
  
      /**
       * True if textual content of current element should be
       * serialized as raw characters (unescaped).
       */
      boolean unescaped;
  
  
      /**
       * True while inside CData and printing text as CData.
       */
      boolean inCData;
  
  
      /**
       * Association between namespace URIs (keys) and prefixes (values).
       */
      Hashtable prefixes;
  
  
  }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/Encodings.java
  
  Index: Encodings.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.io.Writer;
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.UnsupportedEncodingException;
  
  
  /**
   * Provides information about encodings. Depends on the Java runtime
   * to provides writers for the different encodings, but can be used
   * to override encoding names and provide the last printable character
   * for each encoding.
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   */
  class Encodings
  {
  
  
      /**
       * The last printable character for unknown encodings.
       */
      static final int DefaultLastPrintable = 0x7F;
  
  
      /**
       * Returns a writer for the specified encoding based on
       * an output stream.
       *
       * @param output The output stream
       * @param encoding The encoding
       * @return A suitable writer
       * @throws UnsupportedEncodingException There is no convertor
       *  to support this encoding
       */
      static Writer getWriter( OutputStream output, String encoding )
          throws UnsupportedEncodingException
      {
          for ( int i = 0 ; i < _encodings.length ; ++i ) {
              if ( _encodings[ i ].name.equals( encoding ) )
                  return new OutputStreamWriter( output, _encodings[ i ].javaName );
          }
          return new OutputStreamWriter( output, encoding );
      }
  
  
      /**
       * Returns the last printable character for the specified
       * encoding.
       *
       * @param encoding The encoding
       * @return The last printable character
       */
      static int getLastPrintable( String encoding )
      {
          for ( int i = 0 ; i < _encodings.length ; ++i ) {
              if ( _encodings[ i ].name.equalsIgnoreCase( encoding ) )
                  return _encodings[ i ].lastPrintable;
          }
          return DefaultLastPrintable;
      }
  
  
      /**
       * Returns the last printable character for an unspecified
       * encoding.
       */
      static int getLastPrintable()
      {
          return DefaultLastPrintable;
      }
  
  
      /**
       * Holds information about a given encoding.
       */
      static final class EncodingInfo
      {
         
          /**
           * The encoding name.
           */ 
          final String name;
  
          /**
           * The name used by the Java convertor.
           */
          final String javaName;
  
          /**
           * The last printable character.
           */
          final int    lastPrintable;
  
          EncodingInfo( String name, String javaName, int lastPrintable )
          {
              this.name = name;
              this.javaName = javaName;
              this.lastPrintable = lastPrintable;
          }
  
      }
  
  
      /**
       * Constructs a list of all the supported encodings.
       */
      private static final EncodingInfo[] _encodings = new EncodingInfo[] {
          new EncodingInfo( "ASCII", "ASCII", 0x7F ),
          new EncodingInfo( "ISO-Latin-1", "ASCII", 0xFF ),
          new EncodingInfo( "ISO-8859-1", "ISO8859_1", 0xFF ),
          new EncodingInfo( "ISO-8859-2", "ISO8859_2", 0xFF ),
          new EncodingInfo( "ISO-8859-3", "ISO8859_3", 0xFF ),
          new EncodingInfo( "ISO-8859-4", "ISO8859_4", 0xFF ),
          new EncodingInfo( "ISO-8859-5", "ISO8859_5", 0xFF ),
          new EncodingInfo( "ISO-8859-6", "ISO8859_6", 0xFF ),
          new EncodingInfo( "ISO-8859-7", "ISO8859_7", 0xFF ),
          new EncodingInfo( "ISO-8859-8", "ISO8859_8", 0xFF ),
          new EncodingInfo( "ISO-8859-9", "ISO8859_9", 0xFF ),
          new EncodingInfo( "UTF-8", "UTF8", 0xFFFF ),
          new EncodingInfo( "UNICODE", "Unicode", 0xFFFF )
      };
  
  
  }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/HTMLSerializer.java
  
  Index: HTMLSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  // Aug 21, 2000:
  //  Fixed bug in startDocument not calling prepare.
  //  Reported by Mikael Staldal <d9...@d.kth.se>
  // Aug 21, 2000:
  //  Added ability to omit DOCTYPE declaration.
  
  
  package org.apache.xml.serialize.transition;
  
  
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.io.OutputStream;
  import java.io.Writer;
  import java.util.Enumeration;
  
  import org.w3c.dom.Element;
  import org.w3c.dom.Attr;
  import org.w3c.dom.Node;
  import org.w3c.dom.NamedNodeMap;
  import org.xml.sax.DocumentHandler;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.AttributeList;
  import org.xml.sax.Attributes;
  
  import serialize.OutputFormat;
  
  /**
   * Implements an HTML/XHTML serializer supporting both DOM and SAX
   * pretty serializing. HTML/XHTML mode is determined in the
   * constructor.  For usage instructions see {@link Serializer}.
   * <p>
   * If an output stream is used, the encoding is taken from the
   * output format (defaults to <tt>UTF-8</tt>). If a writer is
   * used, make sure the writer uses the same encoding (if applies)
   * as specified in the output format.
   * <p>
   * The serializer supports both DOM and SAX. DOM serializing is done
   * by calling {@link #serialize} and SAX serializing is done by firing
   * SAX events and using the serializer as a document handler.
   * <p>
   * If an I/O exception occurs while serializing, the serializer
   * will not throw an exception directly, but only throw it
   * at the end of serializing (either DOM or SAX's {@link
   * org.xml.sax.DocumentHandler#endDocument}.
   * <p>
   * For elements that are not specified as whitespace preserving,
   * the serializer will potentially break long text lines at space
   * boundaries, indent lines, and serialize elements on separate
   * lines. Line terminators will be regarded as spaces, and
   * spaces at beginning of line will be stripped.
   * <p>
   * XHTML is slightly different than HTML:
   * <ul>
   * <li>Element/attribute names are lower case and case matters
   * <li>Attributes must specify value, even if empty string
   * <li>Empty elements must have '/' in empty tag
   * <li>Contents of SCRIPT and STYLE elements serialized as CDATA
   * </ul>
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see Serializer
   */
  public class HTMLSerializer
      extends BaseMarkupSerializer
  {
  
  
      /**
       * True if serializing in XHTML format.
       */
      private static boolean _xhtml;
  
  
      public static String XHTMLNamespace = "";
  
  
  
  
      /**
       * Constructs a new HTML/XHTML serializer depending on the value of
       * <tt>xhtml</tt>. The serializer cannot be used without calling
       * {@link #init} first.
       *
       * @param xhtml True if XHTML serializing
       */
      protected HTMLSerializer( boolean xhtml, OutputFormat format )
      {
          super( format );
          _xhtml = xhtml;
      }
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputStream}
       * first.
       */
      public HTMLSerializer()
      {
          super();
          OutputFormat format = new OutputFormat();
          format.setMethod(Method.HTML);
          setOutputFormat(format);
      }
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputStream}
       * first.
       */
      public HTMLSerializer( OutputFormat format )
      {
          super();
          if(null != format)
          {
            format = new OutputFormat();
            format.setMethod(Method.HTML);
          }
          setOutputFormat(format);
      }
  
  
  
      /**
       * Constructs a new serializer that writes to the specified writer
       * using the specified output format. If <tt>format</tt> is null,
       * will use a default output format.
       *
       * @param writer The writer to use
       * @param format The output format to use, null for the default
       */
      public HTMLSerializer( Writer writer, OutputFormat format )
      {
          super();
          if(null != format)
          {
            format = new OutputFormat();
            format.setMethod(Method.HTML);
          }
          setWriter(writer);
      }
  
  
      /**
       * Constructs a new serializer that writes to the specified output
       * stream using the specified output format. If <tt>format</tt>
       * is null, will use a default output format.
       *
       * @param output The output stream to use
       * @param format The output format to use, null for the default
       */
      public HTMLSerializer( OutputStream output, OutputFormat format )
      {
          super();
          if(null != format)
          {
            format = new OutputFormat();
            format.setMethod(Method.HTML);
          }
          setOutputStream( output );
      }
      
      
      public void setOutputFormat( OutputFormat format )
      {
          if(null != format)
          {
            format = new OutputFormat();
            format.setMethod(Method.HTML);
          }
          super.setOutputFormat( format );
      }
      
  
      //-----------------------------------------//
      // SAX content handler serializing methods //
      //-----------------------------------------//
  
  
      public void startElement( String namespaceURI, String localName,
                                String rawName, Attributes attrs )
      {
          int          i;
          boolean      preserveSpace;
          ElementState state;
          String       name;
          String       value;
          String       htmlName;
          boolean      addNSAttr = false;
          
          if ( _printer == null )
              throw new IllegalStateException( "SER002 No writer supplied for serializer" );
          
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( localName == null ? rawName : localName );
          } else {
              // For any other element, if first in parent, then
              // close parent's opening tag and use the parnet's
              // space preserving.
              if ( state.empty )
                  _printer.printText( '>' );
              // Indent this element on a new line if the first
              // content of the parent element or immediately
              // following an element.
              if ( _indenting && ! state.preserveSpace &&
                   ( state.empty || state.afterElement ) )
                  _printer.breakLine();
          }
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
          
          if ( rawName == null ) {
              rawName = localName;
              if ( namespaceURI != null ) {
                  String prefix;
                  prefix = getPrefix( namespaceURI );
                  if ( prefix.length() > 0 )
                      rawName = prefix + ":" + localName;
              }
              addNSAttr = true;
          }
          if ( namespaceURI == null )
              htmlName = rawName;
          else {
              if ( namespaceURI.equals( XHTMLNamespace ) )
                  htmlName = localName;
              else
                  htmlName = null;
          }
          
          // XHTML: element names are lower case, DOM will be different
          _printer.printText( '<' );
          if ( _xhtml )
              _printer.printText( rawName.toLowerCase() );
          else
              _printer.printText( rawName );
          _printer.indent();
          
          // For each attribute serialize it's name and value as one part,
          // separated with a space so the element can be broken on
          // multiple lines.
          if ( attrs != null ) {
              for ( i = 0 ; i < attrs.getLength() ; ++i ) {
                  _printer.printSpace();
                  name = attrs.getQName( i ).toLowerCase();;
                  value = attrs.getValue( i );
                  if ( _xhtml || namespaceURI != null ) {
                      // XHTML: print empty string for null values.
                      if ( value == null ) {
                          _printer.printText( name );
                          _printer.printText( "=\"\"" );
                      } else {
                          _printer.printText( name );
                          _printer.printText( "=\"" );
                          printEscaped( value );
                          _printer.printText( '"' );
                      }
                  } else {
                      // HTML: Empty values print as attribute name, no value.
                      // HTML: URI attributes will print unescaped
                      if ( value == null || value.length() == 0 )
                          _printer.printText( name );
                      else if ( HTMLdtd.isURI( rawName, name ) ) {
                          _printer.printText( name );
                          _printer.printText( "=\"" ); 
                          _printer.printText( escapeURI( value ) );
                          _printer.printText( '"' );
                      } else if ( HTMLdtd.isBoolean( rawName, name ) )
                          _printer.printText( name );
                      else {
                          _printer.printText( name );
                          _printer.printText( "=\"" );
                          printEscaped( value );
                          _printer.printText( '"' );
                      }
                  }
              }
          }
          if ( htmlName != null && HTMLdtd.isPreserveSpace( htmlName ) )
              preserveSpace = true;
          
          if ( addNSAttr ) {
              Enumeration enum;
              
              enum = _prefixes.keys();
              while ( enum.hasMoreElements() ) {
                  _printer.printSpace();
                  value = (String) enum.nextElement();
                  name = (String) _prefixes.get( value );
                  if ( name.length() == 0 ) {
                      _printer.printText( "xmlns=\"" );
                      printEscaped( value );
                      _printer.printText( '"' );
                  } else {
                      _printer.printText( "xmlns:" );
                      _printer.printText( name );
                      _printer.printText( "=\"" );
                      printEscaped( value );
                      _printer.printText( '"' );
                  }
              }
          }
          
          // Now it's time to enter a new element state
          // with the tag name and space preserving.
          // We still do not change the curent element state.
          state = enterElementState( namespaceURI, localName, rawName, preserveSpace );
          
          // Prevents line breaks inside A/TD
          
          if ( htmlName != null && ( htmlName.equalsIgnoreCase( "A" ) ||
                                     htmlName.equalsIgnoreCase( "TD" ) ) ) {
              state.empty = false;
              _printer.printText( '>' );
          }
          
          // Handle SCRIPT and STYLE specifically by changing the
          // state of the current element to CDATA (XHTML) or
          // unescaped (HTML).
          if ( htmlName != null && ( rawName.equalsIgnoreCase( "SCRIPT" ) ||
                                     rawName.equalsIgnoreCase( "STYLE" ) ) ) {
              if ( _xhtml ) {
                  // XHTML: Print contents as CDATA section
                  state.doCData = true;
              } else {
                  // HTML: Print contents unescaped
                  state.unescaped = true;
              }
          }
      }
      
      
      public void endElement( String namespaceURI, String localName,
                              String rawName )
      {
          ElementState state;
          String       htmlName;
          
          // Works much like content() with additions for closing
          // an element. Note the different checks for the closed
          // element's state and the parent element's state.
          _printer.unindent();
          state = getElementState();
          
          if ( state.namespaceURI == null )
              htmlName = state.rawName;
          else {
              if ( state.namespaceURI.equals( XHTMLNamespace ) )
                  htmlName = state.localName;
              else
                  htmlName = null;
          }
          
          if ( _xhtml) {
              if ( state.empty ) {
                  _printer.printText( " />" );
              } else {
                  // Must leave CData section first
                  if ( state.inCData )
                      _printer.printText( "]]>" );
                  // XHTML: element names are lower case, DOM will be different
                  _printer.printText( "</" );
                  _printer.printText( state.rawName.toLowerCase() );
                  _printer.printText( '>' );
              }
          } else {
              if ( state.empty )
                  _printer.printText( '>' );
              // This element is not empty and that last content was
              // another element, so print a line break before that
              // last element and this element's closing tag.
              // [keith] Provided this is not an anchor.
              // HTML: some elements do not print closing tag (e.g. LI)
              if ( htmlName == null || ! HTMLdtd.isOnlyOpening( htmlName ) ) {
                  if ( _indenting && ! state.preserveSpace && state.afterElement )
                      _printer.breakLine();
                  // Must leave CData section first (Illegal in HTML, but still)
                  if ( state.inCData )
                      _printer.printText( "]]>" );
                  _printer.printText( "</" );
                  _printer.printText( state.rawName );
                  _printer.printText( '>' );
              }
          }
          // Leave the element state and update that of the parent
          // (if we're not root) to not empty and after element.
          state = leaveElementState();
          // Temporary hack to prevent line breaks inside A/TD
          if ( htmlName == null || ( ! htmlName.equalsIgnoreCase( "A" ) &&
                                     ! htmlName.equalsIgnoreCase( "TD" ) ) )
              
              state.afterElement = true;
          state.empty = false;
          if ( isDocumentState() )
              _printer.flush();
      }
      
      
      //------------------------------------------//
      // SAX document handler serializing methods //
      //------------------------------------------//
  
  
      public void characters( char[] chars, int start, int length )
      {
          ElementState state;
          
          // HTML: no CDATA section
          state = content();
          state.doCData = false;
          super.characters( chars, start, length );
      }
      
      
      public void startElement( String tagName, AttributeList attrs )
      {
          int          i;
          boolean      preserveSpace;
          ElementState state;
          String       name;
          String       value;
          
          if ( _printer == null )
              throw new IllegalStateException( "SER002 No writer supplied for serializer" );
          
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( tagName );
          } else {
              // For any other element, if first in parent, then
              // close parent's opening tag and use the parnet's
              // space preserving.
              if ( state.empty )
                  _printer.printText( '>' );
              // Indent this element on a new line if the first
              // content of the parent element or immediately
              // following an element.
              if ( _indenting && ! state.preserveSpace &&
                   ( state.empty || state.afterElement ) )
                  _printer.breakLine();
          }
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
          
          // XHTML: element names are lower case, DOM will be different
          _printer.printText( '<' );
          if ( _xhtml )
              _printer.printText( tagName.toLowerCase() );
          else
              _printer.printText( tagName );
          _printer.indent();
          
          // For each attribute serialize it's name and value as one part,
          // separated with a space so the element can be broken on
          // multiple lines.
          if ( attrs != null ) {
              for ( i = 0 ; i < attrs.getLength() ; ++i ) {
                  _printer.printSpace();
                  name = attrs.getName( i ).toLowerCase();;
                  value = attrs.getValue( i );
                  if ( _xhtml ) {
                      // XHTML: print empty string for null values.
                      if ( value == null ) {
                          _printer.printText( name );
                          _printer.printText( "=\"\"" );
                      } else {
                          _printer.printText( name );
                          _printer.printText( "=\"" ); 
                          printEscaped( value );
                          _printer.printText( '"' );
                      }
                  } else {
                      // HTML: Empty values print as attribute name, no value.
                      // HTML: URI attributes will print unescaped
                      if ( value == null || value.length() == 0 )
                          _printer.printText( name );
                      else if ( HTMLdtd.isURI( tagName, name ) ) {
                          _printer.printText( name );
                          _printer.printText( "=\"" ); 
                          _printer.printText( escapeURI( value ) );
                          _printer.printText( '"' );
                      } else if ( HTMLdtd.isBoolean( tagName, name ) )
                          _printer.printText( name );
                      else {
                          _printer.printText( name );
                          _printer.printText( "=\"" ); 
                          printEscaped( value );
                          _printer.printText( '"' );
                      }
                  }
              }
          }
          if ( HTMLdtd.isPreserveSpace( tagName ) )
              preserveSpace = true;
          
          // Now it's time to enter a new element state
          // with the tag name and space preserving.
          // We still do not change the curent element state.
          state = enterElementState( null, null, tagName, preserveSpace );
          
          // Prevents line breaks inside A/TD
          if ( tagName.equalsIgnoreCase( "A" ) || tagName.equalsIgnoreCase( "TD" ) ) {
              state.empty = false;
              _printer.printText( '>' );
          }
          
          // Handle SCRIPT and STYLE specifically by changing the
          // state of the current element to CDATA (XHTML) or
          // unescaped (HTML).
          if ( tagName.equalsIgnoreCase( "SCRIPT" ) ||
               tagName.equalsIgnoreCase( "STYLE" ) ) {
              if ( _xhtml ) {
                  // XHTML: Print contents as CDATA section
                  state.doCData = true;
              } else {
                  // HTML: Print contents unescaped
                  state.unescaped = true;
              }
          }
      }
      
      
      public void endElement( String tagName )
      {
          endElement( null, null, tagName );
      }
  
  
      //------------------------------------------//
      // Generic node serializing methods methods //
      //------------------------------------------//
  
  
      /**
       * Called to serialize the document's DOCTYPE by the root element.
       * The document type declaration must name the root element,
       * but the root element is only known when that element is serialized,
       * and not at the start of the document.
       * <p>
       * This method will check if it has not been called before ({@link #_started}),
       * will serialize the document type declaration, and will serialize all
       * pre-root comments and PIs that were accumulated in the document
       * (see {@link #serializePreRoot}). Pre-root will be serialized even if
       * this is not the first root element of the document.
       */
      protected void startDocument( String rootTagName )
      {
          StringBuffer buffer;
          
          // Not supported in HTML/XHTML, but we still have to switch
          // out of DTD mode.
          _printer.leaveDTD();
          if ( ! _started ) {
              // If the public and system identifiers were not specified
              // in the output format, use the appropriate ones for HTML
              // or XHTML.
              if ( _docTypePublicId == null && _docTypeSystemId == null ) {
                  if ( _xhtml ) {
                      _docTypePublicId = DTD.XHTMLPublicId;
                      _docTypeSystemId = DTD.XHTMLSystemId;
                  } else {
                      _docTypePublicId = DTD.HTMLPublicId;
                      _docTypeSystemId = DTD.HTMLSystemId;
                  }
              }
  
              // -sb
              // if ( ! _format.getOmitDocumentType() ) 
              {
                  // XHTML: If public idnentifier and system identifier
                  //  specified, print them, else print just system identifier
                  // HTML: If public identifier specified, print it with
                  //  system identifier, if specified.
                  if ( _docTypePublicId != null && ( ! _xhtml || _docTypeSystemId != null )  ) {
                      _printer.printText( "<!DOCTYPE HTML PUBLIC " );
                      printDoctypeURL( _docTypePublicId );
                      if ( _docTypeSystemId != null ) {
                          if ( _indenting ) {
                              _printer.breakLine();
                              _printer.printText( "                      " );
                          } else
                          _printer.printText( ' ' );
                          printDoctypeURL( _docTypeSystemId );
                      }
                      _printer.printText( '>' );
                      _printer.breakLine();
                  } else if ( _docTypeSystemId != null ) {
                      _printer.printText( "<!DOCTYPE HTML SYSTEM " );
                      printDoctypeURL( _docTypeSystemId );
                      _printer.printText( '>' );
                      _printer.breakLine();
                  }
              }
          }
          
          _started = true;
          // Always serialize these, even if not te first root element.
          serializePreRoot();
      }
  
  
      /**
       * Called to serialize a DOM element. Equivalent to calling {@link
       * #startElement}, {@link #endElement} and serializing everything
       * inbetween, but better optimized.
       */
      protected void serializeElement( Element elem )
      {
          Attr         attr;
          NamedNodeMap attrMap;
          int          i;
          Node         child;
          ElementState state;
          boolean      preserveSpace;
          String       name;
          String       value;
          String       tagName;
          
          tagName = elem.getTagName();
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( tagName );
          } else {
              // For any other element, if first in parent, then
              // close parent's opening tag and use the parnet's
              // space preserving.
              if ( state.empty )
                  _printer.printText( '>' );
              // Indent this element on a new line if the first
              // content of the parent element or immediately
              // following an element.
              if ( _indenting && ! state.preserveSpace &&
                   ( state.empty || state.afterElement ) )
                  _printer.breakLine();
          }
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
          
          // XHTML: element names are lower case, DOM will be different
          _printer.printText( '<' );
          if ( _xhtml )
              _printer.printText( tagName.toLowerCase() );
          else
              _printer.printText( tagName );
          _printer.indent();
          
          // Lookup the element's attribute, but only print specified
          // attributes. (Unspecified attributes are derived from the DTD.
          // For each attribute print it's name and value as one part,
          // separated with a space so the element can be broken on
          // multiple lines.
          attrMap = elem.getAttributes();
          if ( attrMap != null ) {
              for ( i = 0 ; i < attrMap.getLength() ; ++i ) {
                  attr = (Attr) attrMap.item( i );
                  name = attr.getName().toLowerCase();
                  value = attr.getValue();
                  if ( attr.getSpecified() ) {
                      _printer.printSpace();
                      if ( _xhtml ) {
                          // XHTML: print empty string for null values.
                          if ( value == null ) {
                              _printer.printText( name );
                              _printer.printText( "=\"\"" );
                          } else {
                              _printer.printText( name );
                              _printer.printText( "=\"" );
                              printEscaped( value );
                              _printer.printText( '"' );
                          }
                      } else {
                          // HTML: Empty values print as attribute name, no value.
                          // HTML: URI attributes will print unescaped
                          if ( value == null || value.length() == 0 )
                              _printer.printText( name );
                          else if ( HTMLdtd.isURI( tagName, name ) ) {
                              _printer.printText( name );
                              _printer.printText( "=\"" );
                              _printer.printText( escapeURI( value ) );
                              _printer.printText( '"' );
                          } else if ( HTMLdtd.isBoolean( tagName, name ) )
                              _printer.printText( name );
                          else {
                              _printer.printText( name );
                              _printer.printText( "=\"" );
                              printEscaped( value );
                              _printer.printText( '"' );
                          }
                      }
                  }
              }
          }
          if ( HTMLdtd.isPreserveSpace( tagName ) )
              preserveSpace = true;
          
          // If element has children, or if element is not an empty tag,
          // serialize an opening tag.
          if ( elem.hasChildNodes() || ! HTMLdtd.isEmptyTag( tagName ) ) {
              // Enter an element state, and serialize the children
              // one by one. Finally, end the element.
              state = enterElementState( null, null, tagName, preserveSpace );
              
              // Prevents line breaks inside A/TD
              if ( tagName.equalsIgnoreCase( "A" ) || tagName.equalsIgnoreCase( "TD" ) ) {
                  state.empty = false;
                  _printer.printText( '>' );
              }
              
              // Handle SCRIPT and STYLE specifically by changing the
              // state of the current element to CDATA (XHTML) or
              // unescaped (HTML).
              if ( tagName.equalsIgnoreCase( "SCRIPT" ) ||
                   tagName.equalsIgnoreCase( "STYLE" ) ) {
                  if ( _xhtml ) {
                      // XHTML: Print contents as CDATA section
                      state.doCData = true;
                  } else {
                      // HTML: Print contents unescaped
                      state.unescaped = true;
                  }
              }
              child = elem.getFirstChild();
              while ( child != null ) {
                  serializeNode( child );
                  child = child.getNextSibling();
              }
              endElement( null, null, tagName );
          } else {
              _printer.unindent();
              // XHTML: Close empty tag with ' />' so it's XML and HTML compatible.
              // HTML: Empty tags are defined as such in DTD no in document.
              if ( _xhtml )
                  _printer.printText( " />" );
              else
                  _printer.printText( '>' );
              // After element but parent element is no longer empty.
              state.afterElement = true;
              state.empty = false;
              if ( isDocumentState() )
                  _printer.flush();
          }
      }
  
  
  
      protected void characters( String text )
      {
          ElementState state;
          
          // HTML: no CDATA section
          state = content();
          state.doCData = false;
          super.characters( text );
      }
      
      
      protected String getEntityRef( char ch )
      {
          return HTMLdtd.fromChar( ch );
      }
  
  
      protected String escapeURI( String uri )
      {
          int index;
          
          // XXX  Apparently Netscape doesn't like if we escape the URI
          //      using %nn, so we leave it as is, just remove any quotes.
          index = uri.indexOf( "\"" );
          if ( index >= 0 )
              return uri.substring( 0, index );
          else
              return uri;
      }
      
      public static class DTD
      {
  
          /**
           * Public identifier for HTML document type.
           */
          public static final String HTMLPublicId = "-//W3C//DTD HTML 4.0//EN";
  
          /**
           * System identifier for HTML document type.
           */
          public static final String HTMLSystemId =
              "http://www.w3.org/TR/WD-html-in-xml/DTD/xhtml1-strict.dtd";
  
          /**
           * Public identifier for XHTML document type.
           */
          public static final String XHTMLPublicId =
              "-//W3C//DTD XHTML 1.0 Strict//EN";
  
          /**
           * System identifier for XHTML document type.
           */
          public static final String XHTMLSystemId =
              "http://www.w3.org/TR/WD-html-in-xml/DTD/xhtml1-strict.dtd";
  
      }
  
  
  
  }
  
  
  
  
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/HTMLdtd.java
  
  Index: HTMLdtd.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  // Aug 21, 2000:
  //   Fixed bug in isElement and made HTMLdtd public.
  //   Contributed by Eric SCHAEFFER" <es...@posterconseil.com>
  
  
  package org.apache.xml.serialize.transition;
  
  
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.BufferedReader;
  import java.util.Hashtable;
  
  
  /**
   * Utility class for accessing information specific to HTML documents.
   * The HTML DTD is expressed as three utility function groups. Two methods
   * allow for checking whether an element requires an open tag on printing
   * ({@link #isEmptyTag}) or on parsing ({@link #isOptionalClosing}).
   * <P>
   * Two other methods translate character references from name to value and
   * from value to name. A small entities resource is loaded into memory the
   * first time any of these methods is called for fast and efficient access.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   */
  public final class HTMLdtd
  {
  
  
      /**
       * Table of reverse character reference mapping. Character codes are held
       * as single-character strings, mapped to their reference name.
       */
      private static Hashtable        _byChar;
  
  
      /**
       * Table of entity name to value mapping. Entities are held as strings,
       * character references as <TT>Character</TT> objects.
       */
      private static Hashtable        _byName;
  
  
      private static Hashtable        _boolAttrs;
  
  
      /**
       * Holds element definitions.
       */
      private static Hashtable        _elemDefs;
  
  
      /**
       * Locates the HTML entities file that is loaded upon initialization.
       * This file is a resource loaded with the default class loader.
       */
      private static final String     ENTITIES_RESOURCE = "HTMLEntities.res";
  
  
      /**
       * Only opening tag should be printed.
       */
      private static final int ONLY_OPENING = 0x0001;
  
      /**
       * Element contains element content only.
       */
      private static final int ELEM_CONTENT = 0x0002;
  
  
      /**
       * Element preserve spaces.
       */
      private static final int PRESERVE     = 0x0004;
  
  
      /**
       * Optional closing tag.
       */
      private static final int OPT_CLOSING  = 0x0008;
  
  
      /**
       * Element is empty (also means only opening tag)
       */
      private static final int EMPTY        = 0x0010 | ONLY_OPENING;
  
  
      /**
       * Allowed to appear in head.
       */
      private static final int ALLOWED_HEAD = 0x0020;
  
  
      /**
       * When opened, closes P.
       */
      private static final int CLOSE_P      = 0x0040;
  
  
      /**
       * When opened, closes DD or DT.
       */
      private static final int CLOSE_DD_DT  = 0x0080;
  
  
      /**
       * When opened, closes itself.
       */
      private static final int CLOSE_SELF   = 0x0100;
  
  
      /**
       * When opened, closes another table section.
       */
      private static final int CLOSE_TABLE  = 0x0200;
  
  
      /**
       * When opened, closes TH or TD.
       */
      private static final int CLOSE_TH_TD  = 0x04000;
  
  
      /**
       * Returns true if element is declared to be empty. HTML elements are
       * defines as empty in the DTD, not by the document syntax.
       * 
       * @param tagName The element tag name (upper case)
       * @return True if element is empty
       */
      public static boolean isEmptyTag( String tagName )
      {
          return isElement( tagName, EMPTY );
      }
  
  
      /**
       * Returns true if element is declared to have element content.
       * Whitespaces appearing inside element content will be ignored,
       * other text will simply report an error.
       * 
       * @param tagName The element tag name (upper case)
       * @return True if element content
       */
      public static boolean isElementContent( String tagName )
      {
          return isElement( tagName, ELEM_CONTENT );
      }
  
      
      /**
       * Returns true if element's textual contents preserves spaces.
       * This only applies to PRE and TEXTAREA, all other HTML elements
       * do not preserve space.
       * 
       * @param tagName The element tag name (upper case)
       * @return True if element's text content preserves spaces
       */
      public static boolean isPreserveSpace( String tagName )
      {
          return isElement( tagName, PRESERVE );
      }
  
  
      /**
       * Returns true if element's closing tag is optional and need not
       * exist. An error will not be reported for such elements if they
       * are not closed. For example, <tt>LI</tt> is most often not closed.
       *
       * @param tagName The element tag name (upper case)
       * @return True if closing tag implied
       */
      public static boolean isOptionalClosing( String tagName )
      {
          return isElement( tagName, OPT_CLOSING );
      }
  
  
      /**
       * Returns true if element's closing tag is generally not printed.
       * For example, <tt>LI</tt> should not print the closing tag.
       *
       * @param tagName The element tag name (upper case)
       * @return True if only opening tag should be printed
       */
      public static boolean isOnlyOpening( String tagName )
      {
          return isElement( tagName, ONLY_OPENING );
      }
  
  
      /**
       * Returns true if the opening of one element (<tt>tagName</tt>) implies
       * the closing of another open element (<tt>openTag</tt>). For example,
       * every opening <tt>LI</tt> will close the previously open <tt>LI</tt>,
       * and every opening <tt>BODY</tt> will close the previously open <tt>HEAD</tt>.
       *
       * @param tagName The newly opened element
       * @param openTag The already opened element
       * @return True if closing tag closes opening tag
       */    
      public static boolean isClosing( String tagName, String openTag )
      {
          // Several elements are defined as closing the HEAD
          if ( openTag.equalsIgnoreCase( "HEAD" ) )
              return ! isElement( tagName, ALLOWED_HEAD );
          // P closes iteself
          if ( openTag.equalsIgnoreCase( "P" ) )
              return isElement( tagName, CLOSE_P );
          // DT closes DD, DD closes DT
          if ( openTag.equalsIgnoreCase( "DT" ) || openTag.equalsIgnoreCase( "DD" ) )
              return isElement( tagName, CLOSE_DD_DT );
          // LI and OPTION close themselves
          if ( openTag.equalsIgnoreCase( "LI" ) || openTag.equalsIgnoreCase( "OPTION" ) )
              return isElement( tagName, CLOSE_SELF );
          // Each of these table sections closes all the others
          if ( openTag.equalsIgnoreCase( "THEAD" ) || openTag.equalsIgnoreCase( "TFOOT" ) ||
               openTag.equalsIgnoreCase( "TBODY" ) || openTag.equalsIgnoreCase( "TR" ) || 
               openTag.equalsIgnoreCase( "COLGROUP" ) )
              return isElement( tagName, CLOSE_TABLE );
          // TD closes TH and TH closes TD
          if ( openTag.equalsIgnoreCase( "TH" ) || openTag.equalsIgnoreCase( "TD" ) )
              return isElement( tagName, CLOSE_TH_TD );
          return false;
      }
      
      
      /**
       * Returns true if the specified attribute it a URI and should be
       * escaped appropriately. In HTML URIs are escaped differently
       * than normal attributes.
       *
       * @param tagName The element's tag name
       * @param attrName The attribute's name
       */
      public static boolean isURI( String tagName, String attrName )
      {
          // Stupid checks.
          return ( attrName.equalsIgnoreCase( "href" ) || attrName.equalsIgnoreCase( "src" ) );
      }
  
          
      /**
       * Returns true if the specified attribute is a boolean and should be
       * printed without the value. This applies to attributes that are true
       * if they exist, such as selected (OPTION/INPUT). 
       *
       * @param tagName The element's tag name
       * @param attrName The attribute's name
       */
      public static boolean isBoolean( String tagName, String attrName )
      {
          String[] attrNames;
          
          attrNames = (String[]) _boolAttrs.get( tagName.toUpperCase() );
          if ( attrNames == null )
              return false;
          for ( int i = 0 ; i < attrNames.length ; ++i )
              if ( attrNames[ i ].equalsIgnoreCase( attrName ) )
                  return true;
          return false;
      }
  
  
      /**
       * Returns the value of an HTML character reference by its name. If the
       * reference is not found or was not defined as a character reference,
       * returns EOF (-1).
       *
       * @param name Name of character reference
       * @return Character code or EOF (-1)
       */
      public static int charFromName( String name )
      {
          Object    value;
          
          initialize();
          value = _byName.get( name );
          if ( value != null && value instanceof Character )
              return ( (Character) value ).charValue();
          else
              return -1;
      }
      
      
      /**
       * Returns the name of an HTML character reference based on its character
       * value. Only valid for entities defined from character references. If no
       * such character value was defined, return null.
       *
       * @param value Character value of entity
       * @return Entity's name or null
       */
      public static String fromChar( char value )
      {
          String    name;
          
          initialize();
          name = (String) _byChar.get( String.valueOf( value ) );
          if ( name == null )
              return null;
          else
              return name;
      }
      
  
      /**
       * Initialize upon first access. Will load all the HTML character references
       * into a list that is accessible by name or character value and is optimized
       * for character substitution. This method may be called any number of times
       * but will execute only once.
       */
      private static void initialize()
      {
          InputStream     is = null;
          BufferedReader  reader = null;
          int             index;
          String          name;
          String          value;
          int             code;
          String          line;
          
          // Make sure not to initialize twice.
          if ( _byName != null )
              return;
          try {
              _byName = new Hashtable();
              _byChar = new Hashtable();
              is = HTMLdtd.class.getResourceAsStream( ENTITIES_RESOURCE );
              if ( is == null )
                  throw new RuntimeException( "SER003 The resource [" + ENTITIES_RESOURCE + "] could not be found.\n" + ENTITIES_RESOURCE);
              reader = new BufferedReader( new InputStreamReader( is ) );
              line = reader.readLine();
              while ( line != null ) {
                  if ( line.length() == 0 || line.charAt( 0 ) == '#' ) {
                      line = reader.readLine();
                      continue;
                  }
                  index = line.indexOf( ' ' );
                  if ( index > 1 ) {
                      name = line.substring( 0, index );
                      ++index;
                      if ( index < line.length() ) {
                          value = line.substring( index );
                          index = value.indexOf( ' ' );
                          if ( index > 0 )
                              value = value.substring( 0, index );
                          code = Integer.parseInt( value );
                                          defineEntity( name, (char) code );
                      }
                  }
                  line = reader.readLine();
              }
              is.close();
          }  catch ( Exception except ) {
              throw new RuntimeException( "SER003 The resource [" + ENTITIES_RESOURCE + "] could not load: " +
                                          except.toString() + "\n" + ENTITIES_RESOURCE + "\t" + except.toString());
          } finally {
              if ( is != null ) {
                  try {
                      is.close();
                  } catch ( Exception except ) { }
              }
          }
      }
      
  
      /**
       * Defines a new character reference. The reference's name and value are
       * supplied. Nothing happens if the character reference is already defined.
       * <P>
       * Unlike internal entities, character references are a string to single
       * character mapping. They are used to map non-ASCII characters both on
       * parsing and printing, primarily for HTML documents. '&lt;amp;' is an
       * example of a character reference.
       *
       * @param name The entity's name
       * @param value The entity's value
       */
      private static void defineEntity( String name, char value )
      {
          if ( _byName.get( name ) == null ) {
              _byName.put( name, new Character( value ) );
              _byChar.put( String.valueOf( value ), name );
          }
      }
  
  
      private static void defineElement( String name, int flags )
      {
          _elemDefs.put( name, new Integer( flags ) );
      }
      
      
      private static void defineBoolean( String tagName, String attrName )
      {
          defineBoolean( tagName, new String[] { attrName } );
      }
      
      
      private static void defineBoolean( String tagName, String[] attrNames )
      {
          _boolAttrs.put( tagName, attrNames );
      }
      
      
      private static boolean isElement( String name, int flag )
      {
          Integer flags;
          
          flags = (Integer) _elemDefs.get( name.toUpperCase() );
          if ( flags == null )
              return false;
          else
              return ( ( flags.intValue() & flag ) == flag );
      }
      
      
      static
      {
          _elemDefs = new Hashtable();
          defineElement( "ADDRESS", CLOSE_P );
          defineElement( "AREA", EMPTY );
          defineElement( "BASE",  EMPTY | ALLOWED_HEAD );
          defineElement( "BASEFONT", EMPTY );
          defineElement( "BLOCKQUOTE", CLOSE_P );
          defineElement( "BODY", OPT_CLOSING );
          defineElement( "BR", EMPTY );
          defineElement( "COL", EMPTY );
          defineElement( "COLGROUP", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
          defineElement( "DD", OPT_CLOSING | ONLY_OPENING | CLOSE_DD_DT );
          defineElement( "DIV", CLOSE_P );
          defineElement( "DL", ELEM_CONTENT | CLOSE_P );
          defineElement( "DT", OPT_CLOSING | ONLY_OPENING | CLOSE_DD_DT );
          defineElement( "FIELDSET", CLOSE_P );
          defineElement( "FORM", CLOSE_P );
          defineElement( "FRAME", EMPTY | OPT_CLOSING );
          defineElement( "H1", CLOSE_P );
          defineElement( "H2", CLOSE_P );
          defineElement( "H3", CLOSE_P );
          defineElement( "H4", CLOSE_P );
          defineElement( "H5", CLOSE_P );
          defineElement( "H6", CLOSE_P );
          defineElement( "HEAD", ELEM_CONTENT | OPT_CLOSING );
          defineElement( "HR", EMPTY | CLOSE_P );
          defineElement( "HTML", ELEM_CONTENT | OPT_CLOSING );
          defineElement( "IMG", EMPTY );
          defineElement( "INPUT", EMPTY );
          defineElement( "ISINDEX", EMPTY | ALLOWED_HEAD );
          defineElement( "LI", OPT_CLOSING | ONLY_OPENING | CLOSE_SELF );
          defineElement( "LINK", EMPTY | ALLOWED_HEAD );
          defineElement( "MAP", ALLOWED_HEAD );
          defineElement( "META", EMPTY | ALLOWED_HEAD );
          defineElement( "OL", ELEM_CONTENT | CLOSE_P );
          defineElement( "OPTGROUP", ELEM_CONTENT );
          defineElement( "OPTION", OPT_CLOSING | ONLY_OPENING | CLOSE_SELF );
          defineElement( "P", OPT_CLOSING | CLOSE_P | CLOSE_SELF );
          defineElement( "PARAM", EMPTY );
          defineElement( "PRE", PRESERVE | CLOSE_P );
          defineElement( "SCRIPT", ALLOWED_HEAD | PRESERVE );
          defineElement( "NOSCRIPT", ALLOWED_HEAD | PRESERVE );
          defineElement( "SELECT", ELEM_CONTENT );
          defineElement( "STYLE", ALLOWED_HEAD | PRESERVE );
          defineElement( "TABLE", ELEM_CONTENT | CLOSE_P );
          defineElement( "TBODY", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
          defineElement( "TD", OPT_CLOSING | CLOSE_TH_TD );
          defineElement( "TEXTAREA", PRESERVE );
          defineElement( "TFOOT", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
          defineElement( "TH", OPT_CLOSING | CLOSE_TH_TD );
          defineElement( "THEAD", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
          defineElement( "TITLE", ALLOWED_HEAD );
          defineElement( "TR", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
          defineElement( "UL", ELEM_CONTENT | CLOSE_P );
          
          _boolAttrs = new Hashtable();
          defineBoolean( "AREA", "href" );
          defineBoolean( "BUTTON", "disabled" );
          defineBoolean( "DIR", "compact" );
          defineBoolean( "DL", "compact" );
          defineBoolean( "FRAME", "noresize" );
          defineBoolean( "HR", "noshade" );
          defineBoolean( "IMAGE", "ismap" );
          defineBoolean( "INPUT", new String[] { "defaultchecked", "checked", "readonly", "disabled" } );
          defineBoolean( "LINK", "link" );
          defineBoolean( "MENU", "compact" );
          defineBoolean( "OBJECT", "declare" );
          defineBoolean( "OL", "compact" );
          defineBoolean( "OPTGROUP", "disabled" );
          defineBoolean( "OPTION", new String[] { "default-selected", "selected", "disabled" } );
          defineBoolean( "SCRIPT", "defer" );
          defineBoolean( "SELECT", new String[] { "multiple", "disabled" } );
          defineBoolean( "STYLE", "disabled" );
          defineBoolean( "TD", "nowrap" );
          defineBoolean( "TH", "nowrap" );
          defineBoolean( "TEXTAREA", new String[] { "disabled", "readonly" } );
          defineBoolean( "UL", "compact" );
          
          initialize();
      }
  
  
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/IndentPrinter.java
  
  Index: IndentPrinter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.io.Writer;
  import java.io.StringWriter;
  import java.io.IOException;
  
  import serialize.OutputFormat;
  
  /**
   * Extends {@link Printer} and adds support for indentation and line
   * wrapping.
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:12 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   */
  class IndentPrinter
      extends Printer
  {
  
  
      /**
       * Holds the currently accumulating text line. This buffer will constantly
       * be reused by deleting its contents instead of reallocating it.
       */
      private StringBuffer    _line;
  
  
      /**
       * Holds the currently accumulating text that follows {@link #_line}.
       * When the end of the part is identified by a call to {@link #printSpace}
       * or {@link #breakLine}, this part is added to the accumulated line.
       */
      private StringBuffer    _text;
  
  
      /**
       * Counts how many white spaces come between the accumulated line and the
       * current accumulated text. Multiple spaces at the end of the a line
       * will not be printed.
       */
      private int             _spaces;
  
  
      /**
       * Holds the indentation for the current line that is now accumulating in
       * memory and will be sent for printing shortly.
       */
      private int             _thisIndent;
      
      
      /**
       * Holds the indentation for the next line to be printed. After this line is
       * printed, {@link #_nextIndent} is assigned to {@link #_thisIndent}.
       */
      private int             _nextIndent;
          
      /**
       * The line width at which to wrap long lines when indenting.
       */
      private int _lineWidth = 72;
      // -sb Moved from OutputFormat
  
  
      IndentPrinter( Writer writer, OutputFormat format)
      {
          super( writer, format );
          // Initialize everything for a first/second run.
          _line = new StringBuffer( 80 );
          _text = new StringBuffer( 20 );
          _spaces = 0;
          _thisIndent = _nextIndent = 0;
      }
      
      /**
       * Return the selected line width for breaking up long lines.
       * When indenting, and only when indenting, long lines will be
       * broken at space boundaries based on this line width.
       * No line wrapping occurs if this value is zero.
       */
      public int getLineWidth()
      {
          return _lineWidth;
      }
      
      /**
       * Returns a specific line separator to use. The default is the
       * Web line separator (<tt>\n</tt>). A string is returned to
       * support double codes (CR + LF).
       *
       * @return The specified line separator
       */
      public String getLineSeparator()
      {
          return _lineSeparator;
      }
  
  
      /**
       * Called by any of the DTD handlers to enter DTD mode.
       * Once entered, all output will be accumulated in a string
       * that can be printed as part of the document's DTD.
       * This method may be called any number of time but will only
       * have affect the first time it's called. To exist DTD state
       * and get the accumulated DTD, call {@link #leaveDTD}.
       */
      public void enterDTD()
      {
          // Can only enter DTD state once. Once we're out of DTD
          // state, can no longer re-enter it.
          if ( _dtdWriter == null ) {
              _line.append( _text );
              _text = new StringBuffer( 20 );
              flushLine( false );
              _dtdWriter = new StringWriter();
              _docWriter = _writer;
              _writer = _dtdWriter;
          }
      }
      
      
      /**
       * Called by the root element to leave DTD mode and if any
       * DTD parts were printer, will return a string with their
       * textual content.
       */
      public String leaveDTD()
      {
          // Only works if we're going out of DTD mode.
          if ( _writer == _dtdWriter ) {
              _line.append( _text );
              _text = new StringBuffer( 20 );
              flushLine( false );
              _writer = _docWriter;
              return _dtdWriter.toString();
          } else
              return null;
      }
      
      
      /**
       * Called to print additional text. Each time this method is called
       * it accumulates more text. When a space is printed ({@link
       * #printSpace}) all the accumulated text becomes one part and is
       * added to the accumulate line. When a line is long enough, it can
       * be broken at its text boundary.
       *
       * @param text The text to print
       */
      public void printText( String text )
      {
          _text.append( text );
      }
      
      
      public void printText( StringBuffer text )
      {
          _text.append( text );
      }
  
  
      public void printText( char ch )
      {
          _text.append( ch );
      }
  
  
      public void printText( char[] chars, int start, int length )
      {
          _text.append( chars, start, length );
      }
      
  
      /**
       * Called to print a single space between text parts that may be
       * broken into separate lines. Must not be called to print a space
       * when preserving spaces. The text accumulated so far with {@link
       * #printText} will be added to the accumulated line, and a space
       * separator will be counted. If the line accumulated so far is
       * long enough, it will be printed.
       */
      public void printSpace()
      {
          // The line consists of the text accumulated in _line,
          // followed by one or more spaces as counted by _spaces,
          // followed by more space accumulated in _text:
          // -  Text is printed and accumulated into _text.
          // -  A space is printed, so _text is added to _line and
          //    a space is counted.
          // -  More text is printed and accumulated into _text.
          // -  A space is printed, the previous spaces are added
          //    to _line, the _text is added to _line, and a new
          //    space is counted.
          
          // If text was accumulated with printText(), then the space
          // means we have to move that text into the line and
          // start accumulating new text with printText().
          if ( _text.length() > 0 ) {
            // If the text breaks a line bounary, wrap to the next line.
            // The printed line size consists of the indentation we're going
            // to use next, the accumulated line so far, some spaces and the
            // accumulated text so far.
            if ( /* _format. -sb */ getLineWidth() > 0 &&
                                    _thisIndent + _line.length() + _spaces + _text.length() > /* _format. -sb */ getLineWidth() ) {
              flushLine( false );
              try {
                // Print line and new line, then zero the line contents.
                _writer.write( /* _format. -sb */ getLineSeparator() );
              } catch ( IOException except ) {
                // We don't throw an exception, but hold it
                // until the end of the document.
                if ( _exception == null )
                  _exception = except;
              }
            }
              
              // Add as many spaces as we accumulaed before.
              // At the end of this loop, _spaces is zero.
              while ( _spaces > 0 ) {
                  _line.append( ' ' );
                  --_spaces;
              }
              _line.append( _text );
              _text = new StringBuffer( 20 );
          }
          // Starting a new word: accumulate the text between the line
          // and this new word; not a new word: just add another space.
          ++_spaces;
      }
  
  
      /**
       * Called to print a line consisting of the text accumulated so
       * far. This is equivalent to calling {@link #printSpace} but
       * forcing the line to print and starting a new line ({@link
       * #printSpace} will only start a new line if the current line
       * is long enough).
       */
      public void breakLine()
      {
          breakLine( false );
      }
  
  
      public void breakLine( boolean preserveSpace )
      {
          // Equivalent to calling printSpace and forcing a flushLine.
          if ( _text.length() > 0 ) {
              while ( _spaces > 0 ) {
                  _line.append( ' ' );
                  --_spaces;
              }
              _line.append( _text );
              _text = new StringBuffer( 20 );
          }
          flushLine( preserveSpace );
          try {
              // Print line and new line, then zero the line contents.
              _writer.write( getLineSeparator() );
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
      
  
      /**
       * Flushes the line accumulated so far to the writer and get ready
       * to accumulate the next line. This method is called by {@link
       * #printText} and {@link #printSpace} when the accumulated line plus
       * accumulated text are two long to fit on a given line. At the end of
       * this method {@link #_line} is empty and {@link #_spaces} is zero.
       */
      public void flushLine( boolean preserveSpace )
      {
          int     indent;
          
          if ( _line.length() > 0 ) {
              try {
                  
                  if ( _format.getIndent() && ! preserveSpace ) {
                      // Make sure the indentation does not blow us away.
                      indent = _thisIndent;
                      if ( ( 2 * indent ) > /* _format. -sb */ getLineWidth() && /* _format. -sb */getLineWidth() > 0 )
                          indent = /* _format. -sb */ getLineWidth() / 2;
                      // Print the indentation as spaces and set the current
                      // indentation to the next expected indentation.
                      while ( indent > 0 ) {
                          _writer.write( ' ' );
                          --indent;
                      }
                  }
                  _thisIndent = _nextIndent;
                  
                  // There is no need to print the spaces at the end of the line,
                  // they are simply stripped and replaced with a single line
                  // separator.
                  _spaces = 0;
                  _writer.write( _line.toString() );
                  
                  _line = new StringBuffer( 40 );
              } catch ( IOException except ) {
                  // We don't throw an exception, but hold it
                  // until the end of the document.
                  if ( _exception == null )
                      _exception = except;
              }
          }
      }
      
      
      /**
       * Flush the output stream. Must be called when done printing
       * the document, otherwise some text might be buffered.
       */
      public void flush()
      {
          if ( _line.length() > 0 || _text.length() > 0 )
              breakLine();
          try {
              _writer.flush();
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
  
  
      /**
       * Increment the indentation for the next line.
       */
      public void indent()
      {
        // -sb TBD: Define way to set the indent amount
        _nextIndent += 2;
        // _nextIndent += _format.getIndent();
      }
  
  
      /**
       * Decrement the indentation for the next line.
       */
      public void unindent()
      {
        // -sb TBD: Define way to set the indent amount
        _nextIndent -= 2;
        // _nextIndent -= _format.getIndent();
        if ( _nextIndent < 0 )
          _nextIndent = 0;
        // If there is no current line and we're de-identing then
        // this indentation level is actually the next level.
        if ( ( _line.length() + _spaces + _text.length() ) == 0 )
          _thisIndent = _nextIndent;
      }
  
  
      public int getNextIndent()
      {
          return _nextIndent;
      }
  
  
      public void setNextIndent( int indent )
      {
          _nextIndent = indent;
      }
  
  
      public void setThisIndent( int indent )
      {
          _thisIndent = indent;
      }
  
  
  }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/LineSeparator.java
  
  Index: LineSeparator.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  import serialize.OutputFormat;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:arkin@intalio..com">Assaf Arkin</a>
   * @see OutputFormat
   */
  public final class LineSeparator
  {
      
      
      /**
       * Line separator for Unix systems (<tt>\n</tt>).
       */
      public static final String Unix = "\n";
      
      
      /**
       * Line separator for Windows systems (<tt>\r\n</tt>).
       */
      public static final String Windows = "\r\n";
      
      
      /**
       * Line separator for Macintosh systems (<tt>\r</tt>).
       */
      public static final String Macintosh = "\r";
      
      
      /**
       * Line separator for the Web (<tt>\n</tt>).
       */
      public static final String Web = "\n";
      
      
  }
  
  
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/Method.java
  
  Index: Method.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  import serialize.OutputFormat;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see OutputFormat
   */
  public final class Method
  {
      
      
      /**
       * The output method for XML documents.
       */
      public static final String XML = "xml";
      
      
      /**
       * The output method for HTML documents.
       */
      public static final String HTML = "html";
      
      
      /**
       * The output method for HTML documents as XHTML.
       */
      public static final String XHTML = "xhtml";
      
      
      /**
       * The output method for text documents.
       */
      public static final String TEXT = "text";
      
      
      /**
       * The output method for FO documents as PDF.
       */
      public static final String FOP = "fop";
      
      
  }
  
  
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/Printer.java
  
  Index: Printer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.io.Writer;
  import java.io.StringWriter;
  import java.io.IOException;
  
  import serialize.OutputFormat;
  
  /**
   * The printer is responsible for sending text to the output stream
   * or writer. This class performs direct writing for efficiency.
   * {@link IndentPrinter} supports indentation and line wrapping by
   * extending this class.
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   */
  public class Printer
  {
  
  
      /**
       * The output format associated with this serializer. This will never
       * be a null reference. If no format was passed to the constructor,
       * the default one for this document type will be used. The format
       * object is never changed by the serializer.
       */
      protected final OutputFormat _format;
  
  
      /**
       * The writer to which the document is written.
       */
      protected Writer             _writer;
  
  
      /**
       * The DTD writer. When we switch to DTD mode, all output is
       * accumulated in this DTD writer. When we switch out of it,
       * the output is obtained as a string. Must not be reset to
       * null until we're done with the document.
       */
      protected StringWriter       _dtdWriter;
  
  
      /**
       * Holds a reference to the document writer while we are
       * in DTD mode.
       */
      protected Writer          _docWriter;
  
  
      /**
       * Holds the exception thrown by the serializer.  Exceptions do not cause
       * the serializer to quit, but are held and one is thrown at the end.
       */
      protected IOException     _exception;
  
  
      /**
       * The size of the output buffer.
       */
      private static final int BufferSize = 4096;
  
  
      /**
       * Output buffer.
       */
      private final char[]  _buffer = new char[ BufferSize ];
  
  
      /**
       * Position within the output buffer.
       */
      private int           _pos = 0;
      
      /**
       * Use the system line seperator to write line breaks.
       */
      protected final String _lineSeparator = System.getProperty("line.separator");
    
      /**
       * The length of the line seperator, since the write is done 
       * one character at a time.
       */
      protected final int _lineSepLen = _lineSeparator.length();
    
      public Printer( Writer writer, OutputFormat format)
      {
          _writer = writer;
          _format = format;
          _exception = null;
          _dtdWriter = null;
          _docWriter = null;
          _pos = 0;
      }
  
  
      public IOException getException()
      {
          return _exception;
      }
  
  
      /**
       * Called by any of the DTD handlers to enter DTD mode.
       * Once entered, all output will be accumulated in a string
       * that can be printed as part of the document's DTD.
       * This method may be called any number of time but will only
       * have affect the first time it's called. To exist DTD state
       * and get the accumulated DTD, call {@link #leaveDTD}.
       */
      public void enterDTD()
      {
          // Can only enter DTD state once. Once we're out of DTD
          // state, can no longer re-enter it.
          if ( _dtdWriter == null ) {
              flushLine( false );
              _dtdWriter = new StringWriter();
              _docWriter = _writer;
              _writer = _dtdWriter;
          }
      }
      
      
      /**
       * Called by the root element to leave DTD mode and if any
       * DTD parts were printer, will return a string with their
       * textual content.
       */
      public String leaveDTD()
      {
          // Only works if we're going out of DTD mode.
          if ( _writer == _dtdWriter ) {
              flushLine( false );
              _writer = _docWriter;
              return _dtdWriter.toString();
          } else
              return null;
      }
      
      
      public void printText( String text )
      {
          try {
              int length = text.length();
              for ( int i = 0 ; i < length ; ++i ) { 
                  if ( _pos == BufferSize ) {
                      _writer.write( _buffer );
                      _pos = 0;
                  }
                  // -sb Normalize linebreaks.
                  char c = text.charAt( i );
                  if ((0x0D == c) && ((i+1) < length) && (0x0A==text.charAt( i+1 ))) 
                  {
                    breakLine();
                    i++;
                  }
                  else if ((0x0A == c) && ((i+1) < length) && (0x0D==text.charAt( i+1 ))) 
                  {
                    breakLine();
                    i++;
                  }
                  else if('\n' == c)
                  {
                    breakLine();
                  }
                  else
                  {
                    _buffer[ _pos ] = text.charAt( i );
                    ++_pos;
                  }
              }
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
      
      
      public void printText( StringBuffer text )
      {
          try {
              int length = text.length();
              for ( int i = 0 ; i < length ; ++i ) { 
                  if ( _pos == BufferSize ) {
                      _writer.write( _buffer );
                      _pos = 0;
                  }
                  // -sb Normalize linebreaks.
                  char c = text.charAt( i );
                  if ((0x0D == c) && ((i+1) < length) && (0x0A==text.charAt( i+1 ))) 
                  {
                    breakLine();
                    i++;
                  }
                  else if ((0x0A == c) && ((i+1) < length) && (0x0D==text.charAt( i+1 ))) 
                  {
                    breakLine();
                    i++;
                  }
                  else if('\n' == c)
                  {
                    breakLine();
                  }
                  else
                  {
                    _buffer[ _pos ] = text.charAt( i );
                    ++_pos;
                  }
              }
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
  
  
      public void printText( char[] chars, int start, int length )
      {
          try {
              while ( length-- > 0 ) {
                  if ( _pos == BufferSize ) {
                      _writer.write( _buffer );
                      _pos = 0;
                  }
                  // -sb Normalize linebreaks.
                  char c = chars[ start ];
                  if ((0x0D == c) && (length>1) && (0x0A==chars[ start+1 ])) 
                  {
                    breakLine();
                    ++start;
                  }
                  else if ((0x0A == c) && (length>1) && (0x0D==chars[ start+1 ])) 
                  {
                    breakLine();
                    ++start;
                  }
                  else if('\n' == c)
                  {
                    breakLine();
                  }
                  else
                  {
                    _buffer[ _pos ] = chars[ start ];
                    ++_pos;
                  }
                  ++start;
              }
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
      
  
      public void printText( char ch )
      {
          try {
              if ( _pos == BufferSize ) {
                  _writer.write( _buffer );
                  _pos = 0;
              }
              else if('\n' == ch)
              {
                breakLine();
              }
              else
              {
                _buffer[ _pos ] = ch;
                ++_pos;
              }
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
  
  
      public void printSpace()
      {
          try {
              if ( _pos == BufferSize ) {
                  _writer.write( _buffer );
                  _pos = 0;
              }
              _buffer[ _pos ] = ' ';
              ++_pos;
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
      }
  
      public void breakLine()
      {
        try {
          if ( _pos == BufferSize ) {
            _writer.write( _buffer );
            _pos = 0;
          }
          for(int z = 0; z < _lineSepLen; z++)
          {
            _buffer[ _pos ] = _lineSeparator.charAt(z);
            ++_pos;
          }
        } catch ( IOException except ) {
          // We don't throw an exception, but hold it
          // until the end of the document.
          if ( _exception == null )
            _exception = except;
        }
      }
  
  
      public void breakLine( boolean preserveSpace )
      {
          breakLine();
      }
      
  
      public void flushLine( boolean preserveSpace )
      {
          // NOOP
      }
      
      
      /**
       * Flush the output stream. Must be called when done printing
       * the document, otherwise some text might be buffered.
       */
      public void flush()
      {
          try {
              _writer.write( _buffer, 0, _pos );
              _writer.flush();
          } catch ( IOException except ) {
              // We don't throw an exception, but hold it
              // until the end of the document.
              if ( _exception == null )
                  _exception = except;
          }
          _pos = 0;
      }
  
  
      public void indent()
      {
          // NOOP
      }
  
  
      public void unindent()
      {
          // NOOP
      }
  
  
      public int getNextIndent()
      {
          return 0;
      }
  
  
      public void setNextIndent( int indent )
      {
      }
  
  
      public void setThisIndent( int indent )
      {
      }
  
  
  }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/SerializerFactoryImpl.java
  
  Index: SerializerFactoryImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.io.OutputStream;
  import java.io.Writer;
  import java.io.UnsupportedEncodingException;
  
  import serialize.OutputFormat;
  import serialize.SerializerFactory;
  import serialize.Serializer;
  
  /**
   * Default serializer factory can construct serializers for the three
   * markup serializers (XML, HTML, XHTML ).
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:Scott_Boag/CAM/Lotus@lotus.com">Scott Boag</a>
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   */
  final class SerializerFactoryImpl
      extends SerializerFactory
  {
  
  
      private String _method;
      
      
      SerializerFactoryImpl( String method )
      {
          _method = method;
          if ( ! _method.equals( Method.XML ) &&
               ! _method.equals( Method.HTML ) &&
               ! _method.equals( Method.XHTML ) &&
               ! _method.equals( Method.TEXT ) )
              throw new IllegalArgumentException( "SER004 The method '" + method + "' is not supported by this factory\n" + method);
      }
  
  
      public Serializer makeSerializer( OutputFormat format )
      {
          Serializer serializer;
          
          serializer = getSerializer( format );
          serializer.setOutputFormat( format );
          return serializer;
      }
      
      
      
      public Serializer makeSerializer( Writer writer,
                                        OutputFormat format )
      {
          Serializer serializer;
          
          serializer = getSerializer( format );
          serializer.setWriter( writer );
          return serializer;
      }
      
      
      public Serializer makeSerializer( OutputStream output,
                                        OutputFormat format )
          throws UnsupportedEncodingException
      {
          Serializer serializer;
          
          serializer = getSerializer( format );
          serializer.setOutputStream( output );
          return serializer;
      }
      
      /*
      private Serializer getSerializer( OutputFormat format )
      {
          if ( _method.equals( Method.XML ) ) {
              return new XMLSerializer( format );
          } else if ( _method.equals( Method.HTML ) ) {
              return new HTMLSerializer( format );
          }  else if ( _method.equals( Method.XHTML ) ) {
              return new XHTMLSerializer( format );
          }  else if ( _method.equals( Method.TEXT ) ) {
              return new TextSerializer();
          } else {
              throw new IllegalStateException( "SER005 The method '" + _method + "' is not supported by this factory\n" + _method);
          }
      }
      */
      
      
      protected String getSupportedMethod()
      {
          return _method;
      }
  
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/TextSerializer.java
  
  Index: TextSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.io.OutputStream;
  import java.io.Writer;
  
  import org.w3c.dom.*;
  import org.xml.sax.DocumentHandler;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.AttributeList;
  import org.xml.sax.Attributes;
  
  import serialize.OutputFormat;
  
  /**
   * Implements a text serializer supporting both DOM and SAX
   * serializing. For usage instructions see {@link Serializer}.
   * <p>
   * If an output stream is used, the encoding is taken from the
   * output format (defaults to <tt>UTF-8</tt>). If a writer is
   * used, make sure the writer uses the same encoding (if applies)
   * as specified in the output format.
   * <p>
   * The serializer supports both DOM and SAX. DOM serializing is done
   * by calling {@link #serialize} and SAX serializing is done by firing
   * SAX events and using the serializer as a document handler.
   * <p>
   * If an I/O exception occurs while serializing, the serializer
   * will not throw an exception directly, but only throw it
   * at the end of serializing (either DOM or SAX's {@link
   * org.xml.sax.DocumentHandler#endDocument}.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see Serializer
   */
  public final class TextSerializer
      extends BaseMarkupSerializer
  {
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
       * first.
       */
      public TextSerializer()
      {
        super();
        OutputFormat format = new OutputFormat();
        format.setMethod(Method.TEXT);
        setOutputFormat(format);
      }
  
  
      public void setOutputFormat( OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.TEXT);
        }
        super.setOutputFormat(format);
      }
  
  
      //-----------------------------------------//
      // SAX content handler serializing methods //
      //-----------------------------------------//
  
  
      public void startElement( String namespaceURI, String localName,
                                String rawName, Attributes attrs )
      {
          startElement( rawName == null ? localName : rawName, null );
      }
  
  
      public void endElement( String namespaceURI, String localName,
                              String rawName )
      {
          endElement( rawName == null ? localName : rawName );
      }
  
  
      //------------------------------------------//
      // SAX document handler serializing methods //
      //------------------------------000---------//
  
      
      public void startElement( String tagName, AttributeList attrs )
      {
          boolean      preserveSpace;
          ElementState state;
          
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( tagName );
          }
          // For any other element, if first in parent, then
          // use the parnet's space preserving.
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
          
          // Ignore all other attributes of the element, only printing
          // its contents.
          
          // Now it's time to enter a new element state
          // with the tag name and space preserving.
          // We still do not change the curent element state.
          state = enterElementState( null, null, tagName, preserveSpace );
      }
      
      
      public void endElement( String tagName )
      {
          ElementState state;
          
          // Works much like content() with additions for closing
          // an element. Note the different checks for the closed
          // element's state and the parent element's state.
          state = getElementState();
          // Leave the element state and update that of the parent
          // (if we're not root) to not empty and after element.
          state = leaveElementState();
          state.afterElement = true;
          state.empty = false;
          if ( isDocumentState() )
              _printer.flush();
      }
  
  
      public void processingInstruction( String target, String code )
      {
      }
  
  
      public void comment( String text )
      {
      }
  
  
      public void comment( char[] chars, int start, int length )
      {
      }
  
  
      public void characters( char[] chars, int start, int length )
      {
          ElementState state;
          
          state = content();
          state.doCData = state.inCData = false;
          printText( chars, start, length, true, true );
      }
  
  
      protected void characters( String text, boolean unescaped )
      {
          ElementState state;
          
          state = content();
          state.doCData = state.inCData = false;
          printText( text, true, true );
      }
  
  
      //------------------------------------------//
      // Generic node serializing methods methods //
      //------------------------------------------//
  
  
      /**
       * Called to serialize the document's DOCTYPE by the root element.
       * <p>
       * This method will check if it has not been called before ({@link #_started}),
       * will serialize the document type declaration, and will serialize all
       * pre-root comments and PIs that were accumulated in the document
       * (see {@link #serializePreRoot}). Pre-root will be serialized even if
       * this is not the first root element of the document.
       */
      protected void startDocument( String rootTagName )
      {
          // Required to stop processing the DTD, even though the DTD
          // is not printed.
          _printer.leaveDTD();
          
          _started = true;
          // Always serialize these, even if not te first root element.
          serializePreRoot();
      }
  
  
      /**
       * Called to serialize a DOM element. Equivalent to calling {@link
       * #startElement}, {@link #endElement} and serializing everything
       * inbetween, but better optimized.
       */
      protected void serializeElement( Element elem )
      {
          Node         child;
          ElementState state;
          boolean      preserveSpace;
          String       tagName;
          
          tagName = elem.getTagName();
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( tagName );
          }
          // For any other element, if first in parent, then
          // use the parnet's space preserving.
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
          
          // Ignore all other attributes of the element, only printing
          // its contents.
          
          // If element has children, then serialize them, otherwise
          // serialize en empty tag.
          if ( elem.hasChildNodes() ) {
              // Enter an element state, and serialize the children
              // one by one. Finally, end the element.
              state = enterElementState( null, null, tagName, preserveSpace );
              child = elem.getFirstChild();
              while ( child != null ) {
                  serializeNode( child );
                  child = child.getNextSibling();
              }
              endElement( tagName );
          } else {
              if ( ! isDocumentState() ) {
                  // After element but parent element is no longer empty.
                  state.afterElement = true;
                  state.empty = false;
              }
          }
      }
  
  
      /**
       * Serialize the DOM node. This method is unique to the Text serializer.
       *
       * @param node The node to serialize
       */
      protected void serializeNode( Node node )
      {
          // Based on the node type call the suitable SAX handler.
          // Only comments entities and documents which are not
          // handled by SAX are serialized directly.
          switch ( node.getNodeType() ) {
          case Node.TEXT_NODE : {
              String text;
  
              text = node.getNodeValue();
              if ( text != null )
                  characters( node.getNodeValue(), true );
              break;
          }
              
          case Node.CDATA_SECTION_NODE : {
              String text;
  
              text = node.getNodeValue();
              if ( text != null )
                  characters( node.getNodeValue(), true );
              break;
          }
              
          case Node.COMMENT_NODE :
              break;
              
          case Node.ENTITY_REFERENCE_NODE :
              // Ignore.
              break;
              
          case Node.PROCESSING_INSTRUCTION_NODE :
              break;
              
          case Node.ELEMENT_NODE :
              serializeElement( (Element) node );
              break;
              
          case Node.DOCUMENT_NODE :
              // !!! Fall through
          case Node.DOCUMENT_FRAGMENT_NODE : {
              Node         child;
              
              // By definition this will happen if the node is a document,
              // document fragment, etc. Just serialize its contents. It will
              // work well for other nodes that we do not know how to serialize.
              child = node.getFirstChild();
              while ( child != null ) {
                  serializeNode( child );
                  child = child.getNextSibling();
              }
              break;
          }
          
          default:
              break;
          }
      }
      
      
      protected ElementState content()
      {
          ElementState state;
          
          state = getElementState();
          if ( ! isDocumentState() ) {
              // If this is the first content in the element,
              // change the state to not-empty.
              if ( state.empty )
                  state.empty = false;
              // Except for one content type, all of them
              // are not last element. That one content
              // type will take care of itself.
              state.afterElement = false;
          }
          return state;
      }
      
      
      protected String getEntityRef( char ch )
      {
          return null;
      }
  
  
  }
  
  
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/XHTMLSerializer.java
  
  Index: XHTMLSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, 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.xml.serialize.transition;
  
  
  import java.io.OutputStream;
  import java.io.Writer;
  import java.io.UnsupportedEncodingException;
  
  import serialize.OutputFormat;
  
  /**
   * Implements an XHTML serializer supporting both DOM and SAX
   * pretty serializing. For usage instructions see either {@link
   * Serializer} or {@link BaseMarkupSerializer}.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see Serializer
   */
  public final class XHTMLSerializer
      extends HTMLSerializer
  {
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
       * first.
       */
      public XHTMLSerializer()
      {
        super();
        OutputFormat format = new OutputFormat();
        format.setMethod(Method.XHTML);
        setOutputFormat(format);
      }
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
       * first.
       */
      public XHTMLSerializer( OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XHTML);
        }
        setOutputFormat(format);
      }
  
  
      /**
       * Constructs a new serializer that writes to the specified writer
       * using the specified output format. If <tt>format</tt> is null,
       * will use a default output format.
       *
       * @param writer The writer to use
       * @param format The output format to use, null for the default
       */
      public XHTMLSerializer( Writer writer, OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XHTML);
        }
        setOutputFormat(format);
        setWriter( writer );
      }
  
  
      /**
       * Constructs a new serializer that writes to the specified output
       * stream using the specified output format. If <tt>format</tt>
       * is null, will use a default output format.
       *
       * @param output The output stream to use
       * @param format The output format to use, null for the default
       */
      public XHTMLSerializer( OutputStream output, OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XHTML);
        }
        setOutputFormat(format);
        setOutputStream( output );
      }
  
  
      public void setOutputFormat( OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XHTML);
        }
        super.setOutputFormat(format);
      }
  
  
  }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xml/serialize/transition/XMLSerializer.java
  
  Index: XMLSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  // Aug 21, 2000:
  //  Fixed bug in startDocument not calling prepare.
  //  Reported by Mikael Staldal <d9...@d.kth.se>
  // Aug 21, 2000:
  //  Added ability to omit DOCTYPE declaration.
  
  
  package org.apache.xml.serialize.transition;
  
  
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.io.OutputStream;
  import java.io.Writer;
  import java.util.Enumeration;
  
  import org.w3c.dom.*;
  import org.xml.sax.DocumentHandler;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.AttributeList;
  import org.xml.sax.Attributes;
  
  import serialize.OutputFormat;
  import serialize.QName;
  
  /**
   * Implements an XML serializer supporting both DOM and SAX pretty
   * serializing. For usage instructions see {@link Serializer}.
   * <p>
   * If an output stream is used, the encoding is taken from the
   * output format (defaults to <tt>UTF-8</tt>). If a writer is
   * used, make sure the writer uses the same encoding (if applies)
   * as specified in the output format.
   * <p>
   * The serializer supports both DOM and SAX. DOM serializing is done
   * by calling {@link #serialize} and SAX serializing is done by firing
   * SAX events and using the serializer as a document handler.
   * <p>
   * If an I/O exception occurs while serializing, the serializer
   * will not throw an exception directly, but only throw it
   * at the end of serializing (either DOM or SAX's {@link
   * org.xml.sax.DocumentHandler#endDocument}.
   * <p>
   * For elements that are not specified as whitespace preserving,
   * the serializer will potentially break long text lines at space
   * boundaries, indent lines, and serialize elements on separate
   * lines. Line terminators will be regarded as spaces, and
   * spaces at beginning of line will be stripped.
   *
   *
   * @version $Revision: 1.1 $ $Date: 2000/10/02 02:43:13 $
   * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
   * @see Serializer
   */
  public final class XMLSerializer
      extends BaseMarkupSerializer
  {
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
       * first.
       */
      public XMLSerializer()
      {
        super();
        OutputFormat format = new OutputFormat();
        format.setMethod(Method.XML);
        setOutputFormat(format);
      }
  
  
      /**
       * Constructs a new serializer. The serializer cannot be used without
       * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
       * first.
       */
      public XMLSerializer( OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XML);
        }
        setOutputFormat(format);
      }
  
  
      /**
       * Constructs a new serializer that writes to the specified writer
       * using the specified output format. If <tt>format</tt> is null,
       * will use a default output format.
       *
       * @param writer The writer to use
       * @param format The output format to use, null for the default
       */
      public XMLSerializer( Writer writer, OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XML);
        }
        setOutputFormat(format);
        setWriter( writer );
      }
  
  
      /**
       * Constructs a new serializer that writes to the specified output
       * stream using the specified output format. If <tt>format</tt>
       * is null, will use a default output format.
       *
       * @param output The output stream to use
       * @param format The output format to use, null for the default
       */
      public XMLSerializer( OutputStream output, OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XML);
        }
        setOutputFormat(format);
        setOutputStream( output );
      }
  
  
      public void setOutputFormat( OutputFormat format )
      {
        if(null == format)
        {
          format = new OutputFormat();
          format.setMethod(Method.XML);
        }
        super.setOutputFormat(format);
      }
  
       /**
       * Returns true if the text node children of the given elements
       * should be output as CDATA.
       *
       * @param tagName The element's tag name
       * @return True if should serialize as CDATA
       */
      public boolean isCDataElement( String namespaceURI, String localName )
      {
          int i;
          QName[] cdataElements = _format.getCDataElements();
  
          if ( cdataElements == null )
              return false;
          for ( i = 0 ; i < cdataElements.length ; ++i )
              if ( cdataElements[ i ].equals( namespaceURI,localName  ) )
                  return true;
          return false;
      }
  
       /**
       * Returns true if the text node children of the given elements
       * should be output as CDATA.
       *
       * @param tagName The element's tag name
       * @return True if should serialize as CDATA
       */
      public boolean isNonEscapingElement( String namespaceURI, String localName )
      {
          int i;
          QName[] nonEscapingElements = _format.getNonEscapingElements();
  
          if ( nonEscapingElements == null )
              return false;
          for ( i = 0 ; i < nonEscapingElements.length ; ++i )
              if ( nonEscapingElements[ i ].equals( namespaceURI,localName  ) )
                  return true;
          return false;
      }
  
      //-----------------------------------------//
      // SAX content handler serializing methods //
      //-----------------------------------------//
  
      public void startElement( String namespaceURI, String localName,
                                String rawName, Attributes attrs )
      {
          int          i;
          boolean      preserveSpace;
          ElementState state;
          String       name;
          String       value;
          boolean      addNSAttr = false;
  
          if ( _printer == null )
              throw new IllegalStateException( "SER002 No writer supplied for serializer" );
  
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( localName == null ? rawName : localName );
          } else {
              // For any other element, if first in parent, then
              // close parent's opening tag and use the parnet's
              // space preserving.
              if ( state.empty )
                  _printer.printText( '>' );
              // Must leave CData section first
              if ( state.inCData )
              {
                  _printer.printText( "]]>" );
                  state.inCData = false;
              }
              // Indent this element on a new line if the first
              // content of the parent element or immediately
              // following an element.
              if ( _indenting && ! state.preserveSpace &&
                   ( state.empty || state.afterElement ) )
                  _printer.breakLine();
          }
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
          if ( rawName == null ) {
              rawName = localName;
              if ( namespaceURI != null ) {
                  String prefix;
                  prefix = getPrefix( namespaceURI );
                  if ( prefix.length() > 0 )
                      rawName = prefix + ":" + localName;
              }
              addNSAttr = true;
          }
  
          _printer.printText( '<' );
          _printer.printText( rawName );
          _printer.indent();
  
          // For each attribute print it's name and value as one part,
          // separated with a space so the element can be broken on
          // multiple lines.
          if ( attrs != null ) {
              for ( i = 0 ; i < attrs.getLength() ; ++i ) {
                  _printer.printSpace();
  
                  name = attrs.getQName( i );
                  if ( name == null ) {
                      String prefix;
                      String attrURI;
  
                      name = attrs.getLocalName( i );
                      attrURI = attrs.getURI( i );
                      if ( attrURI != null && ( namespaceURI == null ||
                                                ! attrURI.equals( namespaceURI ) ) ) {
                          prefix = getPrefix( attrURI );
                          if ( prefix != null && prefix.length() > 0 )
                              name = prefix + ":" + name;
                      }
                  }
  
                  value = attrs.getValue( i );
                  if ( value == null )
                      value = "";
                  _printer.printText( name );
                  _printer.printText( "=\"" );
                  printEscaped( value );
                  _printer.printText( '"' );
  
                  // If the attribute xml:space exists, determine whether
                  // to preserve spaces in this and child nodes based on
                  // its value.
                  if ( name.equals( "xml:space" ) ) {
                      if ( value.equals( "preserve" ) )
                          preserveSpace = true;
                      else
                          preserveSpace = _format.getPreserveSpace();
                  }
              }
          }
  
          if ( addNSAttr ) {
              Enumeration enum;
  
              enum = _prefixes.keys();
              while ( enum.hasMoreElements() ) {
                  _printer.printSpace();
                  value = (String) enum.nextElement();
                  name = (String) _prefixes.get( value );
                  if ( name.length() == 0 ) {
                      _printer.printText( "xmlns=\"" );
                      printEscaped( value );
                      _printer.printText( '"' );
                  } else {
                      _printer.printText( "xmlns:" );
                      _printer.printText( name );
                      _printer.printText( "=\"" );
                      printEscaped( value );
                      _printer.printText( '"' );
                  }
              }
          }
  
          // Now it's time to enter a new element state
          // with the tag name and space preserving.
          // We still do not change the curent element state.
          state = enterElementState( namespaceURI, localName, rawName, preserveSpace );
          state.doCData = isCDataElement( namespaceURI, localName );
          state.unescaped = isNonEscapingElement( namespaceURI, localName );
      }
  
  
      public void endElement( String namespaceURI, String localName,
                              String rawName )
      {
          ElementState state;
  
          // Works much like content() with additions for closing
          // an element. Note the different checks for the closed
          // element's state and the parent element's state.
          _printer.unindent();
          state = getElementState();
          if ( state.empty ) {
              _printer.printText( "/>" );
          } else {
              // Must leave CData section first
              if ( state.inCData )
                  _printer.printText( "]]>" );
              // This element is not empty and that last content was
              // another element, so print a line break before that
              // last element and this element's closing tag.
              if ( _indenting && ! state.preserveSpace && state.afterElement )
                  _printer.breakLine();
              _printer.printText( "</" );
              _printer.printText( state.rawName );
              _printer.printText( '>' );
          }
          // Leave the element state and update that of the parent
          // (if we're not root) to not empty and after element.
          state = leaveElementState();
          state.afterElement = true;
          state.empty = false;
          if ( isDocumentState() )
              _printer.flush();
      }
  
  
      //------------------------------------------//
      // SAX document handler serializing methods //
      //------------------------------------------//
  
  
      public void startElement( String tagName, AttributeList attrs )
      {
          int          i;
          boolean      preserveSpace;
          ElementState state;
          String       name;
          String       value;
  
          if ( _printer == null )
              throw new IllegalStateException( "SER002 No writer supplied for serializer" );
  
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( tagName );
          } else {
              // For any other element, if first in parent, then
              // close parent's opening tag and use the parnet's
              // space preserving.
              if ( state.empty )
                  _printer.printText( '>' );
              // Must leave CData section first
              if ( state.inCData )
              {
                  _printer.printText( "]]>" );
                  state.inCData = false;
              }
              // Indent this element on a new line if the first
              // content of the parent element or immediately
              // following an element.
              if ( _indenting && ! state.preserveSpace &&
                   ( state.empty || state.afterElement ) )
                  _printer.breakLine();
          }
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
  
          _printer.printText( '<' );
          _printer.printText( tagName );
          _printer.indent();
  
          // For each attribute print it's name and value as one part,
          // separated with a space so the element can be broken on
          // multiple lines.
          if ( attrs != null ) {
              for ( i = 0 ; i < attrs.getLength() ; ++i ) {
                  _printer.printSpace();
                  name = attrs.getName( i );
                  value = attrs.getValue( i );
                  if ( value != null ) {
                      _printer.printText( name );
                      _printer.printText( "=\"" );
                      printEscaped( value );
                      _printer.printText( '"' );
                  }
  
                  // If the attribute xml:space exists, determine whether
                  // to preserve spaces in this and child nodes based on
                  // its value.
                  if ( name.equals( "xml:space" ) ) {
                      if ( value.equals( "preserve" ) )
                          preserveSpace = true;
                      else
                          preserveSpace = _format.getPreserveSpace();
                  }
              }
          }
          // Now it's time to enter a new element state
          // with the tag name and space preserving.
          // We still do not change the curent element state.
          state = enterElementState( null, null, tagName, preserveSpace );
          
          // This will not work correctly with namespaces... but what is to be done?  -sb
          state.doCData = isCDataElement( null, tagName );
          state.unescaped = isNonEscapingElement( null, tagName );
      }
  
  
      public void endElement( String tagName )
      {
          endElement( null, null, tagName );
      }
  
  
  
      //------------------------------------------//
      // Generic node serializing methods methods //
      //------------------------------------------//
  
  
      /**
       * Called to serialize the document's DOCTYPE by the root element.
       * The document type declaration must name the root element,
       * but the root element is only known when that element is serialized,
       * and not at the start of the document.
       * <p>
       * This method will check if it has not been called before ({@link #_started}),
       * will serialize the document type declaration, and will serialize all
       * pre-root comments and PIs that were accumulated in the document
       * (see {@link #serializePreRoot}). Pre-root will be serialized even if
       * this is not the first root element of the document.
       */
      protected void startDocument( String rootTagName )
      {
          int    i;
          String dtd;
  
          dtd = _printer.leaveDTD();
          if ( ! _started ) {
  
              if ( ! _format.getOmitXMLDeclaration() ) {
                  StringBuffer    buffer;
  
                  // Serialize the document declaration appreaing at the head
                  // of very XML document (unless asked not to).
                  buffer = new StringBuffer( "<?xml version=\"" );
                  if ( _format.getVersion() != null )
                      buffer.append( _format.getVersion() );
                  else
                      buffer.append( "1.0" );
                  buffer.append( '"' );
                  String encoding = _format.getEncoding();
                  if ( encoding != null ) {
                      buffer.append( " encoding=\"" );
                      buffer.append( encoding.toUpperCase() );
                      buffer.append( '"' );
                  }
                  if ( _format.getStandalone() && _docTypeSystemId == null &&
                       _docTypePublicId == null )
                      buffer.append( " standalone=\"yes\"" );
                  buffer.append( "?>" );
                  _printer.printText( buffer );
                  _printer.breakLine();
              }
  
              // -sb
              // if ( ! _format.getOmitDocumentType() ) 
              {
                  if ( _docTypeSystemId != null ) {
                      // System identifier must be specified to print DOCTYPE.
                      // If public identifier is specified print 'PUBLIC
                      // <public> <system>', if not, print 'SYSTEM <system>'.
                      _printer.printText( "<!DOCTYPE " );
                      _printer.printText( rootTagName );
                      if ( _docTypePublicId != null ) {
                          _printer.printText( " PUBLIC " );
                          printDoctypeURL( _docTypePublicId );
                          if ( _indenting ) {
                              _printer.breakLine();
                              for ( i = 0 ; i < 18 + rootTagName.length() ; ++i )
                                  _printer.printText( " " );
                          } else
                              _printer.printText( " " );
                      printDoctypeURL( _docTypeSystemId );
                      }
                      else {
                          _printer.printText( " SYSTEM " );
                          printDoctypeURL( _docTypeSystemId );
                      }
                      
                      // If we accumulated any DTD contents while printing.
                      // this would be the place to print it.
                      if ( dtd != null && dtd.length() > 0 ) {
                          _printer.printText( " [" );
                          printText( dtd, true, true );
                          _printer.printText( ']' );
                      }
                      
                      _printer.printText( ">" );
                      _printer.breakLine();
                  } else if ( dtd != null && dtd.length() > 0 ) {
                      _printer.printText( "<!DOCTYPE " );
                      _printer.printText( rootTagName );
                      _printer.printText( " [" );
                      printText( dtd, true, true );
                      _printer.printText( "]>" );
                      _printer.breakLine();
                  }
              }
          }
          _started = true;
          // Always serialize these, even if not te first root element.
          serializePreRoot();
      }
  
  
      /**
       * Called to serialize a DOM element. Equivalent to calling {@link
       * #startElement}, {@link #endElement} and serializing everything
       * inbetween, but better optimized.
       */
      protected void serializeElement( Element elem )
      {
          Attr         attr;
          NamedNodeMap attrMap;
          int          i;
          Node         child;
          ElementState state;
          boolean      preserveSpace;
          String       name;
          String       value;
          String       tagName;
  
          tagName = elem.getTagName();
          state = getElementState();
          if ( isDocumentState() ) {
              // If this is the root element handle it differently.
              // If the first root element in the document, serialize
              // the document's DOCTYPE. Space preserving defaults
              // to that of the output format.
              if ( ! _started )
                  startDocument( tagName );
          } else {
              // For any other element, if first in parent, then
              // close parent's opening tag and use the parnet's
              // space preserving.
              if ( state.empty )
                  _printer.printText( '>' );
              // Must leave CData section first
              if ( state.inCData )
              {
                  _printer.printText( "]]>" );
                  state.inCData = false;
              }
              // Indent this element on a new line if the first
              // content of the parent element or immediately
              // following an element.
              if ( _indenting && ! state.preserveSpace &&
                   ( state.empty || state.afterElement ) )
                  _printer.breakLine();
          }
          preserveSpace = state.preserveSpace;
  
          // Do not change the current element state yet.
          // This only happens in endElement().
  
          _printer.printText( '<' );
          _printer.printText( tagName );
          _printer.indent();
  
          // Lookup the element's attribute, but only print specified
          // attributes. (Unspecified attributes are derived from the DTD.
          // For each attribute print it's name and value as one part,
          // separated with a space so the element can be broken on
          // multiple lines.
          attrMap = elem.getAttributes();
          if ( attrMap != null ) {
              for ( i = 0 ; i < attrMap.getLength() ; ++i ) {
                  attr = (Attr) attrMap.item( i );
                  name = attr.getName();
                  value = attr.getValue();
                  if ( value == null )
                      value = "";
                  if ( attr.getSpecified() ) {
                      _printer.printSpace();
                      _printer.printText( name );
                      _printer.printText( "=\"" );
                      printEscaped( value );
                      _printer.printText( '"' );
                  }
                  // If the attribute xml:space exists, determine whether
                  // to preserve spaces in this and child nodes based on
                  // its value.
                  if ( name.equals( "xml:space" ) ) {
                      if ( value.equals( "preserve" ) )
                          preserveSpace = true;
                      else
                          preserveSpace = _format.getPreserveSpace();
                  }
              }
          }
  
          // If element has children, then serialize them, otherwise
          // serialize en empty tag.
          if ( elem.hasChildNodes() ) {
              // Enter an element state, and serialize the children
              // one by one. Finally, end the element.
              state = enterElementState( null, null, tagName, preserveSpace );
              
              // TBD: This won't work right for namespaces. -sb
              state.doCData = isCDataElement( null, tagName );
              state.unescaped = isNonEscapingElement( null, tagName );
              
              child = elem.getFirstChild();
              while ( child != null ) {
                  serializeNode( child );
                  child = child.getNextSibling();
              }
              endElement( tagName );
          } else {
              _printer.unindent();
              _printer.printText( "/>" );
              // After element but parent element is no longer empty.
              state.afterElement = true;
              state.empty = false;
              if ( isDocumentState() )
                  _printer.flush();
          }
      }
  
  
      protected String getEntityRef( char ch )
      {
          // Encode special XML characters into the equivalent character references.
          // These five are defined by default for all XML documents.
          switch ( ch ) {
          case '<':
              return "lt";
          case '>':
              return "gt";
          case '"':
              return "quot";
          case '\'':
              return "apos";
          case '&':
              return "amp";
          }
          return null;
      }
  
  
  }
  
  
  
  
  
  1.3       +37 -27    xml-xalan/java/src/org/apache/xpath/DOM2Helper.java
  
  Index: DOM2Helper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/DOM2Helper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DOM2Helper.java	2000/08/11 02:57:20	1.2
  +++ DOM2Helper.java	2000/10/02 02:43:14	1.3
  @@ -73,6 +73,8 @@
   import org.xml.sax.InputSource;
   import org.xml.sax.Parser;
   
  +import javax.xml.parsers.*;
  +
   /**
    * <meta name="usage" content="general"/>
    * Provides XSLTProcessor an interface to the Xerces XML parser.  This 
  @@ -97,8 +99,8 @@
     public void checkNode(Node node)
       throws SAXException
     {
  -    if(!(node instanceof org.apache.xerces.dom.NodeImpl))
  -      throw new SAXException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XERCES_CANNOT_HANDLE_NODES, new Object[]{((Object)node).getClass()})); //"DOM2Helper can not handle nodes of type"
  +    // if(!(node instanceof org.apache.xerces.dom.NodeImpl))
  +    //  throw new SAXException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XERCES_CANNOT_HANDLE_NODES, new Object[]{((Object)node).getClass()})); //"DOM2Helper can not handle nodes of type"
           //+((Object)node).getClass());
     }
   
  @@ -150,42 +152,50 @@
     public void parse (InputSource source)
       throws SAXException
     {
  -    // I guess I should use JAXP factory here... when it's legal.
  -    org.apache.xerces.parsers.DOMParser parser 
  -      = new org.apache.xerces.parsers.DOMParser();
  -    
  -    // domParser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", getShouldExpandEntityRefs()? false : true);
  -    if(m_useDOM2getNamespaceURI)
  +    try
       {
  +      // I guess I should use JAXP factory here... when it's legal.
  +      // org.apache.xerces.parsers.DOMParser parser 
  +      //  = new org.apache.xerces.parsers.DOMParser();
  +      DocumentBuilderFactory builderFactory 
  +        = DocumentBuilderFactory.newInstance();
  +      DocumentBuilder parser = builderFactory.newDocumentBuilder();
  +      
  +      /*
  +      // domParser.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", getShouldExpandEntityRefs()? false : true);
  +      if(m_useDOM2getNamespaceURI)
  +      {
         parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", true);
         parser.setFeature("http://xml.org/sax/features/namespaces", true);
  -    }
  -    else
  -    {
  +      }
  +      else
  +      {
         parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
  -    }
  -    
  -    parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
  -
  -    String ident = (null == source.getSystemId())
  -                   ? "Input XSL" : source.getSystemId();
  -    parser.setErrorHandler(new org.apache.xalan.utils.DefaultErrorHandler(ident));
  -
  -    // if(null != m_entityResolver)
  -    // {
  -    // System.out.println("Setting the entity resolver.");
  -    //  parser.setEntityResolver(m_entityResolver);
  -    // }
  +      }
  +      
  +      parser.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
  +      */
  +      String ident = (null == source.getSystemId())
  +                     ? "Input XSL" : source.getSystemId();
  +      parser.setErrorHandler(new org.apache.xalan.utils.DefaultErrorHandler(ident));
  +
  +      // if(null != m_entityResolver)
  +      // {
  +      // System.out.println("Setting the entity resolver.");
  +      //  parser.setEntityResolver(m_entityResolver);
  +      // }
   
  -    try
  +      setDocument(parser.parse(source));
  +    }
  +    catch(ParserConfigurationException pce)
       {
  -      parser.parse(source);
  +      throw new SAXException(pce);
       }
       catch(IOException ioe)
       {
         throw new SAXException(ioe);
       }
  -    setDocument(((org.apache.xerces.parsers.DOMParser)parser).getDocument());
  +    // setDocument(((org.apache.xerces.parsers.DOMParser)parser).getDocument());
     }
   
     /**
  
  
  
  1.2       +14 -53    xml-xalan/java/src/org/apache/xpath/NodeSet.java
  
  Index: NodeSet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NodeSet.java	2000/07/05 14:44:26	1.1
  +++ NodeSet.java	2000/10/02 02:43:14	1.2
  @@ -505,66 +505,27 @@
       int insertIndex = -1;
       if(test)
       {
  -      try
  +      // This needs to do a binary search, but a binary search 
  +      // is somewhat tough because the sequence test involves 
  +      // two nodes.
  +      int size = size(), i;
  +      for(i = size-1; i >= 0; i--)
         {
  -        int index1 = ((org.apache.xalan.dtm.DTMProxy)node).getDTMNodeNumber();
  -        
  -        // This needs to do a binary search, but a binary search 
  -        // is somewhat tough because the sequence test involves 
  -        // two nodes.
  -        int size = size(), i;
  -        for(i = size-1; i >= 0; i--)
  +        Node child = (Node)elementAt(i);
  +        if(child == node)
           {
  -          Node node2 = (Node)elementAt(i);
  -          // Check to see if the nodes share the same parent.  If they 
  -          // do not, then don't try to sort with it.
  -          if(!((((1 == index1) && (node == node2)) ||
  -             (node.getOwnerDocument() == node2.getOwnerDocument()))))
  -          {
  -            continue;
  -          }
  -          int index2 = ((org.apache.xalan.dtm.DTMProxy)node2).getDTMNodeNumber();
  -          if((index2 == index1))
  -          {
  -            i = -2; // Duplicate, suppress insert
  -            break; 
  -          }
  -          if(index2 < index1)
  -          {
  -            break;
  -          }
  +          i = -2; // Duplicate, suppress insert
  +          break; 
           }
  -        if(i != -2)
  +        if(!support.getDOMHelper().isNodeAfter(node, child))
           {
  -          insertIndex = i+1;
  -          insertElementAt(node, insertIndex);
  +          break;
           }
  -        
         }
  -      catch(ClassCastException cce)
  +      if(i != -2)
         {
  -        // This needs to do a binary search, but a binary search 
  -        // is somewhat tough because the sequence test involves 
  -        // two nodes.
  -        int size = size(), i;
  -        for(i = size-1; i >= 0; i--)
  -        {
  -          Node child = (Node)elementAt(i);
  -          if(child == node)
  -          {
  -            i = -2; // Duplicate, suppress insert
  -            break; 
  -          }
  -          if(!support.getDOMHelper().isNodeAfter(node, child))
  -          {
  -            break;
  -          }
  -        }
  -        if(i != -2)
  -        {
  -          insertIndex = i+1;
  -          insertElementAt(node, insertIndex);
  -        }
  +        insertIndex = i+1;
  +        insertElementAt(node, insertIndex);
         }
       }
       else
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Attr.java
  
  Index: Attr.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>Attr</code> interface represents an attribute in an 
   * <code>Element</code> object. Typically the allowable values for the 
   * attribute are defined in a document type definition.
   * <p><code>Attr</code> objects inherit the <code>Node</code>  interface, but 
   * since they are not actually child nodes of the element  they describe, the 
   * DOM does not consider them part of the document  tree.  Thus, the 
   * <code>Node</code> attributes <code>parentNode</code> ,  
   * <code>previousSibling</code> , and <code>nextSibling</code> have a  
   * <code>null</code> value for <code>Attr</code> objects. The DOM takes the  
   * view that attributes are properties of elements rather than having a  
   * separate identity from the elements they are associated with;  this should 
   * make it more efficient to implement such features as default attributes 
   * associated with all elements of a  given type.  Furthermore, 
   * <code>Attr</code> nodes may not be immediate children of a 
   * <code>DocumentFragment</code> . However, they can be associated with 
   * <code>Element</code> nodes contained within a <code>DocumentFragment</code>
   *  . In short, users and implementors of the DOM need to be aware that  
   * <code>Attr</code> nodes have some things in  common with other objects 
   * inheriting the <code>Node</code> interface,  but they also are quite 
   * distinct.
   * <p> The attribute's effective value is determined as follows: if this  
   * attribute has been explicitly assigned any value, that value is the  
   * attribute's effective value; otherwise, if there is a declaration for  
   * this attribute, and that declaration includes a default value, then  that 
   * default value is the attribute's effective value; otherwise, the  
   * attribute does not exist on this element in the structure model until  it 
   * has been explicitly added.  Note that the <code>nodeValue</code>  
   * attribute on the <code>Attr</code> instance can also be used to retrieve 
   * the string version of the attribute's value(s). 
   * <p> In XML, where the value of an attribute can contain entity references, 
   * the child nodes of the <code>Attr</code> node provide a representation in 
   * which entity references are not expanded. These child nodes may be either 
   * <code>Text</code> or <code>EntityReference</code> nodes. Because the 
   * attribute type may be unknown, there are no tokenized attribute values. 
   */
  public interface Attr extends Node {
      /**
       *  Returns the name of this attribute. 
       */
      public String getName();
  
      /**
       *  If this attribute was explicitly given a value in the original 
       * document, this is <code>true</code> ; otherwise, it is 
       * <code>false</code> . Note that the implementation is in charge of this 
       * attribute, not the user. If the user changes the value of the 
       * attribute (even if it ends up having the same value as the default 
       * value) then the <code>specified</code> flag is automatically flipped 
       * to <code>true</code> .  To re-specify the attribute as the default 
       * value from the DTD, the user must delete the attribute. The 
       * implementation will then make a new attribute available with 
       * <code>specified</code> set to <code>false</code> and the default value 
       * (if one exists).
       * <br> In summary: If the attribute has an assigned value in the document 
       * then  <code>specified</code> is <code>true</code> , and the value is 
       * the  assigned value. If the attribute has no assigned value in the 
       * document and has  a default value in the DTD, then 
       * <code>specified</code> is <code>false</code> ,  and the value is the 
       * default value in the DTD. If the attribute has no assigned value in 
       * the document and has  a value of #IMPLIED in the DTD, then the  
       * attribute does not appear  in the structure model of the document.
       */
      public boolean getSpecified();
  
      /**
       *  On retrieval, the value of the attribute is returned as a string. 
       * Character and general entity references are replaced with their 
       * values. See also the method <code>getAttribute</code> on the  
       * <code>Element</code> interface.
       * <br> On setting, this creates a <code>Text</code> node with the unparsed
       *  contents of the string. I.e. any characters that an XML processor 
       * would recognize as markup are instead treated as literal text. See 
       * also the method <code>setAttribute</code> on the  <code>Element</code> 
       * interface.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
       */
      public String getValue();
      public void setValue(String value)
                              throws DOMException;
  
      /**
       *  The <code>Element</code> node this attribute is attached to or 
       * <code>null</code> if this attribute is not in use.
       * @since DOM Level 2
       */
      public Element getOwnerElement();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/CDATASection.java
  
  Index: CDATASection.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  CDATA sections are used to escape blocks of text containing  characters 
   * that would otherwise be regarded as markup. The only  delimiter that is 
   * recognized in a CDATA section is the "]]&gt;" string  that ends the CDATA 
   * section. CDATA sections cannot be  nested. Their primary purpose is for 
   * including material such as XML fragments, without needing to escape all 
   * the delimiters.
   * <p> The <code>DOMString</code> attribute of the <code>Text</code> node 
   * holds the text that is contained by the CDATA section. Note that this  may 
   * contain characters that need to be escaped outside of CDATA sections and 
   * that, depending on the character encoding ("charset") chosen for 
   * serialization, it may be impossible to write out some characters as part 
   * of a CDATA section. 
   * <p> The <code>CDATASection</code> interface inherits from the 
   * <code>CharacterData</code> interface through the <code>Text</code> 
   * interface. Adjacent <code>CDATASections</code> nodes are not merged by use 
   * of the <code>normalize</code> method of the <code>Element</code> interface.
   *  Because no markup is recognized within a <code>CDATASection</code> , 
   * character numeric references cannot be used as an escape mechanism when 
   * serializing. Therefore, action needs to be taken when serializing a 
   * <code>CDATASection</code> with a character encoding where some of the 
   * contained characters cannot be represented. Failure to do so would not 
   * produce well-formed XML. One potential solution in the serialization 
   * process is to end the CDATA section before the character, output the 
   * character using a  character reference or entity reference, and open a new 
   * CDATA section  for any further characters in the text node. Note, however, 
   * that some  code conversion libraries at the time of writing do not return 
   * an error or exception when a character is missing from the encoding,  
   * making the task of ensuring that data is not corrupted on serialization 
   * more difficult.
   */
  public interface CDATASection extends Text {
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/CharacterData.java
  
  Index: CharacterData.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>CharacterData</code> interface extends Node with a set of 
   * attributes and methods for accessing character data in the DOM.  For 
   * clarity this set is defined here rather than on each object that uses 
   * these attributes and methods. No DOM objects correspond directly to 
   * <code>CharacterData</code> , though <code>Text</code> and others do 
   * inherit the interface from it. All <code>offsets</code> in this interface 
   * start from 0.
   * <p> As explained in the <code>DOMString</code> interface, text strings in 
   * the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units.  In 
   * the following, the term  16-bit units is used whenever necessary to 
   * indicate that indexing on CharacterData is done in 16-bit units.
   */
  public interface CharacterData extends Node {
      /**
       *  The character data of the node that implements this interface. The DOM 
       * implementation may not put arbitrary limits on the amount of data that 
       * may be stored in a  <code>CharacterData</code> node. However, 
       * implementation limits may  mean that the entirety of a node's data may 
       * not fit into a single <code>DOMString</code> . In such cases, the user 
       * may call <code>substringData</code> to retrieve the data in 
       * appropriately sized pieces.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
       * @exception DOMException
       *    DOMSTRING_SIZE_ERR: Raised when it would return more characters 
       *   than fit in a <code>DOMString</code> variable on the implementation 
       *   platform.
       */
      public String getData()
                                    throws DOMException;
      public void setData(String data)
                                    throws DOMException;
  
      /**
       *  The number of  16-bit units that are available through 
       * <code>data</code> and the <code>substringData</code> method below.  
       * This may have the value zero, i.e., <code>CharacterData</code> nodes 
       * may be empty.
       */
      public int getLength();
  
      /**
       *  Extracts a range of data from the node.
       * @param offset  Start offset of substring to extract.
       * @param count  The number of 16-bit units to extract.
       * @return  The specified substring. If the sum of <code>offset</code> and 
       *   <code>count</code> exceeds the <code>length</code> , then all 16-bit 
       *   units to the end of the data are returned.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 
       *   negative or greater than the number of 16-bit units in 
       *   <code>data</code> , or if the specified <code>count</code> is 
       *   negative.
       *   <br> DOMSTRING_SIZE_ERR: Raised if the specified range of text does 
       *   not fit into a <code>DOMString</code> .
       */
      public String substringData(int offset, 
                                  int count)
                                  throws DOMException;
  
      /**
       *  Append the string to the end of the character data of the node. Upon 
       * success, <code>data</code> provides access to the concatenation of 
       * <code>data</code> and the <code>DOMString</code> specified.
       * @param arg  The <code>DOMString</code> to append.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public void appendData(String arg)
                             throws DOMException;
  
      /**
       *  Insert a string at the specified character offset.
       * @param offset  The character offset at which to insert.
       * @param arg  The <code>DOMString</code> to insert.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 
       *   negative or greater than the number of 16-bit units in 
       *   <code>data</code> .
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public void insertData(int offset, 
                             String arg)
                             throws DOMException;
  
      /**
       *  Remove a range of  16-bit units from the node. Upon success, 
       * <code>data</code> and <code>length</code> reflect the change.
       * @param offset  The offset from which to start removing.
       * @param count  The number of 16-bit units to delete. If the sum of 
       *   <code>offset</code> and <code>count</code> exceeds 
       *   <code>length</code> then all 16-bit units from <code>offset</code> 
       *   to the end of the data are deleted.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 
       *   negative or greater than the number of 16-bit units in 
       *   <code>data</code> , or if the specified <code>count</code> is 
       *   negative.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public void deleteData(int offset, 
                             int count)
                             throws DOMException;
  
      /**
       *  Replace the characters starting at the specified  16-bit unit offset 
       * with the specified string.
       * @param offset  The offset from which to start replacing.
       * @param count  The number of 16-bit units to replace. If the sum of 
       *   <code>offset</code> and <code>count</code> exceeds 
       *   <code>length</code> , then all 16-bit units to the end of the data 
       *   are replaced; (i.e., the effect is the same as a <code>remove</code> 
       *   method call with the same range, followed by an <code>append</code> 
       *   method invocation).
       * @param arg  The <code>DOMString</code> with which the range must be 
       *   replaced.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 
       *   negative or greater than the number of 16-bit units in 
       *   <code>data</code> , or if the specified <code>count</code> is 
       *   negative.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public void replaceData(int offset, 
                              int count, 
                              String arg)
                              throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Comment.java
  
  Index: Comment.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  This interface inherits from <code>CharacterData</code> and represents the 
   * content of a comment, i.e., all the characters between the starting '
   * <code>&lt;!--</code> ' and ending '<code>--&gt;</code> '. Note that this 
   * is the definition of a comment in XML, and, in practice, HTML, although 
   * some HTML tools may implement the full SGML comment structure.
   */
  public interface Comment extends CharacterData {
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/DOMException.java
  
  Index: DOMException.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  DOM operations only raise exceptions in "exceptional" circumstances, 
   * i.e., when an operation is impossible to perform (either for logical 
   * reasons, because data is lost, or  because the implementation has become 
   * unstable). In general, DOM methods return specific error values in ordinary
   *  processing situations, such as out-of-bound errors when using 
   * <code>NodeList</code> .  
   * <p> Implementations may raise other exceptions under other circumstances. 
   * For example, implementations may raise an implementation-dependent  
   * exception if a <code>null</code> argument is passed. 
   * <p> Some languages and object systems do not support the concept of 
   * exceptions. For such systems, error conditions may be indicated using 
   * native error reporting mechanisms. For some bindings, for example, methods 
   * may return error codes similar to those listed in the corresponding method 
   * descriptions.
   */
  public class DOMException extends RuntimeException {
      public DOMException(short code, String message) {
         super(message);
         this.code = code;
      }
      public short   code;
      // ExceptionCode
      public static final short INDEX_SIZE_ERR            = 1;
      public static final short DOMSTRING_SIZE_ERR        = 2;
      public static final short HIERARCHY_REQUEST_ERR     = 3;
      public static final short WRONG_DOCUMENT_ERR        = 4;
      public static final short INVALID_CHARACTER_ERR     = 5;
      public static final short NO_DATA_ALLOWED_ERR       = 6;
      public static final short NO_MODIFICATION_ALLOWED_ERR = 7;
      public static final short NOT_FOUND_ERR             = 8;
      public static final short NOT_SUPPORTED_ERR         = 9;
      public static final short INUSE_ATTRIBUTE_ERR       = 10;
      /** 
       * @since DOM Level 2
       */ 
      public static final short INVALID_STATE_ERR         = 11;
      /** 
       * @since DOM Level 2
       */ 
      public static final short SYNTAX_ERR                = 12;
      /** 
       * @since DOM Level 2
       */ 
      public static final short INVALID_MODIFICATION_ERR  = 13;
      /** 
       * @since DOM Level 2
       */ 
      public static final short NAMESPACE_ERR             = 14;
      /** 
       * @since DOM Level 2
       */ 
      public static final short INVALID_ACCESS_ERR        = 15;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/DOMImplementation.java
  
  Index: DOMImplementation.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>DOMImplementation</code> interface provides a number of methods 
   * for performing operations that are independent of any particular instance 
   * of the document object model.
   */
  public interface DOMImplementation {
      /**
       *  Test if the DOM implementation implements a specific feature.
       * @param feature  The name of the feature to test (case-insensitive). The 
       *   legal values are defined throughout this specification and listed in 
       *   the  section. The name must be an  XML name . To avoid possible 
       *   conflicts, as a convention, names referring to features defined 
       *   outside the DOM spec should be made unique by reversing the name of 
       *   the Internet domain name of the person (or the organization that 
       *   person belongs to) who defines the feature, component by component, 
       *   and use this as a prefix. For instance, the W3C SYMM Working Group 
       *   defines the feature "org.w3c.dom.smil".
       * @param version  This is the version number of the feature to test. In 
       *   Level 2, this is the string "2.0". If the version is not specified, 
       *   supporting any version of the feature causes the method to return 
       *   <code>true</code> .
       * @return <code>true</code> if the feature is implemented in the 
       *   specified version, <code>false</code> otherwise.
       */
      public boolean hasFeature(String feature, 
                                String version);
  
      /**
       *  Creates an empty <code>DocumentType</code> node. Entity declarations 
       * and notations are not made available. Entity reference expansions and 
       * default attribute additions do not occur. It is expected that a future 
       * version of the DOM will provide a way for populating a 
       * <code>DocumentType</code> .
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param qualifiedName  The  qualified name of the document type to be 
       *   created. 
       * @param publicId  The external subset public identifier.
       * @param systemId  The external subset system identifier.
       * @return  A new <code>DocumentType</code> node with 
       *   <code>Node.ownerDocument</code> set to <code>null</code> .
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified qualified name 
       *   contains an illegal character.
       *   <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is 
       *   malformed.
       * @since DOM Level 2
       */
      public DocumentType createDocumentType(String qualifiedName, 
                                             String publicId, 
                                             String systemId)
                                             throws DOMException;
  
      /**
       *  Creates an XML <code>Document</code> object of the specified type with 
       * its document element. HTML-only DOM implementations do not need to 
       * implement this method.
       * @param namespaceURI  The  namespace URI of the document element to 
       *   create, or <code>null</code> .
       * @param qualifiedName  The  qualified name of the document element to be 
       *   created.
       * @param doctype  The type of document to be created or <code>null</code> 
       *   . When <code>doctype</code> is not <code>null</code> , its 
       *   <code>Node.ownerDocument</code> attribute is set to the document 
       *   being created.
       * @return  A new <code>Document</code> object.
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified qualified name 
       *   contains an illegal character.
       *   <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is 
       *   malformed, or if the <code>qualifiedName</code> has a prefix that is 
       *   "xml" and the <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/XML/1998/namespace".
       *   <br> WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already 
       *   been used with a different document.
       * @since DOM Level 2
       */
      public Document createDocument(String namespaceURI, 
                                     String qualifiedName, 
                                     DocumentType doctype)
                                     throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Document.java
  
  Index: Document.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>Document</code> interface represents the entire HTML or XML 
   * document. Conceptually, it is the root of the document tree, and provides 
   * the  primary access to the document's data.
   * <p> Since elements, text nodes, comments, processing instructions, etc. 
   * cannot exist outside the context of a <code>Document</code> , the 
   * <code>Document</code> interface also contains the factory methods needed 
   * to create these objects. The <code>Node</code> objects created have a 
   * <code>ownerDocument</code> attribute which associates them with the 
   * <code>Document</code> within whose context they were created.
   */
  public interface Document extends Node {
      /**
       *  The Document Type Declaration (see <code>DocumentType</code> ) 
       * associated with this document. For HTML documents as well as XML 
       * documents without a document type declaration this returns 
       * <code>null</code> . The DOM Level 2 does not support editing the 
       * Document Type Declaration, therefore <code>docType</code> cannot be 
       * altered in any way, including through the use of methods, such as 
       * <code>insertNode</code> or <code>removeNode</code> , inherited from 
       * <code>Node</code> .
       */
      public DocumentType getDoctype();
  
      /**
       *  The <code>DOMImplementation</code> object that handles this document. 
       * A DOM application may use objects from multiple  implementations.
       */
      public DOMImplementation getImplementation();
  
      /**
       *  This is a convenience attribute that allows direct access to the child 
       * node that is the root element of  the document. For HTML documents, 
       * this is the element with the tagName "HTML".
       */
      public Element getDocumentElement();
  
      /**
       *  Creates an element of the type specified. Note that the instance 
       * returned implements the <code>Element</code> interface, so attributes 
       * can be specified directly  on the returned object.
       * <br> In addition, if there are known attributes with default values, 
       * <code>Attr</code> nodes representing them are automatically created and
       *  attached to the element.
       * <br> To create an element with a qualified name and namespace URI, use 
       * the <code>createElementNS</code> method.
       * @param tagName  The name of the element type to instantiate. For XML, 
       *   this is case-sensitive. For HTML, the  <code>tagName</code> 
       *   parameter may be provided in any case,  but it must be mapped to the 
       *   canonical uppercase form by  the DOM implementation. 
       * @return  A new <code>Element</code> object with the 
       *   <code>nodeName</code> attribute set to <code>tagName</code> , and 
       *   <code>localName</code> , <code>prefix</code> , and 
       *   <code>namespaceURI</code> set to <code>null</code> .
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified name contains an 
       *   illegal character.
       */
      public Element createElement(String tagName)
                                   throws DOMException;
  
      /**
       *  Creates an empty <code>DocumentFragment</code> object. 
       * @return  A new <code>DocumentFragment</code> .
       */
      public DocumentFragment createDocumentFragment();
  
      /**
       *  Creates a <code>Text</code> node given the specified string.
       * @param data  The data for the node.
       * @return  The new <code>Text</code> object.
       */
      public Text createTextNode(String data);
  
      /**
       *  Creates a <code>Comment</code> node given the specified string.
       * @param data  The data for the node.
       * @return  The new <code>Comment</code> object.
       */
      public Comment createComment(String data);
  
      /**
       *  Creates a <code>CDATASection</code> node whose value  is the specified 
       * string.
       * @param data  The data for the <code>CDATASection</code> contents.
       * @return  The new <code>CDATASection</code> object.
       * @exception DOMException
       *    NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
       */
      public CDATASection createCDATASection(String data)
                                             throws DOMException;
  
      /**
       *  Creates a <code>ProcessingInstruction</code> node given the specified 
       * name and data strings.
       * @param target  The target part of the processing instruction.
       * @param data  The data for the node.
       * @return  The new <code>ProcessingInstruction</code> object.
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified target contains an 
       *   illegal character.
       *   <br> NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
       */
      public ProcessingInstruction createProcessingInstruction(String target, 
                                                               String data)
                                                               throws DOMException;
  
      /**
       *  Creates an <code>Attr</code> of the given name. Note that the 
       * <code>Attr</code> instance can then be set on an <code>Element</code> 
       * using the <code>setAttribute</code> method. 
       * <br> To create an attribute with a qualified name and namespace URI, use
       *  the <code>createAttributeNS</code> method.
       * @param name  The name of the attribute.
       * @return  A new <code>Attr</code> object with the <code>nodeName</code> 
       *   attribute set to <code>name</code> , and <code>localName</code> , 
       *   <code>prefix</code> , and <code>namespaceURI</code> set to 
       *   <code>null</code> .
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified name contains an 
       *   illegal character.
       */
      public Attr createAttribute(String name)
                                  throws DOMException;
  
      /**
       *  Creates an <code>EntityReference</code> object. In addition, if the 
       * referenced entity is known, the child list of the 
       * <code>EntityReference</code> node is made the same as that of the 
       * corresponding <code>Entity</code> node. If any descendant of the 
       * <code>Entity</code> node has an unbound  namespace prefix , the 
       * corresponding descendant of the created <code>EntityReference</code> 
       * node is also unbound; (its <code>namespaceURI</code> is 
       * <code>null</code> ). The DOM Level 2 does not support any mechanism to 
       * resolve namespace prefixes.
       * @param name  The name of the entity to reference. 
       * @return  The new <code>EntityReference</code> object.
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified name contains an 
       *   illegal character.
       *   <br> NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
       */
      public EntityReference createEntityReference(String name)
                                                   throws DOMException;
  
      /**
       *  Returns a <code>NodeList</code> of all the <code>Elements</code> with 
       * a given tag name in the order in which they would be encountered in a 
       * preorder traversal of the <code>Document</code> tree. 
       * @param tagname  The name of the tag to match on. The special value "*" 
       *   matches all tags.
       * @return  A new <code>NodeList</code> object containing all the matched 
       *   <code>Elements</code> .
       */
      public NodeList getElementsByTagName(String tagname);
  
      /**
       *  Imports a node from another document to this document. The returned 
       * node has no parent; (<code>parentNode</code> is <code>null</code> ). 
       * The source node is not altered or removed from the original document; 
       * this method creates a new copy of the source node.
       * <br> For all nodes, importing a node creates a node object owned by the 
       * importing document, with attribute values identical to the source 
       * node's <code>nodeName</code> and <code>nodeType</code> , plus the 
       * attributes related to namespaces (<code>prefix</code> , 
       * <code>localName</code> , and <code>namespaceURI</code> ). As in the 
       * <code>cloneNode</code> operation on a <code>Node</code> , the source 
       * node is not altered.
       * <br> Additional information is copied as appropriate to the 
       * <code>nodeType</code> , attempting to mirror the behavior expected if a
       *  fragment of XML or HTML source was copied from one document to 
       * another, recognizing that the two documents may have different DTDs in 
       * the XML case. The following list describes the specifics for every 
       * type of node. 
       * <dl>
       * <dt> ELEMENT_NODE</dt>
       * <dd> Specified attribute nodes of the source 
       * element are imported, and the generated <code>Attr</code> nodes are 
       * attached to the generated <code>Element</code> . Default attributes 
       * are  not copied, though if the document being imported into defines 
       * default attributes for this element name, those are assigned. If the 
       * <code>importNode</code> <code>deep</code> parameter was set to 
       * <code>true</code> , the descendants of the source element will be 
       * recursively imported and the resulting nodes reassembled to form the 
       * corresponding subtree.</dd>
       * <dt> ATTRIBUTE_NODE</dt>
       * <dd> The <code>specified</code> flag 
       * is set to <code>true</code> on the generated <code>Attr</code> . The 
       * descendants of the source <code>Attr</code> are recursively imported 
       * and the resulting nodes reassembled to form the corresponding subtree. 
       * Note that the <code>deep</code> parameter does not apply to 
       * <code>Attr</code> nodes; they always carry their children with them 
       * when imported.</dd>
       * <dt> TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</dt>
       * <dd> These three 
       * types of nodes inheriting from <code>CharacterData</code> copy their 
       * <code>data</code> and <code>length</code> attributes from those of the 
       * source node.</dd>
       * <dt> ENTITY_REFERENCE_NODE</dt>
       * <dd> Only the 
       * <code>EntityReference</code> itself is copied, even if a 
       * <code>deep</code> import is requested, since the source and 
       * destination documents might have defined the entity differently. If 
       * the document being imported into provides a definition for this entity 
       * name, its value is assigned.</dd>
       * <dt> ENTITY_NODE</dt>
       * <dd><code>Entity</code> nodes can 
       * be imported, however in the current release of the DOM the 
       * <code>DocumentType</code> is readonly. Ability to add these imported 
       * nodes to a <code>DocumentType</code> will be considered for addition 
       * to a future release of the DOM. On import, the <code>publicId</code> , 
       * <code>systemId</code> , and <code>notationName</code> attributes are 
       * copied. If a <code>deep</code> import is requested, the descendants of 
       * the the source <code>Entity</code> is recursively imported and the 
       * resulting nodes reassembled to form the corresponding subtree.</dd>
       * <dt> 
       * PROCESSING_INSTRUCTION_NODE</dt>
       * <dd> The imported node copies its 
       * <code>target</code> and <code>data</code> values from those of the 
       * source node.</dd>
       * <dt> DOCUMENT_NODE</dt>
       * <dd><code>Document</code> nodes cannot be 
       * imported.</dd>
       * <dt> DOCUMENT_TYPE_NODE</dt>
       * <dd><code>DocumentType</code> nodes cannot be 
       * imported.</dd>
       * <dt> DOCUMENT_FRAGMENT_NODE</dt>
       * <dd> If the <code>deep</code> option was 
       * set <code>true</code> , the descendants of the source element will be 
       * recursively imported and the resulting nodes reassembled to form the 
       * corresponding subtree. Otherwise, this simply generates an empty 
       * <code>DocumentFragment</code> .</dd>
       * <dt> NOTATION_NODE</dt>
       * <dd><code>Notation</code> 
       * nodes can be imported, however in the current release of the DOM the 
       * <code>DocumentType</code> is readonly. Ability to add these imported 
       * nodes to a <code>DocumentType</code> will be considered for addition 
       * to a future release of the DOM. On import, the <code>publicId</code> 
       * and <code>systemId</code> attributes are copied. Note that the 
       * <code>deep</code> parameter does not apply to <code>Notation</code> 
       * nodes since they never have any children.</dd>
       * </dl> 
       * @param importedNode  The node to import.
       * @param deep  If <code>true</code> , recursively import the subtree 
       *   under the specified node; if <code>false</code> , import only the 
       *   node itself, as explained above. This does not apply to 
       *   <code>Attr</code> , <code>EntityReference</code> , and 
       *   <code>Notation</code> nodes.
       * @return  The imported node that belongs to this <code>Document</code> .
       * @exception DOMException
       *    NOT_SUPPORTED_ERR: Raised if the type of node being imported is not 
       *   supported.
       * @since DOM Level 2
       */
      public Node importNode(Node importedNode, 
                             boolean deep)
                             throws DOMException;
  
      /**
       *  Creates an element of the given qualified name and namespace URI. 
       * HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the element to create.
       * @param qualifiedName  The  qualified name of the element type to 
       *   instantiate.
       * @return  A new <code>Element</code> object with the following 
       *   attributes: Attribute Value<code>Node.nodeName</code>
       *   <code>qualifiedName</code><code>Node.namespaceURI</code>
       *   <code>namespaceURI</code><code>Node.prefix</code> prefix, extracted 
       *   from <code>qualifiedName</code> , or <code>null</code> if there is no
       *    prefix<code>Node.localName</code> local name , extracted from 
       *   <code>qualifiedName</code><code>Element.tagName</code>
       *   <code>qualifiedName</code>
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified qualified name 
       *   contains an illegal character.
       *   <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is 
       *   malformed, if the <code>qualifiedName</code> has a prefix and the 
       *   <code>namespaceURI</code> is <code>null</code> or an empty string, 
       *   or if the <code>qualifiedName</code> has a prefix that is "xml" and 
       *   the <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/XML/1998/namespace"  .
       * @since DOM Level 2
       */
      public Element createElementNS(String namespaceURI, 
                                     String qualifiedName)
                                     throws DOMException;
  
      /**
       *  Creates an attribute of the given qualified name and namespace URI. 
       * HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the attribute to create.
       * @param qualifiedName  The  qualified name of the attribute to 
       *   instantiate.
       * @return  A new <code>Attr</code> object with the following attributes: 
       *   Attribute Value<code>Node.nodeName</code> qualifiedName
       *   <code>Node.namespaceURI</code><code>namespaceURI</code>
       *   <code>Node.prefix</code> prefix, extracted from 
       *   <code>qualifiedName</code> , or <code>null</code> if there is no 
       *   prefix<code>Node.localName</code> local name , extracted from 
       *   <code>qualifiedName</code><code>Attr.name</code>
       *   <code>qualifiedName</code>
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified qualified name 
       *   contains an illegal character.
       *   <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is 
       *   malformed, if the <code>qualifiedName</code> has a prefix and the 
       *   <code>namespaceURI</code> is <code>null</code> or an empty string, 
       *   if the <code>qualifiedName</code> has a prefix that is "xml" and the 
       *   <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/XML/1998/namespace", if the 
       *   <code>qualifiedName</code> has a prefix that is "xmlns" and the 
       *   <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/2000/xmlns/", or if the <code>qualifiedName</code>
       *    is "xmlns" and the <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/2000/xmlns/".
       * @since DOM Level 2
       */
      public Attr createAttributeNS(String namespaceURI, 
                                    String qualifiedName)
                                    throws DOMException;
  
      /**
       *  Returns a <code>NodeList</code> of all the <code>Elements</code> with 
       * a given  local name and namespace URI in the order in which they would 
       * be encountered in a preorder traversal of the <code>Document</code> 
       * tree.
       * @param namespaceURI  The  namespace URI of the elements to match on. 
       *   The special value "*" matches all namespaces.
       * @param localName  The  local name of the elements to match on. The 
       *   special value "*" matches all local names.
       * @return  A new <code>NodeList</code> object containing all the matched 
       *   <code>Elements</code> .
       * @since DOM Level 2
       */
      public NodeList getElementsByTagNameNS(String namespaceURI, 
                                             String localName);
  
      /**
       *  Returns the <code>Element</code> whose <code>ID</code> is given by 
       * <code>elementId</code> . If no such element exists, returns 
       * <code>null</code> . Behavior is not defined if more than one element 
       * has this <code>ID</code> .  The DOM implementation must have 
       * information that says which attributes are of type ID. Attributes with 
       * the name "ID" are not of type ID unless so defined. Implementations 
       * that do not know whether attributes are of type ID or not are expected 
       * to return <code>null</code> .
       * @param elementId  The unique <code>id</code> value for an element.
       * @return  The matching element.
       * @since DOM Level 2
       */
      public Element getElementById(String elementId);
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/DocumentFragment.java
  
  Index: DocumentFragment.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   * <code>DocumentFragment</code> is a "lightweight" or "minimal" 
   * <code>Document</code> object. It is very common to want to be able to 
   * extract a portion of a document's tree or to create a new fragment of a 
   * document. Imagine implementing a user command like cut or rearranging a 
   * document by moving fragments around. It is desirable to have an object 
   * which can hold such fragments and it is quite natural to use a Node for 
   * this purpose. While it is true that a <code>Document</code> object could 
   * fulfill this role, a <code>Document</code> object can potentially be a 
   * heavyweight object, depending on the underlying implementation. What is 
   * really needed for this is a very lightweight object. 
   * <code>DocumentFragment</code> is such an object.
   * <p> Furthermore, various operations -- such as inserting nodes as children 
   * of another <code>Node</code> -- may take <code>DocumentFragment</code> 
   * objects as arguments;  this results in all the child nodes of the 
   * <code>DocumentFragment</code> being moved to the child list of this node.
   * <p> The children of a <code>DocumentFragment</code> node are zero or more 
   * nodes representing the tops of any sub-trees defining the structure of the 
   * document. <code>DocumentFragment</code> nodes do not need to be 
   * well-formed XML documents (although they do need to follow the rules 
   * imposed upon well-formed XML parsed entities, which can have multiple top 
   * nodes). For example, a <code>DocumentFragment</code> might have only one 
   * child and that child node could be a <code>Text</code> node. Such a 
   * structure model represents neither an HTML document nor a well-formed XML 
   * document.
   * <p> When a <code>DocumentFragment</code> is inserted into a 
   * <code>Document</code> (or indeed any other <code>Node</code> that may take 
   * children) the children of the <code>DocumentFragment</code> and not the 
   * <code>DocumentFragment</code> itself are inserted into the 
   * <code>Node</code> . This makes the <code>DocumentFragment</code> very 
   * useful when the user wishes to create nodes that are siblings; the 
   * <code>DocumentFragment</code> acts as the parent of these nodes so that 
   * the user can use the standard methods from the <code>Node</code> 
   * interface, such as <code>insertBefore</code> and <code>appendChild</code> .
   */
  public interface DocumentFragment extends Node {
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/DocumentType.java
  
  Index: DocumentType.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  Each <code>Document</code> has a <code>doctype</code> attribute whose 
   * value is either <code>null</code> or a <code>DocumentType</code> object. 
   * The <code>DocumentType</code> interface in the DOM Core provides an 
   * interface to the list of entities that are defined for the document, and 
   * little else because the effect of namespaces and the various XML schema 
   * efforts on DTD representation are not clearly understood as of this 
   * writing.
   * <p> The DOM Level 2 doesn't support editing <code>DocumentType</code> nodes.
   */
  public interface DocumentType extends Node {
      /**
       *  The name of DTD; i.e., the name immediately following the 
       * <code>DOCTYPE</code> keyword.
       */
      public String getName();
  
      /**
       *  A <code>NamedNodeMap</code> containing the general entities, both 
       * external and internal, declared in the DTD. Parameter entities are not 
       *  contained. Duplicates are discarded. For example in:
       * <pre>
       * &lt;!DOCTYPE ex SYSTEM "ex.dtd" [
       *   &lt;!ENTITY foo "foo"&gt;
       *   &lt;!ENTITY bar "bar"&gt;
       *   &lt;!ENTITY bar "bar2"&gt;
       *   &lt;!ENTITY % baz "baz"&gt;
       * ]&gt;
       * &lt;ex/&gt;</pre>
       *   the interface 
       * provides access to <code>foo</code> and the first declaration of 
       * <code>bar</code> but not the second declaration of  <code>bar</code> 
       * or <code>baz</code> . Every node in this map also implements the 
       * <code>Entity</code> interface.
       * <br> The DOM Level 2 does not support editing entities, therefore 
       * <code>entities</code> cannot be altered in any way.
       */
      public NamedNodeMap getEntities();
  
      /**
       *  A <code>NamedNodeMap</code> containing  the notations declared in the 
       * DTD. Duplicates are discarded. Every node in this map also implements 
       * the <code>Notation</code> interface.
       * <br> The DOM Level 2 does not support editing notations, therefore 
       * <code>notations</code> cannot be altered in any way.
       */
      public NamedNodeMap getNotations();
  
      /**
       *  The public identifier of the external subset.
       * @since DOM Level 2
       */
      public String getPublicId();
  
      /**
       *  The system identifier of the external subset.
       * @since DOM Level 2
       */
      public String getSystemId();
  
      /**
       *  The internal subset as a string.
       * @since DOM Level 2
       */
      public String getInternalSubset();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Element.java
  
  Index: Element.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>Element</code> interface represents an element in an HTML or XML 
   * document. Elements may have attributes associated with them; since the 
   * <code>Element</code> interface inherits from <code>Node</code> , the 
   * generic <code>Node</code> interface attribute <code>attributes</code> may 
   * be used to retrieve the set of all attributes for an element. There are 
   * methods on the <code>Element</code> interface to retrieve either an 
   * <code>Attr</code> object by name or an attribute value by name. In XML, 
   * where an attribute value may contain entity references, an 
   * <code>Attr</code> object should be retrieved to examine the possibly 
   * fairly complex sub-tree representing the attribute value. On the other 
   * hand, in HTML, where all attributes have simple string values, methods to 
   * directly access an attribute value can safely be used as a convenience. In 
   * DOM Level 2, the method <code>normalize</code> is inherited from the 
   * <code>Node</code> interface where it was moved.
   */
  public interface Element extends Node {
      /**
       *  The name of the element. For example, in: 
       * <pre>
       * &lt;elementExample id="demo"&gt; 
       *         ... 
       * &lt;/elementExample&gt; ,</pre>
       *  <code>tagName</code> has 
       * the value <code>"elementExample"</code> . Note that this is 
       * case-preserving in XML, as are all of the operations of the DOM. The 
       * HTML DOM returns the <code>tagName</code> of an HTML element in the 
       * canonical uppercase form, regardless of the case in the  source HTML 
       * document. 
       */
      public String getTagName();
  
      /**
       *  Retrieves an attribute value by name.
       * @param name  The name of the attribute to retrieve.
       * @return  The <code>Attr</code> value as a string, or the empty string if
       *    that attribute does not have a specified or default value.
       */
      public String getAttribute(String name);
  
      /**
       *  Adds a new attribute. If an attribute with that name is already 
       * present in the element, its value is changed to be that of the value 
       * parameter. This value is a simple string; it is not parsed as it is 
       * being set. So any markup (such as syntax to be recognized as an entity 
       * reference) is treated as literal text, and needs to be appropriately 
       * escaped by the implementation when it is written out. In order to 
       * assign an attribute value that contains entity references, the user 
       * must create an <code>Attr</code> node plus any <code>Text</code> and 
       * <code>EntityReference</code> nodes, build the appropriate subtree, and 
       * use <code>setAttributeNode</code> to assign it as the value of an 
       * attribute.
       * <br> To set an attribute with a qualified name and namespace URI, use 
       * the <code>setAttributeNS</code> method.
       * @param name  The name of the attribute to create or alter.
       * @param value  Value to set in string form.
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified name contains an 
       *   illegal character.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public void setAttribute(String name, 
                               String value)
                               throws DOMException;
  
      /**
       *  Removes an attribute by name. If the removed attribute is known to 
       * have a default value, an attribute immediately appears containing the 
       * default value as well as the corresponding namespace URI, local name, 
       * and prefix when applicable.
       * <br> To remove an attribute by local name and namespace URI, use the 
       * <code>removeAttributeNS</code> method.
       * @param name  The name of the attribute to remove.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public void removeAttribute(String name)
                                  throws DOMException;
  
      /**
       *  Retrieves an attribute node by name.
       * <br> To retrieve an attribute node by qualified name and namespace URI, 
       * use the <code>getAttributeNodeNS</code> method.
       * @param name  The name (<code>nodeName</code> ) of the attribute to 
       *   retrieve.
       * @return  The <code>Attr</code> node with the specified name (
       *   <code>nodeName</code> ) or <code>null</code> if there is no such 
       *   attribute.
       */
      public Attr getAttributeNode(String name);
  
      /**
       *  Adds a new attribute node. If an attribute with that name (
       * <code>nodeName</code> ) is already present in the element, it is 
       * replaced by the new one.
       * <br> To add a new attribute node with a qualified name and namespace 
       * URI, use the <code>setAttributeNodeNS</code> method.
       * @param newAttr  The <code>Attr</code> node to add to the attribute list.
       * @return  If the <code>newAttr</code> attribute replaces an existing 
       *   attribute, the replaced <code>Attr</code> node is returned, 
       *   otherwise <code>null</code> is returned.
       * @exception DOMException
       *    WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from 
       *   a different document than the one that created the element.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       *   <br> INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already 
       *   an attribute of another <code>Element</code> object. The DOM user 
       *   must explicitly clone <code>Attr</code> nodes to re-use them in 
       *   other elements.
       */
      public Attr setAttributeNode(Attr newAttr)
                                   throws DOMException;
  
      /**
       *  Removes the specified attribute node. If the removed <code>Attr</code> 
       * has a default value it is immediately replaced. The replacing 
       * attribute has the same namespace URI and local name, as well as the 
       * original prefix, when applicable.
       * @param oldAttr  The <code>Attr</code> node to remove from the attribute 
       *   list.
       * @return  The <code>Attr</code> node that was removed.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       *   <br> NOT_FOUND_ERR: Raised if <code>oldAttr</code> is not an 
       *   attribute of the element.
       */
      public Attr removeAttributeNode(Attr oldAttr)
                                      throws DOMException;
  
      /**
       *  Returns a <code>NodeList</code> of all descendant elements with a 
       * given tag name, in the order in which they would be encountered in a 
       * preorder traversal of the <code>Element</code> tree.
       * @param name  The name of the tag to match on. The special value "*" 
       *   matches all tags.
       * @return  A list of matching <code>Element</code> nodes.
       */
      public NodeList getElementsByTagName(String name);
  
      /**
       *  Retrieves an attribute value by local name and namespace URI. 
       * HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the attribute to retrieve.
       * @param localName  The  local name of the attribute to retrieve.
       * @return  The <code>Attr</code> value as a string, or an 
       *   <code>null</code> if that attribute does not have a specified or 
       *   default value.  This is different from <code>getAttribute</code> 
       *   which never return <code>null</code> . 
       * @since DOM Level 2
       */
      public String getAttributeNS(String namespaceURI, 
                                   String localName);
  
      /**
       *  Adds a new attribute. If an attribute with the same local name and 
       * namespace URI is already present on the element, its prefix is changed 
       * to be the prefix part of the <code>qualifiedName</code> , and its 
       * value is changed to be the <code>value</code> parameter. This value is 
       * a simple string; it is not parsed as it is being set. So any markup 
       * (such as syntax to be recognized as an entity reference) is treated as 
       * literal text, and needs to be appropriately escaped by the 
       * implementation when it is written out. In order to assign an attribute 
       * value that contains entity references, the user must create an 
       * <code>Attr</code> node plus any <code>Text</code> and 
       * <code>EntityReference</code> nodes, build the appropriate subtree, and 
       * use <code>setAttributeNodeNS</code> or <code>setAttributeNode</code> to
       *  assign it as the value of an attribute.
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the attribute to create or 
       *   alter.
       * @param qualifiedName  The  qualified name of the attribute to create or 
       *   alter.
       * @param value  The value to set in string form.
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified qualified name 
       *   contains an illegal character.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       *   <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is 
       *   malformed, if the <code>qualifiedName</code> has a prefix and the 
       *   <code>namespaceURI</code> is <code>null</code> or an empty string, 
       *   if the <code>qualifiedName</code> has a prefix that is "xml" and the 
       *   <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/XML/1998/namespace", if the 
       *   <code>qualifiedName</code> has a prefix that is "xmlns" and the 
       *   <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/2000/xmlns/", or if the <code>qualifiedName</code>
       *    is "xmlns" and the <code>namespaceURI</code> is different from 
       *   "http://www.w3.org/2000/xmlns/".
       * @since DOM Level 2
       */
      public void setAttributeNS(String namespaceURI, 
                                 String qualifiedName, 
                                 String value)
                                 throws DOMException;
  
      /**
       *  Removes an attribute by local name and namespace URI. If the removed 
       * attribute has a default value it is immediately replaced. The 
       * replacing attribute has the same namespace URI and local name, as well 
       * as the original prefix.
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the attribute to remove.
       * @param localName  The  local name of the attribute to remove.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       * @since DOM Level 2
       */
      public void removeAttributeNS(String namespaceURI, 
                                    String localName)
                                    throws DOMException;
  
      /**
       *  Retrieves an <code>Attr</code> node by local name and namespace URI. 
       * HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the attribute to retrieve.
       * @param localName  The  local name of the attribute to retrieve.
       * @return  The <code>Attr</code> node with the specified attribute local 
       *   name and namespace URI or <code>null</code> if there is no such 
       *   attribute.
       * @since DOM Level 2
       */
      public Attr getAttributeNodeNS(String namespaceURI, 
                                     String localName);
  
      /**
       *  Adds a new attribute. If an attribute with that local name and that 
       * namespace URI is already present in the element, it is replaced by the 
       * new one.
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param newAttr  The <code>Attr</code> node to add to the attribute list.
       * @return  If the <code>newAttr</code> attribute replaces an existing 
       *   attribute with the same  local name and  namespace URI , the 
       *   replaced <code>Attr</code> node is returned, otherwise 
       *   <code>null</code> is returned.
       * @exception DOMException
       *    WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from 
       *   a different document than the one that created the element.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       *   <br> INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already 
       *   an attribute of another <code>Element</code> object. The DOM user 
       *   must explicitly clone <code>Attr</code> nodes to re-use them in 
       *   other elements.
       * @since DOM Level 2
       */
      public Attr setAttributeNodeNS(Attr newAttr)
                                     throws DOMException;
  
      /**
       *  Returns a <code>NodeList</code> of all the <code>Elements</code> with 
       * a given local name and namespace URI in the order in which they would 
       * be encountered in a preorder traversal of the <code>Document</code> 
       * tree, starting from this node.
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the elements to match on. 
       *   The special value "*" matches all namespaces.
       * @param localName  The  local name of the elements to match on. The 
       *   special value "*" matches all local names.
       * @return  A new <code>NodeList</code> object containing all the matched 
       *   <code>Elements</code> .
       * @since DOM Level 2
       */
      public NodeList getElementsByTagNameNS(String namespaceURI, 
                                             String localName);
  
      /**
       *  Returns <code>true</code> when an attribute with a given name is 
       * specified on this element or has a default value, <code>false</code> 
       * otherwise.
       * @param name  The name of the attribute to look for.
       * @return <code>true</code> if an attribute with the given name is 
       *   specified on this element or has a default value, <code>false</code> 
       *   otherwise.
       * @since DOM Level 2
       */
      public boolean hasAttribute(String name);
  
      /**
       *  Returns <code>true</code> when an attribute with a given local name 
       * and namespace URI is specified on this element or has a default value, 
       * <code>false</code> otherwise. HTML-only DOM implementations do not 
       * need to implement this method.
       * @param namespaceURI  The  namespace URI of the attribute to look for.
       * @param localName  The  local name of the attribute to look for.
       * @return <code>true</code> if an attribute with the given local name and 
       *   namespace URI is specified or has a default value on this element, 
       *   <code>false</code> otherwise.
       * @since DOM Level 2
       */
      public boolean hasAttributeNS(String namespaceURI, 
                                    String localName);
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Entity.java
  
  Index: Entity.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  This interface represents an entity, either parsed or unparsed, in an XML 
   * document. Note that this models the entity itself  not the entity 
   * declaration. <code>Entity</code> declaration modeling has been left for a 
   * later Level of the DOM specification.
   * <p> The <code>nodeName</code> attribute that is inherited from 
   * <code>Node</code> contains the name of the entity.
   * <p> An XML processor may choose to completely expand entities before  the 
   * structure model is passed to the DOM; in this case there will be no 
   * <code>EntityReference</code> nodes in the document tree.
   * <p> XML does not mandate that a non-validating XML processor read and 
   * process entity declarations made in the external subset or declared in 
   * external parameter entities. This means that parsed entities declared in 
   * the external subset need not be expanded by some classes of applications, 
   * and that the replacement value of the entity may not be available. When the
   *  replacement value is available, the corresponding  <code>Entity</code> 
   * node's child list represents the structure of that replacement text. 
   * Otherwise, the child list is empty.
   * <p> The DOM Level 2 does not support editing <code>Entity</code> nodes; if 
   * a user wants to make changes to the contents of an <code>Entity</code> , 
   * every related <code>EntityReference</code> node has to be replaced in the 
   * structure model by a clone of the <code>Entity</code> 's contents, and 
   * then the desired changes must be made to each of those clones instead. All 
   * the descendants of an <code>Entity</code> node are readonly.
   * <p> An <code>Entity</code> node does not have any parent. If the entity 
   * contains an unbound  namespace prefix , the <code>namespaceURI</code> of 
   * the corresponding node in the <code>Entity</code> node subtree is 
   * <code>null</code> . The same is true for <code>EntityReference</code> 
   * nodes that refer to this entity, when they are created using the 
   * <code>createEntityReference</code> method of the <code>Document</code> 
   * interface. The DOM Level 2 does not support any mechanism to resolve 
   * namespace prefixes.
   */
  public interface Entity extends Node {
      /**
       *  The public identifier associated with the entity, if specified. If the 
       * public identifier was not specified, this is <code>null</code> .
       */
      public String getPublicId();
  
      /**
       *  The system identifier associated with the entity, if specified. If the 
       * system identifier was not specified, this is <code>null</code> .
       */
      public String getSystemId();
  
      /**
       *  For unparsed entities, the name of the notation for the entity. For 
       * parsed entities, this is <code>null</code> . 
       */
      public String getNotationName();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/EntityReference.java
  
  Index: EntityReference.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   * <code>EntityReference</code> objects may be inserted into the structure 
   * model when an entity reference is in the source document, or when the user 
   * wishes to insert an entity reference. Note that character references and 
   * references to predefined entities are considered to be expanded by the 
   * HTML or XML processor so that characters are represented by their Unicode 
   * equivalent rather than by an entity reference. Moreover, the XML processor 
   * may completely expand references to entities while building the structure 
   * model, instead of providing <code>EntityReference</code> objects. If it 
   * does provide such objects, then for a given <code>EntityReference</code> 
   * node, it may be that there is no <code>Entity</code> node representing the 
   * referenced entity. If such an <code>Entity</code> exists, then the child 
   * list of the <code>EntityReference</code> node is in general the same as 
   * that of the <code>Entity</code> node. They may differ when an entity 
   * contains an unbound  namespace prefix . In such a case, because the 
   * namespace prefix resolution depends on where the entity reference is, the 
   * descendants of the <code>EntityReference</code> node may be bound to 
   * different  namespace URIs .
   * <p> As with the <code>Entity</code> node, all descendants of the 
   * <code>EntityReference</code> are readonly.
   */
  public interface EntityReference extends Node {
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/NamedNodeMap.java
  
  Index: NamedNodeMap.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  Objects implementing the <code>NamedNodeMap</code> interface are used to 
   * represent collections of nodes that can be accessed by name. Note that 
   * <code>NamedNodeMap</code> does not inherit from <code>NodeList</code> ; 
   * <code>NamedNodeMaps</code> are not maintained in any particular order. 
   * Objects contained in an object implementing <code>NamedNodeMap</code> may 
   * also be accessed by an ordinal index, but this is simply to allow 
   * convenient enumeration of the contents of a <code>NamedNodeMap</code> , 
   * and does not imply that the DOM specifies an order to these Nodes. 
   */
  public interface NamedNodeMap {
      /**
       *  Retrieves a node specified by name.
       * @param name  The <code>nodeName</code> of a node to retrieve.
       * @return  A <code>Node</code> (of any type) with the specified 
       *   <code>nodeName</code> , or <code>null</code> if it does not identify 
       *   any node in this map.
       */
      public Node getNamedItem(String name);
  
      /**
       *  Adds a node using its <code>nodeName</code> attribute. If a node with 
       * that name is already present in this map, it is replaced by the new 
       * one.
       * <br> As the <code>nodeName</code> attribute is used to derive the name 
       * which the node must be stored under, multiple nodes of certain types 
       * (those that have a "special" string value) cannot be stored as the 
       * names would clash. This is seen as preferable to allowing nodes to be 
       * aliased.
       * @param arg  A node to store in this map. The node will later be 
       *   accessible using the value of its <code>nodeName</code> attribute.
       * @return  If the new <code>Node</code> replaces an existing node the 
       *   replaced <code>Node</code> is returned, otherwise <code>null</code> 
       *   is returned.
       * @exception DOMException
       *    WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a 
       *   different document than the one that created this map.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
       *   <br> INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an 
       *   <code>Attr</code> that is already an attribute of another 
       *   <code>Element</code> object. The DOM user must explicitly clone 
       *   <code>Attr</code> nodes to re-use them in other elements.
       */
      public Node setNamedItem(Node arg)
                               throws DOMException;
  
      /**
       *  Removes a node specified by name. A removed attribute may be known to 
       * have a default value when this map contains the attributes attached to 
       * an element, as returned by the attributes attribute of the 
       * <code>Node</code> interface. If so, an attribute immediately appears 
       * containing the default value as well as the corresponding namespace 
       * URI, local name, and prefix when applicable.
       * @param name  The <code>nodeName</code> of the node to remove.
       * @return  The node removed from this map if a node with such a name 
       *   exists.
       * @exception DOMException
       *    NOT_FOUND_ERR: Raised if there is no node named <code>name</code> 
       *   in this map.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
       */
      public Node removeNamedItem(String name)
                                  throws DOMException;
  
      /**
       *  Returns the <code>index</code> th item in the map. If 
       * <code>index</code> is greater than or equal to the number of nodes in 
       * this map, this returns <code>null</code> .
       * @param index  Index into this map.
       * @return  The node at the <code>index</code> th position in the map, or 
       *   <code>null</code> if that is not a valid index.
       */
      public Node item(int index);
  
      /**
       *  The number of nodes in this map. The range of valid child node indices 
       * is <code>0</code> to <code>length-1</code> inclusive. 
       */
      public int getLength();
  
      /**
       *  Retrieves a node specified by local name and namespace URI. HTML-only 
       * DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the node to retrieve.
       * @param localName  The  local name of the node to retrieve.
       * @return  A <code>Node</code> (of any type) with the specified local 
       *   name and namespace URI, or <code>null</code> if they do not identify 
       *   any node in this map.
       * @since DOM Level 2
       */
      public Node getNamedItemNS(String namespaceURI, 
                                 String localName);
  
      /**
       *  Adds a node using its <code>namespaceURI</code> and 
       * <code>localName</code> . If a node with that namespace URI and that 
       * local name is already present in this map, it is replaced by the new 
       * one.
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param arg  A node to store in this map. The node will later be 
       *   accessible using the value of its <code>namespaceURI</code> and 
       *   <code>localName</code> attributes.
       * @return  If the new <code>Node</code> replaces an existing node the 
       *   replaced <code>Node</code> is returned, otherwise <code>null</code> 
       *   is returned.
       * @exception DOMException
       *    WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a 
       *   different document than the one that created this map.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
       *   <br> INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an 
       *   <code>Attr</code> that is already an attribute of another 
       *   <code>Element</code> object. The DOM user must explicitly clone 
       *   <code>Attr</code> nodes to re-use them in other elements.
       * @since DOM Level 2
       */
      public Node setNamedItemNS(Node arg)
                                 throws DOMException;
  
      /**
       *  Removes a node specified by local name and namespace URI. A removed 
       * attribute may be known to have a default value when this map contains 
       * the attributes attached to an element, as returned by the attributes 
       * attribute of the <code>Node</code> interface. If so, an attribute 
       * immediately appears containing the default value as well as the 
       * corresponding namespace URI, local name, and prefix when applicable.
       * <br> HTML-only DOM implementations do not need to implement this method.
       * @param namespaceURI  The  namespace URI of the node to remove.
       * @param localName  The  local name of the node to remove.
       * @return  The node removed from this map if a node with such a local 
       *   name and namespace URI exists.
       * @exception DOMException
       *    NOT_FOUND_ERR: Raised if there is no node with the specified 
       *   <code>namespaceURI</code> and <code>localName</code> in this map.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
       * @since DOM Level 2
       */
      public Node removeNamedItemNS(String namespaceURI, 
                                    String localName)
                                    throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Node.java
  
  Index: Node.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>Node</code> interface is the primary datatype for the entire 
   * Document Object Model. It represents a single node in the document tree. 
   * While all objects implementing the <code>Node</code> interface expose 
   * methods for dealing with children, not all objects implementing the 
   * <code>Node</code> interface may have children. For example, 
   * <code>Text</code> nodes may not have children, and adding children to such 
   * nodes results in a <code>DOMException</code> being raised.
   * <p> The attributes <code>nodeName</code> , <code>nodeValue</code> and 
   * <code>attributes</code> are included as a mechanism to get at node 
   * information without casting down to the specific derived interface. In 
   * cases where there is no obvious mapping of these attributes for a specific 
   * <code>nodeType</code> (e.g., <code>nodeValue</code> for an 
   * <code>Element</code> or <code>attributes</code> for a <code>Comment</code> 
   * ), this returns <code>null</code> . Note that the specialized interfaces 
   * may contain additional and more convenient mechanisms to get and set the 
   * relevant information.
   */
  public interface Node {
      // NodeType
      public static final short ELEMENT_NODE              = 1;
      public static final short ATTRIBUTE_NODE            = 2;
      public static final short TEXT_NODE                 = 3;
      public static final short CDATA_SECTION_NODE        = 4;
      public static final short ENTITY_REFERENCE_NODE     = 5;
      public static final short ENTITY_NODE               = 6;
      public static final short PROCESSING_INSTRUCTION_NODE = 7;
      public static final short COMMENT_NODE              = 8;
      public static final short DOCUMENT_NODE             = 9;
      public static final short DOCUMENT_TYPE_NODE        = 10;
      public static final short DOCUMENT_FRAGMENT_NODE    = 11;
      public static final short NOTATION_NODE             = 12;
  
      /**
       *  The name of this node, depending on its type; see the table above. 
       */
      public String getNodeName();
  
      /**
       *  The value of this node, depending on its type; see the table above. 
       * When it is defined to be <code>null</code> , setting it has no effect.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
       * @exception DOMException
       *    DOMSTRING_SIZE_ERR: Raised when it would return more characters 
       *   than fit in a <code>DOMString</code> variable on the implementation 
       *   platform.
       */
      public String getNodeValue()
                                    throws DOMException;
      public void setNodeValue(String nodeValue)
                                    throws DOMException;
  
      /**
       *  A code representing the type of the underlying object, as defined 
       * above.
       */
      public short getNodeType();
  
      /**
       *  The parent of this node. All nodes, except <code>Attr</code> , 
       * <code>Document</code> , <code>DocumentFragment</code> , 
       * <code>Entity</code> , and <code>Notation</code> may have a parent. 
       * However, if a	node has just been created and not yet added to the 
       * tree, or if it has been removed from the tree, this is 
       * <code>null</code> .
       */
      public Node getParentNode();
  
      /**
       *  A <code>NodeList</code> that contains all children of this node. If 
       * there are no children, this is a <code>NodeList</code> containing no 
       * nodes. The content of the returned <code>NodeList</code> is "live" in 
       * the sense that, for instance, changes to the children of the node 
       * object that it	was created from are immediately reflected in the nodes 
       * returned by the <code>NodeList</code> accessors; it is not a static 
       * snapshot of the content of the node. This is true for every 
       * <code>NodeList</code> , including the ones returned by the 
       * <code>getElementsByTagName</code> method.
       */
      public NodeList getChildNodes();
  
      /**
       *  The first child of this node. If there is no such node, this returns 
       * <code>null</code> .
       */
      public Node getFirstChild();
  
      /**
       *  The last child of this node. If there is no such node, this returns 
       * <code>null</code> .
       */
      public Node getLastChild();
  
      /**
       *  The node immediately preceding this node. If there is no such node, 
       * this returns <code>null</code> .
       */
      public Node getPreviousSibling();
  
      /**
       *  The node immediately following this node. If there is no such node, 
       * this returns <code>null</code> .
       */
      public Node getNextSibling();
  
      /**
       *  A <code>NamedNodeMap</code> containing the attributes of this node (if 
       * it is an <code>Element</code> ) or <code>null</code> otherwise. 
       */
      public NamedNodeMap getAttributes();
  
      /**
       *  The <code>Document</code> object associated with this node. This is 
       * also the <code>Document</code> object used to create new nodes. When 
       * this node is a <code>Document</code> or a <code>DocumentType</code> 
       * which is not used with any <code>Document</code> yet, this is 
       * <code>null</code> .
       * @version DOM Level 2
       */
      public Document getOwnerDocument();
  
      /**
       *  Inserts the node <code>newChild</code> before the existing child node 
       * <code>refChild</code> . If <code>refChild</code> is <code>null</code> 
       * , insert <code>newChild</code> at the end of the list of children.
       * <br> If <code>newChild</code> is a <code>DocumentFragment</code> 
       * object, all of its children are inserted, in the same order, before 
       * <code>refChild</code> . If the <code>newChild</code> is already in the 
       * tree, it is first removed.
       * @param newChild  The node to insert.
       * @param refChild  The reference node, i.e., the node before which the 
       *   new node must be inserted.
       * @return  The node being inserted.
       * @exception DOMException
       *    HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does 
       *   not allow children of the type of the <code>newChild</code> node, or 
       *   if the node to insert is one of this node's ancestors.
       *   <br> WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 
       *   from a different document than the one that created this node.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node 
       *   being inserted is readonly.
       *   <br> NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child 
       *   of this node.
       */
      public Node insertBefore(Node newChild, 
                               Node refChild)
                               throws DOMException;
  
      /**
       *  Replaces the child node <code>oldChild</code> with 
       * <code>newChild</code> in the list of children, and returns the 
       * <code>oldChild</code> node.
       * <br> If <code>newChild</code> is a <code>DocumentFragment</code> object,
       *  <code>oldChild</code> is replaced by all of the 
       * <code>DocumentFragment</code> children, which are inserted in the same 
       * order. If the <code>newChild</code> is already in the tree, it is 
       * first removed.
       * @param newChild  The new node to put in the child list.
       * @param oldChild  The node being replaced in the list.
       * @return  The node replaced.
       * @exception DOMException
       *    HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does 
       *   not allow children of the type of the <code>newChild</code> node, or 
       *   if the node to put in is one of this node's ancestors.
       *   <br> WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 
       *   from a different document than the one that created this node.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the new 
       *   node is readonly.
       *   <br> NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child 
       *   of this node.
       */
      public Node replaceChild(Node newChild, 
                               Node oldChild)
                               throws DOMException;
  
      /**
       *  Removes the child node indicated by <code>oldChild</code> from the 
       * list of children, and returns it.
       * @param oldChild  The node being removed.
       * @return  The node removed.
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       *   <br> NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child 
       *   of this node.
       */
      public Node removeChild(Node oldChild)
                              throws DOMException;
  
      /**
       *  Adds the node <code>newChild</code> to the end of the list of children 
       * of this node. If the <code>newChild</code> is already in the tree, it 
       * is first removed.
       * @param newChild  The node to add. If it is a  
       *   <code>DocumentFragment</code> object, the entire contents of the 
       *   document fragment are moved into the child list of this node
       * @return  The node added.
       * @exception DOMException
       *    HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does 
       *   not allow children of the type of the <code>newChild</code> node, or 
       *   if the node to append is one of this node's ancestors.
       *   <br> WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 
       *   from a different document than the one that created this node.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node 
       *   being appended is readonly.
       */
      public Node appendChild(Node newChild)
                              throws DOMException;
  
      /**
       *  This is a convenience method to allow easy determination of whether a 
       * node has any children.
       * @return  <code>true</code> if the node has any children, 
       *   <code>false</code> if the node has no children.
       */
      public boolean hasChildNodes();
  
      /**
       *  Returns a duplicate of this node, i.e., serves as a generic copy 
       * constructor for nodes. The duplicate node has no parent; (
       * <code>parentNode</code> returns <code>null</code> .).
       * <br> Cloning an <code>Element</code> copies all attributes and their 
       * values, including those generated by the XML processor to represent 
       * defaulted attributes, but this method does not copy any text it 
       * contains unless it is a deep clone, since the text is contained in a 
       * child <code>Text</code> node. Cloning any other type of node simply 
       * returns a copy of this node.
       * <br> Note that cloning an immutable subtree results in a mutable copy, 
       * but the children of an <code>EntityReference</code> clone are readonly.
       * @param deep  If <code>true</code> , recursively clone the subtree under 
       *   the specified node; if <code>false</code> , clone only the node 
       *   itself (and its attributes, if it is an <code>Element</code> ).  
       * @return  The duplicate node.
       */
      public Node cloneNode(boolean deep);
  
      /**
       *  Puts all <code>Text</code> nodes in the full depth of the sub-tree 
       * underneath this <code>Node</code> , including attribute nodes, into a 
       * "normal" form where only markup (e.g., tags, comments, processing 
       * instructions, CDATA sections, and entity references) separates 
       * <code>Text</code> nodes, i.e., there are neither adjacent 
       * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can be 
       * used to ensure that the DOM view  of a document is the same as if it 
       * were saved and re-loaded, and is useful when operations (such as 
       * XPointer lookups) that depend on a particular document tree structure 
       * are to be used. In cases where the document contains 
       * <code>CDATASections</code> , the normalize operation alone may not be 
       * sufficient, since XPointers do not differentiate between 
       * <code>Text</code> nodes and <code>CDATASection</code> nodes.
       * @since DOM Level 2
       */
      public void normalize();
  
      /**
       *  Tests whether the DOM implementation implements a specific feature and 
       * that feature is supported by this node.
       * @param feature  The name of the feature to test. This is the same name 
       *   which can be passed to the method <code>hasFeature</code> on 
       *   <code>DOMImplementation</code> .
       * @param version  This is the version number of the feature to test. In 
       *   Level 2, version 1, this is the string "2.0". If the version is not 
       *   specified, supporting any version of the feature will cause the 
       *   method to return <code>true</code> .
       * @return  Returns <code>true</code> if the specified feature is supported
       *    on this node, <code>false</code> otherwise.
       * @since DOM Level 2
       */
      public boolean supports(String feature, 
                              String version);
  
      /**
       *  The  namespace URI of this node, or <code>null</code> if it is 
       * unspecified.
       * <br> This is not a computed value that is the result of a namespace 
       * lookup based on an examination of the namespace declarations in scope. 
       * It is merely the namespace URI given at creation time.
       * <br> For nodes of any type other than <code>ELEMENT_NODE</code> and 
       * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 
       * method, such as <code>createElement</code> from the 
       * <code>Document</code> interface, this is always <code>null</code> . 
       * Per the  Namespaces in XML Specification  an attribute does not 
       * inherit its namespace from the element it is attached to. If an 
       * attribute is not explicitly given a namespace, it simply has no 
       * namespace.
       * @since DOM Level 2
       */
      public String getNamespaceURI();
  
      /**
       *  The  namespace prefix of this node, or <code>null</code> if it is 
       * unspecified.
       * <br> Note that setting this attribute, when permitted, changes the 
       * <code>nodeName</code> attribute, which holds the  qualified name , as 
       * well as the <code>tagName</code> and <code>name</code> attributes of 
       * the <code>Element</code> and <code>Attr</code> interfaces, when 
       * applicable.
       * <br> Note also that changing the prefix of an attribute that is known to
       *  have a default value, does not make a new attribute with the default 
       * value and the original prefix appear, since the 
       * <code>namespaceURI</code> and <code>localName</code> do not change.
       * @exception DOMException
       *    INVALID_CHARACTER_ERR: Raised if the specified prefix contains an 
       *   illegal character.
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       *   <br> NAMESPACE_ERR: Raised if the specified <code>prefix</code> is 
       *   malformed, if the <code>namespaceURI</code> of this node is 
       *   <code>null</code> , if the specified prefix is "xml" and the 
       *   <code>namespaceURI</code> of this node is different from 
       *   "http://www.w3.org/XML/1998/namespace", if this node is an attribute 
       *   and the specified prefix is "xmlns" and the <code>namespaceURI</code>
       *    of this node is different from "http://www.w3.org/2000/xmlns/", or 
       *   if this node is an attribute and the <code>qualifiedName</code> of 
       *   this node is "xmlns"  .
       * @since DOM Level 2
       */
      public String getPrefix();
      public void setPrefix(String prefix)
                              throws DOMException;
  
      /**
       *  Returns the local part of the  qualified name of this node.
       * <br> For nodes created with a DOM Level 1 method, such as 
       * <code>createElement</code> from the <code>Document</code> interface, 
       * it is <code>null</code> .
       * @since DOM Level 2
       */
      public String getLocalName();
  
      /**
       *  Returns whether this node (if it is an element) has any attributes.
       * @return <code>true</code> if this node has any attributes, 
       *   <code>false</code> otherwise.
       * @since DOM Level 2
       */
      public boolean hasAttributes();
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/NodeList.java
  
  Index: NodeList.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>NodeList</code> interface provides the abstraction of an ordered 
   * collection of nodes, without defining or constraining how this collection 
   * is implemented.
   * <p> The items in the <code>NodeList</code> are accessible via an integral 
   * index, starting from 0. 
   */
  public interface NodeList {
      /**
       *  Returns the <code>index</code> th item in the collection. If 
       * <code>index</code> is greater than or equal to the number of nodes in 
       * the list, this returns <code>null</code> .
       * @param index  Index into the collection.
       * @return  The node at the <code>index</code> th position in the 
       *   <code>NodeList</code> , or <code>null</code> if that is not a valid 
       *   index.
       */
      public Node item(int index);
  
      /**
       *  The number of nodes in the list. The range of valid child node indices 
       * is 0 to <code>length-1</code> inclusive. 
       */
      public int getLength();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Notation.java
  
  Index: Notation.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  This interface represents a notation declared in the DTD. A notation 
   * either declares, by name, the format of an unparsed entity (see section 4.7
   *  of the XML 1.0 specification), or is used for formal declaration of 
   * processing instruction targets (see section 2.6 of the XML 1.0 
   * specification). The <code>nodeName</code> attribute inherited from 
   * <code>Node</code> is set to the declared name of the notation.
   * <p> The DOM Level 1 does not support editing <code>Notation</code> nodes; 
   * they are therefore readonly.
   * <p> A <code>Notation</code> node does not have any parent.
   */
  public interface Notation extends Node {
      /**
       *  The public identifier of this notation. If the  public identifier was 
       * not specified, this is <code>null</code> .
       */
      public String getPublicId();
  
      /**
       *  The system identifier of this notation. If the  system identifier was 
       * not specified, this is <code>null</code> .
       */
      public String getSystemId();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/ProcessingInstruction.java
  
  Index: ProcessingInstruction.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>ProcessingInstruction</code> interface represents a  "processing 
   * instruction", used in XML as a way to keep processor-specific information 
   * in the text of the document.
   */
  public interface ProcessingInstruction extends Node {
      /**
       *  The target of this processing instruction. XML defines this as being 
       * the first token following the markup that begins the processing 
       * instruction.
       */
      public String getTarget();
  
      /**
       *  The content of this processing instruction. This is from the first non 
       * white space character after the target to the character immediately 
       * preceding the <code>?&gt;</code> .
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
       */
      public String getData();
      public void setData(String data)
                            throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/Text.java
  
  Index: Text.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom;
  
  /**
   *  The <code>Text</code> interface inherits from <code>CharacterData</code> 
   * and represents the textual content (termed  character  data in XML) of an 
   * <code>Element</code> or <code>Attr</code> .  If there is no markup inside 
   * an element's content, the text is contained in a single object 
   * implementing the <code>Text</code> interface that is the only child of the 
   * element. If there is markup, it is parsed into the  information items 
   * (elements,  comments, etc.) and <code>Text</code>  nodes that form the 
   * list of children of the element.
   * <p> When a document is first made available via the DOM, there is  only one 
   * <code>Text</code> node for each block of text. Users may create  adjacent 
   * <code>Text</code> nodes that represent the  contents of a given element 
   * without any intervening markup, but should be aware that there is no way 
   * to represent the separations between these nodes in XML or HTML, so they 
   * will not (in general) persist between DOM editing sessions. The 
   * <code>normalize()</code> method on <code>Element</code> merges any such 
   * adjacent <code>Text</code> objects into a single node for each block of 
   * text.
   */
  public interface Text extends CharacterData {
      /**
       *  Breaks this node into two  nodes at the specified <code>offset</code> 
       * , keeping both in the tree as siblings. This node then only contains 
       * all the content up to the <code>offset</code> point. A new node of the 
       * same type, which is inserted as the next sibling of this node, 
       * contains all the content at and after the <code>offset</code> point. 
       * When the <code>offset</code> is equal to the length of this node, the 
       * new node has no data.
       * @param offset  The  16-bit unit offset at which to split, starting from 
       *   <code>0</code> .
       * @return  The new node, of the same type as this node.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if the specified offset is negative or 
       *   greater than the number of 16-bit units in <code>data</code> .
       *   <br> NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
       */
      public Text splitText(int offset)
                            throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/range/DocumentRange.java
  
  Index: DocumentRange.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.range;
  
  /**
   * @since DOM Level 2
   */
  public interface DocumentRange {
      /**
       *  This interface can be obtained from the object implementing the 
       * <code>Document</code> interface using binding-specific casting methods.
       * @return  The initial state of the range returned from this  method is 
       *   such that both of its boundary-points are positioned at the 
       *   beginning  of the corresponding  Document, before any content. The 
       *   range returned can only be used to select content associated with 
       *   this Document, or with DocumentFragments and Attrs for which this 
       *   Document is the <code>ownerDocument</code> .
       */
      public Range createRange();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/range/Range.java
  
  Index: Range.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.range;
  
  import org.w3c.dom.DOMException;
  import org.w3c.dom.DocumentFragment;
  import org.w3c.dom.Node;
  
  /**
   * @since DOM Level 2
   */
  public interface Range {
      /**
       *  Node within which the range begins 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public Node getStartContainer()
                                         throws DOMException;
  
      /**
       *  Offset within the starting node of the range. 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public int getStartOffset()
                                         throws DOMException;
  
      /**
       *  Node within which the range ends 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public Node getEndContainer()
                                         throws DOMException;
  
      /**
       *  Offset within the ending node of the range. 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public int getEndOffset()
                                         throws DOMException;
  
      /**
       *  TRUE if the range is collapsed 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public boolean getCollapsed()
                                         throws DOMException;
  
      /**
       *  The deepest common  ancestor container of the range's two 
       * boundary-points.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public Node getCommonAncestorContainer()
                                         throws DOMException;
  
      /**
       *  Sets the attributes describing the start of the range. 
       * @param refNode  The <code>refNode</code> value. This parameter must be 
       *   different from <code>null</code> .
       * @param offset  The <code>startOffset</code> value. 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if<code>refNode</code> or an ancestor 
       *   of <code>refNode</code> is an Entity, Notation, or DocumentType node.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or 
       *   greater than the number of child units in <code>refNode</code> . 
       *   Child units are 16-bit units if <code>refNode</code> is a 
       *   CharacterData, Comment or ProcessingInstruction node. Child units 
       *   are Nodes in all other cases.
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       */
      public void setStart(Node refNode, 
                           int offset)
                           throws RangeException, DOMException;
  
      /**
       *  Sets the attributes describing the end of a range.
       * @param refNode  The <code>refNode</code> value. This parameter must be 
       *   different from <code>null</code> .
       * @param offset  The <code>endOffset</code> value. 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if<code>refNode</code> or an ancestor 
       *   of <code>refNode</code> is an Entity, Notation, or DocumentType node.
       * @exception DOMException
       *    INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or 
       *   greater than the number of child units in <code>refNode</code> . 
       *   Child units are 16-bit units if <code>refNode</code> is a 
       *   CharacterData, Comment or ProcessingInstruction node. Child units 
       *   are Nodes in all other cases.
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       */
      public void setEnd(Node refNode, 
                         int offset)
                         throws RangeException, DOMException;
  
      /**
       *  Sets the start position to be before a node
       * @param refNode  Range starts before <code>refNode</code> 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
       *    is an Entity, Notation, or DocumentType node or if 
       *   <code>refNode</code> is a Document, DocumentFragment, Attr, Entity, 
       *   or Notation node.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void setStartBefore(Node refNode)
                                 throws RangeException, DOMException;
  
      /**
       *  Sets the start position to be after a node
       * @param refNode  Range starts after <code>refNode</code> 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
       *    is an Entity, Notation, or DocumentType node or if 
       *   <code>refNode</code> is a Document, DocumentFragment, Attr, Entity, 
       *   or Notation node.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void setStartAfter(Node refNode)
                                throws RangeException, DOMException;
  
      /**
       *  Sets the end position to be before a node. 
       * @param refNode  Range ends before <code>refNode</code> 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
       *    is an Entity, Notation, or DocumentType node or if 
       *   <code>refNode</code> is a Document, DocumentFragment, Attr, Entity, 
       *   or Notation node.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void setEndBefore(Node refNode)
                               throws RangeException, DOMException;
  
      /**
       *  Sets the end of a range to be after a node 
       * @param refNode  Range ends after <code>refNode</code> . 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
       *    is an Entity, Notation or DocumentType node or if 
       *   <code>refNode</code> is a Document, DocumentFragment, Attr, Entity, 
       *   or Notation node.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void setEndAfter(Node refNode)
                              throws RangeException, DOMException;
  
      /**
       *  Collapse a range onto one of its boundary-points 
       * @param toStart  If TRUE, collapses the Range onto its start; if FALSE, 
       *   collapses it onto its end. 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void collapse(boolean toStart)
                           throws DOMException;
  
      /**
       *  Select a node and its contents 
       * @param refNode  The node to select. 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
       *    is an Entity, Notation or DocumentType node or if 
       *   <code>refNode</code> is a Document, DocumentFragment, Attr, Entity, 
       *   or Notation node.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void selectNode(Node refNode)
                             throws RangeException, DOMException;
  
      /**
       *  Select the contents within a node 
       * @param refNode  Node to select from 
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if<code>refNode</code> or an ancestor 
       *   of <code>refNode</code> is an Entity, Notation or DocumentType node.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void selectNodeContents(Node refNode)
                                     throws RangeException, DOMException;
  
      // CompareHow
      public static final short START_TO_START            = 0;
      public static final short START_TO_END              = 1;
      public static final short END_TO_END                = 2;
      public static final short END_TO_START              = 3;
  
      /**
       *  Compare the boundary-points of two ranges in a document.
       * @param how 
       * @param sourceRange 
       * @return  -1, 0 or 1 depending on whether the corresponding 
       *   boundary-point of the Range is before, equal to, or after the 
       *   corresponding boundary-point of <code>sourceRange</code> . 
       * @exception DOMException
       *    WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the same 
       *   document or document fragment.
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       */
      public short compareBoundaryPoints(short how, 
                                         Range sourceRange)
                                         throws DOMException;
  
      /**
       *  Removes the contents of a range from the containing document or 
       * document fragment without returning a reference to the removed 
       * content.  
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content 
       *   of the range is read-only or any of the nodes that contain any of the
       *    content of the range are read-only.
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       */
      public void deleteContents()
                                 throws DOMException;
  
      /**
       *  Moves the contents of a range from the containing document or document 
       * fragment to a new DocumentFragment. 
       * @return  A DocumentFragment containing the extracted contents. 
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content 
       *   of the range is read-only or any of the nodes which contain any of 
       *   the content of the range are read-only.
       *   <br> HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be 
       *   extracted into the new DocumentFragment.
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       */
      public DocumentFragment extractContents()
                                              throws DOMException;
  
      /**
       *  Duplicates the contents of a range 
       * @return  A DocumentFragment containing contents equivalent to those of 
       *   this range. 
       * @exception DOMException
       *    HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be 
       *   extracted into the new DocumentFragment.
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       */
      public DocumentFragment cloneContents()
                                            throws DOMException;
  
      /**
       *  Inserts a node into the document or document fragment at the start of 
       * the range. 
       * @param newNode  The node to insert at the start of the range 
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if an  ancestor container of 
       *   the start of the range is read-only.
       *   <br> WRONG_DOCUMENT_ERR: Raised if<code>newNode</code> and the  
       *   container of the start of the Range were not created from the same 
       *   document.
       *   <br> HIERARCHY_REQUEST_ERR: Raised if the  container of the start of 
       *   the Range is of a type that does not allow children of the type of 
       *   <code>newNode</code> or if <code>newNode</code> is an ancestor of the
       *    container .
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       * @exception RangeException
       *    INVALID_NODE_TYPE_ERR: Raised if<code>node</code> is an Attr, 
       *   Entity, Notation, DocumentFragment, or Document node.
       */
      public void insertNode(Node newNode)
                             throws DOMException, RangeException;
  
      /**
       *  Reparents the contents of the range to the given node and inserts the 
       * node at the position of the start of the range. 
       * @param newParent  The node to surround the contents with. 
       * @exception DOMException
       *    NO_MODIFICATION_ALLOWED_ERR: Raised if an  ancestor container of 
       *   either boundary-point of the range is read-only.
       *   <br> WRONG_DOCUMENT_ERR: Raised if<code>newParent</code> and the  
       *   container of the start of the Range were not created from the same 
       *   document.
       *   <br> HIERARCHY_REQUEST_ERR: Raised if the  container of the start of 
       *   the Range is of a type that does not allow children of the type of 
       *   <code>newParent</code> or if <code>newParent</code> is an ancestor 
       *   of the container or if <code>node</code> would end up with a child 
       *   node of a type not allowed by the type of <code>node</code> .
       *   <br> INVALID_STATE_ERR: Raised if <code>detach()</code> has already 
       *   been invoked on this object.
       * @exception RangeException
       *    BAD_BOUNDARYPOINTS_ERR: Raised if the range  partially selects a 
       *   non-text node.
       *   <br> INVALID_NODE_TYPE_ERR: Raised if<code>node</code> is an Attr, 
       *   Entity, DocumentType, Notation, Document, or DocumentFragment node.
       */
      public void surroundContents(Node newParent)
                                   throws DOMException, RangeException;
  
      /**
       *  Produces a new range whose boundary-points are equal to the 
       * boundary-points of the range. 
       * @return  The duplicated range. 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public Range cloneRange()
                              throws DOMException;
  
      /**
       *  Returns the contents of a range as a string. 
       * @return  The contents of the range.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public String toString()
                             throws DOMException;
  
      /**
       *  Called to indicate that the range is no  longer in use and that the 
       * implementation may relinquish any resources associated with this 
       * range. Subsequent calls to any methods or attribute getters on this 
       * range will result in a <code>DOMException</code> being thrown with an 
       * error code of  <code>INVALID_STATE_ERR</code> .
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if <code>detach()</code> has already been 
       *   invoked on this object.
       */
      public void detach()
                         throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/range/RangeException.java
  
  Index: RangeException.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.range;
  
  /**
   *  Range operations may throw a <code>RangeException</code> as specified in 
   * their method descriptions.
   */
  public class RangeException extends RuntimeException {
      public RangeException(short code, String message) {
         super(message);
         this.code = code;
      }
      public short   code;
      // RangeExceptionCode
      public static final short BAD_BOUNDARYPOINTS_ERR    = 1;
      public static final short INVALID_NODE_TYPE_ERR     = 2;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/traversal/DocumentTraversal.java
  
  Index: DocumentTraversal.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.traversal;
  
  import org.w3c.dom.DOMException;
  import org.w3c.dom.Node;
  
  /**
   * <code>DocumentTraversal</code> contains methods that create iterators and 
   * tree-walkers to traverse a node and its children in document order (depth 
   * first, pre-order traversal, which is equivalent to the order in which the 
   * start tags occur in the text representation of the document).
   * @since DOM Level 2
   */
  public interface DocumentTraversal {
      /**
       *  Create a new NodeIterator over the subtree rooted at the specified 
       * node.
       * @param root  The node which will be iterated together with its 
       *   children. The iterator is initially positioned just before this 
       *   node. The whatToShow flags and the filter, if any, are not 
       *   considered when setting this position.
       * @param whatToShow  This flag specifies which node types may appear in 
       *   the logical view of the tree presented by the iterator. See the 
       *   description of iterator for the set of possible values. These flags 
       *   can be combined using <code>OR</code> .
       * @param filter  The Filter to be used with this TreeWalker, or null to 
       *   indicate no filter.
       * @param entityReferenceExpansion  The value of this flag determines 
       *   whether entity reference nodes are expanded.
       * @return  The newly created <code>NodeIterator</code> .
       */
      public NodeIterator createNodeIterator(Node root, 
                                             int whatToShow, 
                                             NodeFilter filter, 
                                             boolean entityReferenceExpansion);
  
      /**
       *  Create a new TreeWalker over the subtree rooted at the specified node.
       * @param root  The node which will serve as the root for the 
       *   <code>TreeWalker</code> . The whatToShow flags and the NodeFilter 
       *   are not considered when setting this value; any node type will be 
       *   accepted as the root. The currentNode of the TreeWalker is 
       *   initialized to this node, whether or not it is visible. The root 
       *   functions as a stopping point for traversal methods that look upward 
       *   in the document structure, such as parentNode and nextNode. The root 
       *   must not be null.
       * @param whatToShow  This flag specifies which node types may appear in 
       *   the logical view of the tree presented by the iterator. See the 
       *   description of TreeWalker for the set of possible values. These 
       *   flags can be combined using <code>OR</code> .
       * @param filter  The Filter to be used with this TreeWalker, or null to 
       *   indicate no filter.
       * @param entityReferenceExpansion  The value of this flag determines 
       *   whether entity reference nodes are expanded.
       * @return  The newly created <code>TreeWalker</code> .
       * @exception DOMException
       *    Raises the exception NOT_SUPPORTED_ERR if the specified root node is
       *    null.
       */
      public TreeWalker createTreeWalker(Node root, 
                                         int whatToShow, 
                                         NodeFilter filter, 
                                         boolean entityReferenceExpansion)
                                         throws DOMException;
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/traversal/NodeFilter.java
  
  Index: NodeFilter.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.traversal;
  
  import org.w3c.dom.Node;
  
  /**
   *  Filters are objects that know how to "filter out" nodes. If a
   * <code>NodeIterator</code> or <code>TreeWalker</code> is given a filter, it 
   * applies the filter before it returns the next node. If the filter says to 
   * accept the node, the iterator returns it; otherwise, the iterator looks 
   * for the next node and pretends that the node that was rejected was not 
   * there.
   * <p> The DOM does not provide any filters. Filter is just an interface that 
   * users can implement to provide their own filters. 
   * <p> Filters do not need to know how to iterate, nor do they need to know 
   * anything about the data structure that is being iterated. This makes it 
   * very easy to write filters, since the only thing they have to know how to 
   * do is evaluate a single node. One filter may be used with a number of 
   * different kinds of iterators, encouraging code reuse. This is an 
   * ECMAScript function reference. This method returns a<code>short</code> . 
   * The parameter is of type <code>Node</code> . 
   * @since DOM Level 2
   */
  public interface NodeFilter {
      // Constants returned by acceptNode
      public static final short FILTER_ACCEPT             = 1;
      public static final short FILTER_REJECT             = 2;
      public static final short FILTER_SKIP               = 3;
  
      // Constants for whatToShow
      public static final int SHOW_ALL                  = 0xFFFFFFFF;
      public static final int SHOW_ELEMENT              = 0x00000001;
      public static final int SHOW_ATTRIBUTE            = 0x00000002;
      public static final int SHOW_TEXT                 = 0x00000004;
      public static final int SHOW_CDATA_SECTION        = 0x00000008;
      public static final int SHOW_ENTITY_REFERENCE     = 0x00000010;
      public static final int SHOW_ENTITY               = 0x00000020;
      public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
      public static final int SHOW_COMMENT              = 0x00000080;
      public static final int SHOW_DOCUMENT             = 0x00000100;
      public static final int SHOW_DOCUMENT_TYPE        = 0x00000200;
      public static final int SHOW_DOCUMENT_FRAGMENT    = 0x00000400;
      public static final int SHOW_NOTATION             = 0x00000800;
  
      /**
       *  Test whether a specified node is visible in the logical view of a 
       * TreeWalker or NodeIterator. This function will be called by the 
       * implementation of TreeWalker and NodeIterator; it is not intended to 
       * be called directly from user code.
       * @param n  The node to check to see if it passes the filter or not.
       * @return  a constant to determine whether the node is accepted, 
       *   rejected, or skipped, as defined  above .
       */
      public short acceptNode(Node n);
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/traversal/NodeIterator.java
  
  Index: NodeIterator.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.traversal;
  
  import org.w3c.dom.DOMException;
  import org.w3c.dom.Node;
  
  /**
   *  NodeIterators are used to step through a set of nodes, e.g. the set of 
   * nodes in a NodeList, the document subtree governed by a particular node, 
   * the results of a query, or any other set of nodes. The set of nodes to be 
   * iterated is determined by the implementation of the NodeIterator. DOM 
   * Level 2 specifies a single NodeIterator implementation for document-order 
   * traversal of a document subtree. Instances of these iterators are created 
   * by calling DocumentTraversal.createNodeIterator().
   * @since DOM Level 2
   */
  public interface NodeIterator {
      /**
       *  The root node of the Iterator, as specified when it was created.
       */
      public Node getRoot();
  
      /**
       *  This attribute determines which node types are presented via the 
       * iterator. The available set of constants is defined in the 
       * <code>NodeFilter</code> interface.
       */
      public int getWhatToShow();
  
      /**
       *  The filter used to screen nodes.
       */
      public NodeFilter getFilter();
  
      /**
       *  The value of this flag determines whether the children of entity 
       * reference nodes are visible to the iterator. If false, they will be 
       * skipped over.
       * <br> To produce a view of the document that has entity references 
       * expanded and does not expose the entity reference node itself, use the 
       * whatToShow flags to hide the entity reference node and set 
       * expandEntityReferences to true when creating the iterator. To produce 
       * a view of the document that has entity reference nodes but no entity 
       * expansion, use the whatToShow flags to show the entity reference node 
       * and set expandEntityReferences to false.
       */
      public boolean getExpandEntityReferences();
  
      /**
       *  Returns the next node in the set and advances the position of the 
       * iterator in the set. After a NodeIterator is created, the first call 
       * to nextNode() returns the first node in the set.
       * @return  The next <code>Node</code> in the set being iterated over, or
       *   <code>null</code> if there are no more members in that set.
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if this method is called after the
       *   <code>detach</code> method was invoked.
       */
      public Node nextNode()
                           throws DOMException;
  
      /**
       *  Returns the previous node in the set and moves the position of the 
       * iterator backwards in the set.
       * @return  The previous <code>Node</code> in the set being iterated over, 
       *   or<code>null</code> if there are no more members in that set. 
       * @exception DOMException
       *    INVALID_STATE_ERR: Raised if this method is called after the
       *   <code>detach</code> method was invoked.
       */
      public Node previousNode()
                               throws DOMException;
  
      /**
       *  Detaches the iterator from the set which it iterated over, releasing 
       * any computational resources and placing the iterator in the INVALID 
       * state. After<code>detach</code> has been invoked, calls to 
       * <code>nextNode</code> or<code>previousNode</code> will raise the 
       * exception INVALID_STATE_ERR.
       */
      public void detach();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/w3c/dom/traversal/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  /*
   * Copyright (c) 2000 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE. See W3C License http://www.w3.org/Consortium/Legal/ for more
   * details.
   */
  
  package org.w3c.dom.traversal;
  
  import org.w3c.dom.DOMException;
  import org.w3c.dom.Node;
  
  /**
   * <code>TreeWalker</code> objects are used to navigate a document tree or 
   * subtree using the view of the document defined by its 
   * <code>whatToShow</code> flags and any filters that are defined for the 
   * <code>TreeWalker</code> . Any function which performs navigation using a 
   * <code>TreeWalker</code> will automatically support any view defined by a 
   * <code>TreeWalker</code> .
   * <p> Omitting nodes from the logical view of a subtree can result in a 
   * structure that is substantially different from the same subtree in the 
   * complete, unfiltered document. Nodes that are siblings in the TreeWalker 
   * view may be children of different, widely separated nodes in the original 
   * view. For instance, consider a Filter that skips all nodes except for Text 
   * nodes and the root node of a document. In the logical view that results, 
   * all text nodes will be siblings and appear as direct children of the root 
   * node, no matter how deeply nested the structure of the original document.
   * @since DOM Level 2
   */
  public interface TreeWalker {
      /**
       *  The root node of the TreeWalker, as specified when it was created.
       */
      public Node getRoot();
  
      /**
       *  This attribute determines which node types are presented via the 
       * TreeWalker. These constants are defined in the <code>NodeFilter</code> 
       * interface.
       */
      public int getWhatToShow();
  
      /**
       *  The filter used to screen nodes.
       */
      public NodeFilter getFilter();
  
      /**
       *  The value of this flag determines whether the children of entity 
       * reference nodes are visible to the TreeWalker. If false, they will be 
       * skipped over.
       * <br> To produce a view of the document that has entity references 
       * expanded and does not expose the entity reference node itself, use the 
       * whatToShow flags to hide the entity reference node and set 
       * expandEntityReferences to true when creating the TreeWalker. To 
       * produce a view of the document that has entity reference nodes but no 
       * entity expansion, use the whatToShow flags to show the entity 
       * reference node and set expandEntityReferences to false.
       */
      public boolean getExpandEntityReferences();
  
      /**
       *  The node at which the TreeWalker is currently positioned.
       * <br> The value must not be null. Alterations to the DOM tree may cause 
       * the current node to no longer be accepted by the TreeWalker's 
       * associated filter. currentNode may also be explicitly set to any node, 
       * whether or not it is within the subtree specified by the root node or 
       * would be accepted by the filter and whatToShow flags. Further 
       * traversal occurs relative to currentNode even if it is not part of the 
       * current view by applying the filters in the requested direction (not 
       * changing currentNode where no traversal is possible). 
       * @exception DOMException
       *    NOT_SUPPORTED_ERR: Raised if the specified <code>currentNode</code> 
       *   is<code>null</code> .
       */
      public Node getCurrentNode();
      public void setCurrentNode(Node currentNode)
                              throws DOMException;
  
      /**
       *  Moves to and returns the closest visible ancestor node of the current 
       * node. If the search for parentNode attempts to step upward from the 
       * TreeWalker's root node, or if it fails to find a visible ancestor 
       * node, this method retains the current position and returns null.
       * @return  The new parent node, or null if the current node has no parent 
       *   in the TreeWalker's logical view.
       */
      public Node parentNode();
  
      /**
       *  Moves the <code>TreeWalker</code> to the first visible child of the 
       * current node, and returns the new node. If the current node has no 
       * visible children, returns <code>null</code> , and retains the current 
       * node.
       * @return  The new node, or <code>null</code> if the current node has no 
       *   visible children in the TreeWalker's logical view.
       */
      public Node firstChild();
  
      /**
       *  Moves the <code>TreeWalker</code> to the last visible child of the 
       * current node, and returns the new node. If the current node has no 
       * visible children, returns <code>null</code> , and retains the current 
       * node.
       * @return  The new node, or <code>null</code> if the current node has no 
       *   children  in the TreeWalker's logical view.
       */
      public Node lastChild();
  
      /**
       *  Moves the <code>TreeWalker</code> to the previous sibling of the 
       * current node, and returns the new node. If the current node has no 
       * visible previous sibling, returns <code>null</code> , and retains the 
       * current node.
       * @return  The new node, or <code>null</code> if the current node has no 
       *   previous sibling in the TreeWalker's logical view.
       */
      public Node previousSibling();
  
      /**
       *  Moves the <code>TreeWalker</code> to the next sibling of the current 
       * node, and returns the new node. If the current node has no visible 
       * next sibling, returns <code>null</code> , and retains the current node.
       * @return  The new node, or <code>null</code> if the current node has no 
       *   next sibling in the TreeWalker's logical view.
       */
      public Node nextSibling();
  
      /**
       *  Moves the <code>TreeWalker</code> to the previous visible node in 
       * document order relative to the current node, and returns the new node. 
       * If the current node has no previous node,  or if the search for 
       * previousNode attempts to step upward from the TreeWalker's root node, 
       * returns <code>null</code> , and retains the current node. 
       * @return  The new node, or <code>null</code> if the current node has no 
       *   previous node in the TreeWalker's logical view.
       */
      public Node previousNode();
  
      /**
       *  Moves the <code>TreeWalker</code> to the next visible node in document 
       * order relative to the current node, and returns the new node. If the 
       * current node has no next node,  or if the search for nextNode attempts 
       * to step upward from the TreeWalker's root node, returns 
       * <code>null</code> , and retains the current node.
       * @return  The new node, or <code>null</code> if the current node has no 
       *   next node  in the TreeWalker's logical view.
       */
      public Node nextNode();
  
  }
  
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/AttributeList.java
  
  Index: AttributeList.java
  ===================================================================
  // SAX Attribute List Interface.
  // No warranty; no copyright -- use this as you will.
  // $Id: AttributeList.java,v 1.1 2000/10/02 02:43:16 sboag Exp $
  
  package org.xml.sax;
  
  /**
   * Interface for an element's attribute specifications.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This is the original SAX1 interface for reporting an element's
   * attributes.  Unlike the new {@link org.xml.sax.Attributes Attributes}
   * interface, it does not support Namespace-related information.</p>
   *
   * <p>When an attribute list is supplied as part of a
   * {@link org.xml.sax.DocumentHandler#startElement startElement}
   * event, the list will return valid results only during the
   * scope of the event; once the event handler returns control
   * to the parser, the attribute list is invalid.  To save a
   * persistent copy of the attribute list, use the SAX1
   * {@link org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
   * helper class.</p>
   *
   * <p>An attribute list includes only attributes that have been
   * specified or defaulted: #IMPLIED attributes will not be included.</p>
   *
   * <p>There are two ways for the SAX application to obtain information
   * from the AttributeList.  First, it can iterate through the entire
   * list:</p>
   *
   * <pre>
   * public void startElement (String name, AttributeList atts) {
   *   for (int i = 0; i < atts.getLength(); i++) {
   *     String name = atts.getName(i);
   *     String type = atts.getType(i);
   *     String value = atts.getValue(i);
   *     [...]
   *   }
   * }
   * </pre>
   *
   * <p>(Note that the result of getLength() will be zero if there
   * are no attributes.)
   *
   * <p>As an alternative, the application can request the value or
   * type of specific attributes:</p>
   *
   * <pre>
   * public void startElement (String name, AttributeList atts) {
   *   String identifier = atts.getValue("id");
   *   String label = atts.getValue("label");
   *   [...]
   * }
   * </pre>
   *
   * @deprecated This interface has been replaced by the SAX2
   *             {@link org.xml.sax.Attributes Attributes}
   *             interface, which includes Namespace support.
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.DocumentHandler#startElement startElement
   * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
   */
  public interface AttributeList {
  
  
      ////////////////////////////////////////////////////////////////////
      // Iteration methods.
      ////////////////////////////////////////////////////////////////////
      
  
      /**
       * Return the number of attributes in this list.
       *
       * <p>The SAX parser may provide attributes in any
       * arbitrary order, regardless of the order in which they were
       * declared or specified.  The number of attributes may be
       * zero.</p>
       *
       * @return The number of attributes in the list.  
       */
      public abstract int getLength ();
      
      
      /**
       * Return the name of an attribute in this list (by position).
       *
       * <p>The names must be unique: the SAX parser shall not include the
       * same attribute twice.  Attributes without values (those declared
       * #IMPLIED without a value specified in the start tag) will be
       * omitted from the list.</p>
       *
       * <p>If the attribute name has a namespace prefix, the prefix
       * will still be attached.</p>
       *
       * @param i The index of the attribute in the list (starting at 0).
       * @return The name of the indexed attribute, or null
       *         if the index is out of range.
       * @see #getLength 
       */
      public abstract String getName (int i);
      
      
      /**
       * Return the type of an attribute in the list (by position).
       *
       * <p>The attribute type is one of the strings "CDATA", "ID",
       * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
       * or "NOTATION" (always in upper case).</p>
       *
       * <p>If the parser has not read a declaration for the attribute,
       * or if the parser does not report attribute types, then it must
       * return the value "CDATA" as stated in the XML 1.0 Recommentation
       * (clause 3.3.3, "Attribute-Value Normalization").</p>
       *
       * <p>For an enumerated attribute that is not a notation, the
       * parser will report the type as "NMTOKEN".</p>
       *
       * @param i The index of the attribute in the list (starting at 0).
       * @return The attribute type as a string, or
       *         null if the index is out of range.
       * @see #getLength 
       * @see #getType(java.lang.String)
       */
      public abstract String getType (int i);
      
      
      /**
       * Return the value of an attribute in the list (by position).
       *
       * <p>If the attribute value is a list of tokens (IDREFS,
       * ENTITIES, or NMTOKENS), the tokens will be concatenated
       * into a single string separated by whitespace.</p>
       *
       * @param i The index of the attribute in the list (starting at 0).
       * @return The attribute value as a string, or
       *         null if the index is out of range.
       * @see #getLength
       * @see #getValue(java.lang.String)
       */
      public abstract String getValue (int i);
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Lookup methods.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Return the type of an attribute in the list (by name).
       *
       * <p>The return value is the same as the return value for
       * getType(int).</p>
       *
       * <p>If the attribute name has a namespace prefix in the document,
       * the application must include the prefix here.</p>
       *
       * @param name The name of the attribute.
       * @return The attribute type as a string, or null if no
       *         such attribute exists.
       * @see #getType(int)
       */
      public abstract String getType (String name);
      
      
      /**
       * Return the value of an attribute in the list (by name).
       *
       * <p>The return value is the same as the return value for
       * getValue(int).</p>
       *
       * <p>If the attribute name has a namespace prefix in the document,
       * the application must include the prefix here.</p>
       *
       * @param i The index of the attribute in the list.
       * @return The attribute value as a string, or null if
       *         no such attribute exists.
       * @see #getValue(int)
       */
      public abstract String getValue (String name);
      
  }
  
  // end of AttributeList.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/Attributes.java
  
  Index: Attributes.java
  ===================================================================
  // Attributes.java - attribute list with Namespace support
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the public domain.
  
  // $Id: Attributes.java,v 1.1 2000/10/02 02:43:16 sboag Exp $
  
  
  package org.xml.sax;
  
  
  /**
   * Interface for a list of XML attributes.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This interface allows access to a list of attributes in
   * three different ways:</p>
   *
   * <ol>
   * <li>by attribute index;</li>
   * <li>by Namespace-qualified name; or</li>
   * <li>by qualified (prefixed) name.</li>
   * </ol>
   *
   * <p>The list will not contain attributes that were declared
   * #IMPLIED but not specified in the start tag.  It will also not
   * contain attributes used as Namespace declarations (xmlns*) unless
   * the <code>http://xml.org/sax/features/namespace-prefixes</code> 
   * feature is set to <var>true</var> (it is <var>false</var> by 
   * default).</p>
   *
   * <p>If the namespace-prefixes feature (see above) is <var>false</var>, 
   * access by qualified name may not be available; if the 
   * <code>http://xml.org/sax/features/namespaces</code>
   * feature is <var>false</var>, access by Namespace-qualified names 
   * may not be available.</p>
   *
   * <p>This interface replaces the now-deprecated SAX1 {@link
   * org.xml.sax.AttributeList AttributeList} interface, which does not 
   * contain Namespace support.  In addition to Namespace support, it 
   * adds the <var>getIndex</var> methods (below).</p>
   *
   * <p>The order of attributes in the list is unspecified, and will
   * vary from implementation to implementation.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.helpers.AttributeListImpl
   */
  public interface Attributes
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Indexed access.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Return the number of attributes in the list.
       *
       * <p>Once you know the number of attributes, you can iterate
       * through the list.</p>
       *
       * @return The number of attributes in the list.
       * @see #getURI(int)
       * @see #getLocalName(int)
       * @see #getQName(int)
       * @see #getType(int)
       * @see #getValue(int)
       */
      public abstract int getLength ();
  
  
      /**
       * Look up an attribute's Namespace URI by index.
       *
       * @param index The attribute index (zero-based).
       * @return The Namespace URI, or the empty string if none
       *         is available, or null if the index is out of
       *         range.
       * @see #getLength
       */
      public abstract String getURI (int index);
  
  
      /**
       * Look up an attribute's local name by index.
       *
       * @param index The attribute index (zero-based).
       * @return The local name, or the empty string if Namespace
       *         processing is not being performed, or null
       *         if the index is out of range.
       * @see #getLength
       */
      public abstract String getLocalName (int index);
  
  
      /**
       * Look up an attribute's XML 1.0 qualified name by index.
       *
       * @param index The attribute index (zero-based).
       * @return The XML 1.0 qualified name, or the empty string
       *         if none is available, or null if the index
       *         is out of range.
       * @see #getLength
       */
      public abstract String getQName (int index);
  
  
      /**
       * Look up an attribute's type by index.
       *
       * <p>The attribute type is one of the strings "CDATA", "ID",
       * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
       * or "NOTATION" (always in upper case).</p>
       *
       * <p>If the parser has not read a declaration for the attribute,
       * or if the parser does not report attribute types, then it must
       * return the value "CDATA" as stated in the XML 1.0 Recommentation
       * (clause 3.3.3, "Attribute-Value Normalization").</p>
       *
       * <p>For an enumerated attribute that is not a notation, the
       * parser will report the type as "NMTOKEN".</p>
       *
       * @param index The attribute index (zero-based).
       * @return The attribute's type as a string, or null if the
       *         index is out of range.
       * @see #getLength
       */
      public abstract String getType (int index);
  
  
      /**
       * Look up an attribute's value by index.
       *
       * <p>If the attribute value is a list of tokens (IDREFS,
       * ENTITIES, or NMTOKENS), the tokens will be concatenated
       * into a single string with each token separated by a
       * single space.</p>
       *
       * @param index The attribute index (zero-based).
       * @return The attribute's value as a string, or null if the
       *         index is out of range.
       * @see #getLength
       */
      public abstract String getValue (int index);
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Name-based query.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Look up the index of an attribute by Namespace name.
       *
       * @param uri The Namespace URI, or the empty string if
       *        the name has no Namespace URI.
       * @param localName The attribute's local name.
       * @return The index of the attribute, or -1 if it does not
       *         appear in the list.
       */
      public int getIndex (String uri, String localPart);
  
  
      /**
       * Look up the index of an attribute by XML 1.0 qualified name.
       *
       * @param qName The qualified (prefixed) name.
       * @return The index of the attribute, or -1 if it does not
       *         appear in the list.
       */
      public int getIndex (String qName);
  
  
      /**
       * Look up an attribute's type by Namespace name.
       *
       * <p>See {@link #getType(int) getType(int)} for a description
       * of the possible types.</p>
       *
       * @param uri The Namespace URI, or the empty String if the
       *        name has no Namespace URI.
       * @param localName The local name of the attribute.
       * @return The attribute type as a string, or null if the
       *         attribute is not in the list or if Namespace
       *         processing is not being performed.
       */
      public abstract String getType (String uri, String localName);
  
  
      /**
       * Look up an attribute's type by XML 1.0 qualified name.
       *
       * <p>See {@link #getType(int) getType(int)} for a description
       * of the possible types.</p>
       *
       * @param qName The XML 1.0 qualified name.
       * @return The attribute type as a string, or null if the
       *         attribute is not in the list or if qualified names
       *         are not available.
       */
      public abstract String getType (String qName);
  
  
      /**
       * Look up an attribute's value by Namespace name.
       *
       * <p>See {@link #getValue(int) getValue(int)} for a description
       * of the possible values.</p>
       *
       * @param uri The Namespace URI, or the empty String if the
       *        name has no Namespace URI.
       * @param localName The local name of the attribute.
       * @return The attribute value as a string, or null if the
       *         attribute is not in the list.
       */
      public abstract String getValue (String uri, String localName);
  
  
      /**
       * Look up an attribute's value by XML 1.0 qualified name.
       *
       * <p>See {@link #getValue(int) getValue(int)} for a description
       * of the possible values.</p>
       *
       * @param qName The XML 1.0 qualified name.
       * @return The attribute value as a string, or null if the
       *         attribute is not in the list or if qualified names
       *         are not available.
       */
      public abstract String getValue (String qName);
  
  }
  
  // end of Attributes.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/ContentHandler.java
  
  Index: ContentHandler.java
  ===================================================================
  // ContentHandler.java - handle main document content.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the public domain.
  
  // $Id: ContentHandler.java,v 1.1 2000/10/02 02:43:16 sboag Exp $
  
  package org.xml.sax;
  
  
  /**
   * Receive notification of the logical content of a document.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This is the main interface that most SAX applications
   * implement: if the application needs to be informed of basic parsing 
   * events, it implements this interface and registers an instance with 
   * the SAX parser using the {@link org.xml.sax.XMLReader#setContentHandler 
   * setContentHandler} method.  The parser uses the instance to report 
   * basic document-related events like the start and end of elements 
   * and character data.</p>
   *
   * <p>The order of events in this interface is very important, and
   * mirrors the order of information in the document itself.  For
   * example, all of an element's content (character data, processing
   * instructions, and/or subelements) will appear, in order, between
   * the startElement event and the corresponding endElement event.</p>
   *
   * <p>This interface is similar to the now-deprecated SAX 1.0
   * DocumentHandler interface, but it adds support for Namespaces
   * and for reporting skipped entities (in non-validating XML
   * processors).</p>
   *
   * <p>Implementors should note that there is also a Java class
   * {@link java.net.ContentHandler ContentHandler} in the java.net
   * package; that means that it's probably a bad idea to do</p>
   *
   * <blockquote>
   * import java.net.*;
   * import org.xml.sax.*;
   * </blockquote>
   *
   * <p>In fact, "import ...*" is usually a sign of sloppy programming
   * anyway, so the user should consider this a feature rather than a
   * bug.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.XMLReader
   * @see org.xml.sax.DTDHandler
   * @see org.xml.sax.ErrorHandler
   */
  public interface ContentHandler
  {
  
      /**
       * Receive an object for locating the origin of SAX document events.
       *
       * <p>SAX parsers are strongly encouraged (though not absolutely
       * required) to supply a locator: if it does so, it must supply
       * the locator to the application by invoking this method before
       * invoking any of the other methods in the ContentHandler
       * interface.</p>
       *
       * <p>The locator allows the application to determine the end
       * position of any document-related event, even if the parser is
       * not reporting an error.  Typically, the application will
       * use this information for reporting its own errors (such as
       * character content that does not match an application's
       * business rules).  The information returned by the locator
       * is probably not sufficient for use with a search engine.</p>
       *
       * <p>Note that the locator will return correct information only
       * during the invocation of the events in this interface.  The
       * application should not attempt to use it at any other time.</p>
       *
       * @param locator An object that can return the location of
       *                any SAX document event.
       * @see org.xml.sax.Locator
       */
      public void setDocumentLocator (Locator locator);
  
  
      /**
       * Receive notification of the beginning of a document.
       *
       * <p>The SAX parser will invoke this method only once, before any
       * other methods in this interface or in {@link org.xml.sax.DTDHandler
       * DTDHandler} (except for {@link #setDocumentLocator 
       * setDocumentLocator}).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #endDocument
       */
      public void startDocument ()
  	throws SAXException;
  
  
      /**
       * Receive notification of the end of a document.
       *
       * <p>The SAX parser will invoke this method only once, and it will
       * be the last method invoked during the parse.  The parser shall
       * not invoke this method until it has either abandoned parsing
       * (because of an unrecoverable error) or reached the end of
       * input.</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #startDocument
       */
      public void endDocument()
  	throws SAXException;
  
  
      /**
       * Begin the scope of a prefix-URI Namespace mapping.
       *
       * <p>The information from this event is not necessary for
       * normal Namespace processing: the SAX XML reader will 
       * automatically replace prefixes for element and attribute
       * names when the <code>http://xml.org/sax/features/namespaces</code>
       * feature is <var>true</var> (the default).</p>
       *
       * <p>There are cases, however, when applications need to
       * use prefixes in character data or in attribute values,
       * where they cannot safely be expanded automatically; the
       * start/endPrefixMapping event supplies the information
       * to the application to expand prefixes in those contexts
       * itself, if necessary.</p>
       *
       * <p>Note that start/endPrefixMapping events are not
       * guaranteed to be properly nested relative to each-other:
       * all startPrefixMapping events will occur before the
       * corresponding {@link #startElement startElement} event, 
       * and all {@link #endPrefixMapping endPrefixMapping}
       * events will occur after the corresponding {@link #endElement
       * endElement} event, but their order is not otherwise 
       * guaranteed.</p>
       *
       * <p>There should never be start/endPrefixMapping events for the
       * "xml" prefix, since it is predeclared and immutable.</p>
       *
       * @param prefix The Namespace prefix being declared.
       * @param uri The Namespace URI the prefix is mapped to.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see #endPrefixMapping
       * @see #startElement
       */
      public void startPrefixMapping (String prefix, String uri)
  	throws SAXException;
  
  
      /**
       * End the scope of a prefix-URI mapping.
       *
       * <p>See {@link #startPrefixMapping startPrefixMapping} for 
       * details.  This event will always occur after the corresponding 
       * {@link #endElement endElement} event, but the order of 
       * {@link #endPrefixMapping endPrefixMapping} events is not otherwise
       * guaranteed.</p>
       *
       * @param prefix The prefix that was being mapping.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see #startPrefixMapping
       * @see #endElement
       */
      public void endPrefixMapping (String prefix)
  	throws SAXException;
  
  
      /**
       * Receive notification of the beginning of an element.
       *
       * <p>The Parser will invoke this method at the beginning of every
       * element in the XML document; there will be a corresponding
       * {@link #endElement endElement} event for every startElement event
       * (even when the element is empty). All of the element's content will be
       * reported, in order, before the corresponding endElement
       * event.</p>
       *
       * <p>This event allows up to three name components for each
       * element:</p>
       *
       * <ol>
       * <li>the Namespace URI;</li>
       * <li>the local name; and</li>
       * <li>the qualified (prefixed) name.</li>
       * </ol>
       *
       * <p>Any or all of these may be provided, depending on the
       * values of the <var>http://xml.org/sax/features/namespaces</var>
       * and the <var>http://xml.org/sax/features/namespace-prefixes</var>
       * properties:</p>
       *
       * <ul>
       * <li>the Namespace URI and local name are required when 
       * the namespaces property is <var>true</var> (the default), and are
       * optional when the namespaces property is <var>false</var> (if one is
       * specified, both must be);</li>
       * <li>the qualified name is required when the namespace-prefixes property
       * is <var>true</var>, and is optional when the namespace-prefixes property
       * is <var>false</var> (the default).</li>
       * </ul>
       *
       * <p>Note that the attribute list provided will contain only
       * attributes with explicit values (specified or defaulted):
       * #IMPLIED attributes will be omitted.  The attribute list
       * will contain attributes used for Namespace declarations
       * (xmlns* attributes) only if the
       * <code>http://xml.org/sax/features/namespace-prefixes</code>
       * property is true (it is false by default, and support for a 
       * true value is optional).</p>
       *
       * @param uri The Namespace URI, or the empty string if the
       *        element has no Namespace URI or if Namespace
       *        processing is not being performed.
       * @param localName The local name (without prefix), or the
       *        empty string if Namespace processing is not being
       *        performed.
       * @param qName The qualified name (with prefix), or the
       *        empty string if qualified names are not available.
       * @param atts The attributes attached to the element.  If
       *        there are no attributes, it shall be an empty
       *        Attributes object.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #endElement
       * @see org.xml.sax.Attributes
       */
      public void startElement (String namespaceURI, String localName,
  			      String qName, Attributes atts)
  	throws SAXException;
  
  
      /**
       * Receive notification of the end of an element.
       *
       * <p>The SAX parser will invoke this method at the end of every
       * element in the XML document; there will be a corresponding
       * {@link #startElement startElement} event for every endElement 
       * event (even when the element is empty).</p>
       *
       * <p>For information on the names, see startElement.</p>
       *
       * @param uri The Namespace URI, or the empty string if the
       *        element has no Namespace URI or if Namespace
       *        processing is not being performed.
       * @param localName The local name (without prefix), or the
       *        empty string if Namespace processing is not being
       *        performed.
       * @param qName The qualified XML 1.0 name (with prefix), or the
       *        empty string if qualified names are not available.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public void endElement (String namespaceURI, String localName,
  			    String qName)
  	throws SAXException;
  
  
      /**
       * Receive notification of character data.
       *
       * <p>The Parser will call this method to report each chunk of
       * character data.  SAX parsers may return all contiguous character
       * data in a single chunk, or they may split it into several
       * chunks; however, all of the characters in any single event
       * must come from the same external entity so that the Locator
       * provides useful information.</p>
       *
       * <p>The application must not attempt to read from the array
       * outside of the specified range.</p>
       *
       * <p>Note that some parsers will report whitespace in element
       * content using the {@link #ignorableWhitespace ignorableWhitespace}
       * method rather than this one (validating parsers <em>must</em> 
       * do so).</p>
       *
       * @param ch The characters from the XML document.
       * @param start The start position in the array.
       * @param length The number of characters to read from the array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #ignorableWhitespace 
       * @see org.xml.sax.Locator
       */
      public void characters (char ch[], int start, int length)
  	throws SAXException;
  
  
      /**
       * Receive notification of ignorable whitespace in element content.
       *
       * <p>Validating Parsers must use this method to report each chunk
       * of whitespace in element content (see the W3C XML 1.0 recommendation,
       * section 2.10): non-validating parsers may also use this method
       * if they are capable of parsing and using content models.</p>
       *
       * <p>SAX parsers may return all contiguous whitespace in a single
       * chunk, or they may split it into several chunks; however, all of
       * the characters in any single event must come from the same
       * external entity, so that the Locator provides useful
       * information.</p>
       *
       * <p>The application must not attempt to read from the array
       * outside of the specified range.</p>
       *
       * @param ch The characters from the XML document.
       * @param start The start position in the array.
       * @param length The number of characters to read from the array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #characters
       */
      public void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException;
  
  
      /**
       * Receive notification of a processing instruction.
       *
       * <p>The Parser will invoke this method once for each processing
       * instruction found: note that processing instructions may occur
       * before or after the main document element.</p>
       *
       * <p>A SAX parser must never report an XML declaration (XML 1.0,
       * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
       * using this method.</p>
       *
       * @param target The processing instruction target.
       * @param data The processing instruction data, or null if
       *        none was supplied.  The data does not include any
       *        whitespace separating it from the target.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public void processingInstruction (String target, String data)
  	throws SAXException;
  
  
      /**
       * Receive notification of a skipped entity.
       *
       * <p>The Parser will invoke this method once for each entity
       * skipped.  Non-validating processors may skip entities if they
       * have not seen the declarations (because, for example, the
       * entity was declared in an external DTD subset).  All processors
       * may skip external entities, depending on the values of the
       * <code>http://xml.org/sax/features/external-general-entities</code>
       * and the
       * <code>http://xml.org/sax/features/external-parameter-entities</code>
       * properties.</p>
       *
       * @param name The name of the skipped entity.  If it is a 
       *        parameter entity, the name will begin with '%', and if
       *        it is the external DTD subset, it will be the string
       *        "[dtd]".
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public void skippedEntity (String name)
  	throws SAXException;
  }
  
  // end of ContentHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/DTDHandler.java
  
  Index: DTDHandler.java
  ===================================================================
  // SAX DTD handler.
  // No warranty; no copyright -- use this as you will.
  // $Id: DTDHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  /**
   * Receive notification of basic DTD-related events.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>If a SAX application needs information about notations and
   * unparsed entities, then the application implements this 
   * interface and registers an instance with the SAX parser using 
   * the parser's setDTDHandler method.  The parser uses the 
   * instance to report notation and unparsed entity declarations to 
   * the application.</p>
   *
   * <p>Note that this interface includes only those DTD events that
   * the XML recommendation <em>requires</em> processors to report:
   * notation and unparsed entity declarations.</p>
   *
   * <p>The SAX parser may report these events in any order, regardless
   * of the order in which the notations and unparsed entities were
   * declared; however, all DTD events must be reported after the
   * document handler's startDocument event, and before the first
   * startElement event.</p>
   *
   * <p>It is up to the application to store the information for 
   * future use (perhaps in a hash table or object tree).
   * If the application encounters attributes of type "NOTATION",
   * "ENTITY", or "ENTITIES", it can use the information that it
   * obtained through this interface to find the entity and/or
   * notation corresponding with the attribute value.</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser#setDTDHandler
   * @see org.xml.sax.HandlerBase 
   */
  public interface DTDHandler {
      
      
      /**
       * Receive notification of a notation declaration event.
       *
       * <p>It is up to the application to record the notation for later
       * reference, if necessary.</p>
       *
       * <p>At least one of publicId and systemId must be non-null.
       * If a system identifier is present, and it is a URL, the SAX
       * parser must resolve it fully before passing it to the
       * application through this event.</p>
       *
       * <p>There is no guarantee that the notation declaration will be
       * reported before any unparsed entities that use it.</p>
       *
       * @param name The notation name.
       * @param publicId The notation's public identifier, or null if
       *        none was given.
       * @param systemId The notation's system identifier, or null if
       *        none was given.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #unparsedEntityDecl
       * @see org.xml.sax.AttributeList
       */
      public abstract void notationDecl (String name,
  				       String publicId,
  				       String systemId)
  	throws SAXException;
      
      
      /**
       * Receive notification of an unparsed entity declaration event.
       *
       * <p>Note that the notation name corresponds to a notation
       * reported by the {@link #notationDecl notationDecl} event.  
       * It is up to the application to record the entity for later 
       * reference, if necessary.</p>
       *
       * <p>If the system identifier is a URL, the parser must resolve it
       * fully before passing it to the application.</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @param name The unparsed entity's name.
       * @param publicId The entity's public identifier, or null if none
       *        was given.
       * @param systemId The entity's system identifier.
       * @param notation name The name of the associated notation.
       * @see #notationDecl
       * @see org.xml.sax.AttributeList
       */
      public abstract void unparsedEntityDecl (String name,
  					     String publicId,
  					     String systemId,
  					     String notationName)
  	throws SAXException;
      
  }
  
  // end of DTDHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/DocumentHandler.java
  
  Index: DocumentHandler.java
  ===================================================================
  // SAX document handler.
  // No warranty; no copyright -- use this as you will.
  // $Id: DocumentHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  /**
   * Receive notification of general document events.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This was the main event-handling interface for SAX1; in
   * SAX2, it has been replaced by {@link org.xml.sax.ContentHandler
   * ContentHandler}, which provides Namespace support and reporting
   * of skipped entities.  This interface is included in SAX2 only
   * to support legacy SAX1 applications.</p>
   *
   * <p>The order of events in this interface is very important, and
   * mirrors the order of information in the document itself.  For
   * example, all of an element's content (character data, processing
   * instructions, and/or subelements) will appear, in order, between
   * the startElement event and the corresponding endElement event.</p>
   *
   * <p>Application writers who do not want to implement the entire
   * interface can derive a class from HandlerBase, which implements
   * the default functionality; parser writers can instantiate
   * HandlerBase to obtain a default handler.  The application can find
   * the location of any document event using the Locator interface
   * supplied by the Parser through the setDocumentLocator method.</p>
   *
   * @deprecated This interface has been replaced by the SAX2
   *             {@link org.xml.sax.ContentHandler ContentHandler}
   *             interface, which includes Namespace support.
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser#setDocumentHandler
   * @see org.xml.sax.Locator
   * @see org.xml.sax.HandlerBase
   */
  public interface DocumentHandler {
      
      
      /**
       * Receive an object for locating the origin of SAX document events.
       *
       * <p>SAX parsers are strongly encouraged (though not absolutely
       * required) to supply a locator: if it does so, it must supply
       * the locator to the application by invoking this method before
       * invoking any of the other methods in the DocumentHandler
       * interface.</p>
       *
       * <p>The locator allows the application to determine the end
       * position of any document-related event, even if the parser is
       * not reporting an error.  Typically, the application will
       * use this information for reporting its own errors (such as
       * character content that does not match an application's
       * business rules).  The information returned by the locator
       * is probably not sufficient for use with a search engine.</p>
       *
       * <p>Note that the locator will return correct information only
       * during the invocation of the events in this interface.  The
       * application should not attempt to use it at any other time.</p>
       *
       * @param locator An object that can return the location of
       *                any SAX document event.
       * @see org.xml.sax.Locator
       */
      public abstract void setDocumentLocator (Locator locator);
      
      
      /**
       * Receive notification of the beginning of a document.
       *
       * <p>The SAX parser will invoke this method only once, before any
       * other methods in this interface or in DTDHandler (except for
       * setDocumentLocator).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public abstract void startDocument ()
  	throws SAXException;
      
      
      /**
       * Receive notification of the end of a document.
       *
       * <p>The SAX parser will invoke this method only once, and it will
       * be the last method invoked during the parse.  The parser shall
       * not invoke this method until it has either abandoned parsing
       * (because of an unrecoverable error) or reached the end of
       * input.</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public abstract void endDocument ()
  	throws SAXException;
      
      
      /**
       * Receive notification of the beginning of an element.
       *
       * <p>The Parser will invoke this method at the beginning of every
       * element in the XML document; there will be a corresponding
       * endElement() event for every startElement() event (even when the
       * element is empty). All of the element's content will be
       * reported, in order, before the corresponding endElement()
       * event.</p>
       *
       * <p>If the element name has a namespace prefix, the prefix will
       * still be attached.  Note that the attribute list provided will
       * contain only attributes with explicit values (specified or
       * defaulted): #IMPLIED attributes will be omitted.</p>
       *
       * @param name The element type name.
       * @param atts The attributes attached to the element, if any.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #endElement
       * @see org.xml.sax.AttributeList 
       */
      public abstract void startElement (String name, AttributeList atts)
  	throws SAXException;
      
      
      /**
       * Receive notification of the end of an element.
       *
       * <p>The SAX parser will invoke this method at the end of every
       * element in the XML document; there will be a corresponding
       * startElement() event for every endElement() event (even when the
       * element is empty).</p>
       *
       * <p>If the element name has a namespace prefix, the prefix will
       * still be attached to the name.</p>
       *
       * @param name The element type name
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public abstract void endElement (String name)
  	throws SAXException;
      
      
      /**
       * Receive notification of character data.
       *
       * <p>The Parser will call this method to report each chunk of
       * character data.  SAX parsers may return all contiguous character
       * data in a single chunk, or they may split it into several
       * chunks; however, all of the characters in any single event
       * must come from the same external entity, so that the Locator
       * provides useful information.</p>
       *
       * <p>The application must not attempt to read from the array
       * outside of the specified range.</p>
       *
       * <p>Note that some parsers will report whitespace using the
       * ignorableWhitespace() method rather than this one (validating
       * parsers must do so).</p>
       *
       * @param ch The characters from the XML document.
       * @param start The start position in the array.
       * @param length The number of characters to read from the array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #ignorableWhitespace 
       * @see org.xml.sax.Locator
       */
      public abstract void characters (char ch[], int start, int length)
  	throws SAXException;
      
      
      /**
       * Receive notification of ignorable whitespace in element content.
       *
       * <p>Validating Parsers must use this method to report each chunk
       * of ignorable whitespace (see the W3C XML 1.0 recommendation,
       * section 2.10): non-validating parsers may also use this method
       * if they are capable of parsing and using content models.</p>
       *
       * <p>SAX parsers may return all contiguous whitespace in a single
       * chunk, or they may split it into several chunks; however, all of
       * the characters in any single event must come from the same
       * external entity, so that the Locator provides useful
       * information.</p>
       *
       * <p>The application must not attempt to read from the array
       * outside of the specified range.</p>
       *
       * @param ch The characters from the XML document.
       * @param start The start position in the array.
       * @param length The number of characters to read from the array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #characters
       */
      public abstract void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException;
      
      
      /**
       * Receive notification of a processing instruction.
       *
       * <p>The Parser will invoke this method once for each processing
       * instruction found: note that processing instructions may occur
       * before or after the main document element.</p>
       *
       * <p>A SAX parser should never report an XML declaration (XML 1.0,
       * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
       * using this method.</p>
       *
       * @param target The processing instruction target.
       * @param data The processing instruction data, or null if
       *        none was supplied.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public abstract void processingInstruction (String target, String data)
  	throws SAXException;
      
  }
  
  // end of DocumentHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/EntityResolver.java
  
  Index: EntityResolver.java
  ===================================================================
  // SAX entity resolver.
  // No warranty; no copyright -- use this as you will.
  // $Id: EntityResolver.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  import java.io.IOException;
  
  
  /**
   * Basic interface for resolving entities.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>If a SAX application needs to implement customized handling
   * for external entities, it must implement this interface and
   * register an instance with the SAX driver using the
   * {@link org.xml.sax.XMLReader#setEntityResolver setEntityResolver}
   * method.</p>
   *
   * <p>The XML reader will then allow the application to intercept any
   * external entities (including the external DTD subset and external
   * parameter entities, if any) before including them.</p>
   *
   * <p>Many SAX applications will not need to implement this interface,
   * but it will be especially useful for applications that build
   * XML documents from databases or other specialised input sources,
   * or for applications that use URI types other than URLs.</p>
   *
   * <p>The following resolver would provide the application
   * with a special character stream for the entity with the system
   * identifier "http://www.myhost.com/today":</p>
   *
   * <pre>
   * import org.xml.sax.EntityResolver;
   * import org.xml.sax.InputSource;
   *
   * public class MyResolver implements EntityResolver {
   *   public InputSource resolveEntity (String publicId, String systemId)
   *   {
   *     if (systemId.equals("http://www.myhost.com/today")) {
   *              // return a special input source
   *       MyReader reader = new MyReader();
   *       return new InputSource(reader);
   *     } else {
   *              // use the default behaviour
   *       return null;
   *     }
   *   }
   * }
   * </pre>
   *
   * <p>The application can also use this interface to redirect system
   * identifiers to local URIs or to look up replacements in a catalog
   * (possibly by using the public identifier).</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser#setEntityResolver
   * @see org.xml.sax.InputSource
   */
  public interface EntityResolver {
      
      
      /**
       * Allow the application to resolve external entities.
       *
       * <p>The Parser will call this method before opening any external
       * entity except the top-level document entity (including the
       * external DTD subset, external entities referenced within the
       * DTD, and external entities referenced within the document
       * element): the application may request that the parser resolve
       * the entity itself, that it use an alternative URI, or that it
       * use an entirely different input source.</p>
       *
       * <p>Application writers can use this method to redirect external
       * system identifiers to secure and/or local URIs, to look up
       * public identifiers in a catalogue, or to read an entity from a
       * database or other input source (including, for example, a dialog
       * box).</p>
       *
       * <p>If the system identifier is a URL, the SAX parser must
       * resolve it fully before reporting it to the application.</p>
       *
       * @param publicId The public identifier of the external entity
       *        being referenced, or null if none was supplied.
       * @param systemId The system identifier of the external entity
       *        being referenced.
       * @return An InputSource object describing the new input source,
       *         or null to request that the parser open a regular
       *         URI connection to the system identifier.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException A Java-specific IO exception,
       *            possibly the result of creating a new InputStream
       *            or Reader for the InputSource.
       * @see org.xml.sax.InputSource
       */
      public abstract InputSource resolveEntity (String publicId,
  					       String systemId)
  	throws SAXException, IOException;
      
  }
  
  // end of EntityResolver.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/ErrorHandler.java
  
  Index: ErrorHandler.java
  ===================================================================
  // SAX error handler.
  // No warranty; no copyright -- use this as you will.
  // $Id: ErrorHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  
  /**
   * Basic interface for SAX error handlers.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>If a SAX application needs to implement customized error
   * handling, it must implement this interface and then register an
   * instance with the XML reader using the
   * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}
   * method.  The parser will then report all errors and warnings
   * through this interface.</p>
   *
   * <p><strong>WARNING:</strong> If an application does <em>not</em>
   * register an ErrorHandler, XML parsing errors will go unreported
   * and bizarre behaviour may result.</p>
   *
   * <p>For XML processing errors, a SAX driver must use this interface 
   * instead of throwing an exception: it is up to the application 
   * to decide whether to throw an exception for different types of 
   * errors and warnings.  Note, however, that there is no requirement that 
   * the parser continue to provide useful information after a call to 
   * {@link #fatalError fatalError} (in other words, a SAX driver class 
   * could catch an exception and report a fatalError).</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser#setErrorHandler
   * @see org.xml.sax.SAXParseException 
   */
  public interface ErrorHandler {
      
      
      /**
       * Receive notification of a warning.
       *
       * <p>SAX parsers will use this method to report conditions that
       * are not errors or fatal errors as defined by the XML 1.0
       * recommendation.  The default behaviour is to take no action.</p>
       *
       * <p>The SAX parser must continue to provide normal parsing events
       * after invoking this method: it should still be possible for the
       * application to process the document through to the end.</p>
       *
       * <p>Filters may use this method to report other, non-XML warnings
       * as well.</p>
       *
       * @param exception The warning information encapsulated in a
       *                  SAX parse exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.SAXParseException 
       */
      public abstract void warning (SAXParseException exception)
  	throws SAXException;
      
      
      /**
       * Receive notification of a recoverable error.
       *
       * <p>This corresponds to the definition of "error" in section 1.2
       * of the W3C XML 1.0 Recommendation.  For example, a validating
       * parser would use this callback to report the violation of a
       * validity constraint.  The default behaviour is to take no
       * action.</p>
       *
       * <p>The SAX parser must continue to provide normal parsing events
       * after invoking this method: it should still be possible for the
       * application to process the document through to the end.  If the
       * application cannot do so, then the parser should report a fatal
       * error even if the XML 1.0 recommendation does not require it to
       * do so.</p>
       *
       * <p>Filters may use this method to report other, non-XML errors
       * as well.</p>
       *
       * @param exception The error information encapsulated in a
       *                  SAX parse exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.SAXParseException 
       */
      public abstract void error (SAXParseException exception)
  	throws SAXException;
      
      
      /**
       * Receive notification of a non-recoverable error.
       *
       * <p>This corresponds to the definition of "fatal error" in
       * section 1.2 of the W3C XML 1.0 Recommendation.  For example, a
       * parser would use this callback to report the violation of a
       * well-formedness constraint.</p>
       *
       * <p>The application must assume that the document is unusable
       * after the parser has invoked this method, and should continue
       * (if at all) only for the sake of collecting addition error
       * messages: in fact, SAX parsers are free to stop reporting any
       * other events once this method has been invoked.</p>
       *
       * @param exception The error information encapsulated in a
       *                  SAX parse exception.  
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.SAXParseException
       */
      public abstract void fatalError (SAXParseException exception)
  	throws SAXException;
      
  }
  
  // end of ErrorHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/HandlerBase.java
  
  Index: HandlerBase.java
  ===================================================================
  // SAX default handler base class.
  // No warranty; no copyright -- use this as you will.
  // $Id: HandlerBase.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  /**
   * Default base class for handlers.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class implements the default behaviour for four SAX1
   * interfaces: EntityResolver, DTDHandler, DocumentHandler,
   * and ErrorHandler.  It is now obsolete, but is included in SAX2 to
   * support legacy SAX1 applications.  SAX2 applications should use
   * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
   * class instead.</p>
   *
   * <p>Application writers can extend this class when they need to
   * implement only part of an interface; parser writers can
   * instantiate this class to provide default handlers when the
   * application has not supplied its own.</p>
   *
   * <p>Note that the use of this class is optional.</p>
   *
   * @deprecated This class works with the deprecated
   *             {@link org.xml.sax.DocumentHandler DocumentHandler}
   *             interface.  It has been replaced by the SAX2
   *             {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
   *             class.
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.EntityResolver
   * @see org.xml.sax.DTDHandler
   * @see org.xml.sax.DocumentHandler
   * @see org.xml.sax.ErrorHandler
   */
  public class HandlerBase
      implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
  {
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of the EntityResolver interface.
      ////////////////////////////////////////////////////////////////////
      
      /**
       * Resolve an external entity.
       *
       * <p>Always return null, so that the parser will use the system
       * identifier provided in the XML document.  This method implements
       * the SAX default behaviour: application writers can override it
       * in a subclass to do special translations such as catalog lookups
       * or URI redirection.</p>
       *
       * @param publicId The public identifer, or null if none is
       *                 available.
       * @param systemId The system identifier provided in the XML 
       *                 document.
       * @return The new input source, or null to require the
       *         default behaviour.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.EntityResolver#resolveEntity
       */
      public InputSource resolveEntity (String publicId, String systemId)
  	throws SAXException
      {
  	return null;
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of DTDHandler interface.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Receive notification of a notation declaration.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass if they wish to keep track of the notations
       * declared in a document.</p>
       *
       * @param name The notation name.
       * @param publicId The notation public identifier, or null if not
       *                 available.
       * @param systemId The notation system identifier.
       * @see org.xml.sax.DTDHandler#notationDecl
       */
      public void notationDecl (String name, String publicId, String systemId)
      {
  	// no op
      }
      
      
      /**
       * Receive notification of an unparsed entity declaration.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to keep track of the unparsed entities
       * declared in a document.</p>
       *
       * @param name The entity name.
       * @param publicId The entity public identifier, or null if not
       *                 available.
       * @param systemId The entity system identifier.
       * @param notationName The name of the associated notation.
       * @see org.xml.sax.DTDHandler#unparsedEntityDecl
       */
      public void unparsedEntityDecl (String name, String publicId,
  				    String systemId, String notationName)
      {
  	// no op
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of DocumentHandler interface.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Receive a Locator object for document events.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass if they wish to store the locator for use
       * with other document events.</p>
       *
       * @param locator A locator for all SAX document events.
       * @see org.xml.sax.DocumentHandler#setDocumentLocator
       * @see org.xml.sax.Locator
       */
      public void setDocumentLocator (Locator locator)
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the beginning of the document.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the beginning
       * of a document (such as allocating the root node of a tree or
       * creating an output file).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#startDocument
       */
      public void startDocument ()
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the end of the document.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the beginning
       * of a document (such as finalising a tree or closing an output
       * file).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#endDocument
       */
      public void endDocument ()
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the start of an element.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the start of
       * each element (such as allocating a new tree node or writing
       * output to a file).</p>
       *
       * @param name The element type name.
       * @param attributes The specified or defaulted attributes.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#startElement
       */
      public void startElement (String name, AttributeList attributes)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the end of an element.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the end of
       * each element (such as finalising a tree node or writing
       * output to a file).</p>
       *
       * @param name The element type name.
       * @param attributes The specified or defaulted attributes.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#endElement
       */
      public void endElement (String name)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of character data inside an element.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method to take specific actions for each chunk of character data
       * (such as adding the data to a node or buffer, or printing it to
       * a file).</p>
       *
       * @param ch The characters.
       * @param start The start position in the character array.
       * @param length The number of characters to use from the
       *               character array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#characters
       */
      public void characters (char ch[], int start, int length)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of ignorable whitespace in element content.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method to take specific actions for each chunk of ignorable
       * whitespace (such as adding data to a node or buffer, or printing
       * it to a file).</p>
       *
       * @param ch The whitespace characters.
       * @param start The start position in the character array.
       * @param length The number of characters to use from the
       *               character array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#ignorableWhitespace
       */
      public void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of a processing instruction.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions for each
       * processing instruction, such as setting status variables or
       * invoking other methods.</p>
       *
       * @param target The processing instruction target.
       * @param data The processing instruction data, or null if
       *             none is supplied.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DocumentHandler#processingInstruction
       */
      public void processingInstruction (String target, String data)
  	throws SAXException
      {
  	// no op
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of the ErrorHandler interface.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Receive notification of a parser warning.
       *
       * <p>The default implementation does nothing.  Application writers
       * may override this method in a subclass to take specific actions
       * for each warning, such as inserting the message in a log file or
       * printing it to the console.</p>
       *
       * @param e The warning information encoded as an exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ErrorHandler#warning
       * @see org.xml.sax.SAXParseException
       */
      public void warning (SAXParseException e)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of a recoverable parser error.
       *
       * <p>The default implementation does nothing.  Application writers
       * may override this method in a subclass to take specific actions
       * for each error, such as inserting the message in a log file or
       * printing it to the console.</p>
       *
       * @param e The warning information encoded as an exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ErrorHandler#warning
       * @see org.xml.sax.SAXParseException
       */
      public void error (SAXParseException e)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Report a fatal XML parsing error.
       *
       * <p>The default implementation throws a SAXParseException.
       * Application writers may override this method in a subclass if
       * they need to take specific actions for each fatal error (such as
       * collecting all of the errors into a single report): in any case,
       * the application must stop all regular processing when this
       * method is invoked, since the document is no longer reliable, and
       * the parser may no longer report parsing events.</p>
       *
       * @param e The error information encoded as an exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ErrorHandler#fatalError
       * @see org.xml.sax.SAXParseException
       */
      public void fatalError (SAXParseException e)
  	throws SAXException
      {
  	throw e;
      }
      
  }
  
  // end of HandlerBase.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/InputSource.java
  
  Index: InputSource.java
  ===================================================================
  // SAX input source.
  // No warranty; no copyright -- use this as you will.
  // $Id: InputSource.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  import java.io.Reader;
  import java.io.InputStream;
  
  /**
   * A single input source for an XML entity.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class allows a SAX application to encapsulate information
   * about an input source in a single object, which may include
   * a public identifier, a system identifier, a byte stream (possibly
   * with a specified encoding), and/or a character stream.</p>
   *
   * <p>There are two places that the application will deliver this
   * input source to the parser: as the argument to the Parser.parse
   * method, or as the return value of the EntityResolver.resolveEntity
   * method.</p>
   *
   * <p>The SAX parser will use the InputSource object to determine how
   * to read XML input.  If there is a character stream available, the
   * parser will read that stream directly; if not, the parser will use
   * a byte stream, if available; if neither a character stream nor a
   * byte stream is available, the parser will attempt to open a URI
   * connection to the resource identified by the system
   * identifier.</p>
   *
   * <p>An InputSource object belongs to the application: the SAX parser
   * shall never modify it in any way (it may modify a copy if 
   * necessary).</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser#parse
   * @see org.xml.sax.EntityResolver#resolveEntity
   * @see java.io.InputStream
   * @see java.io.Reader
   */
  public class InputSource {
      
      /**
       * Zero-argument default constructor.
       *
       * @see #setPublicId
       * @see #setSystemId
       * @see #setByteStream
       * @see #setCharacterStream
       * @see #setEncoding
       */
      public InputSource ()
      {
      }
      
      
      /**
       * Create a new input source with a system identifier.
       *
       * <p>Applications may use setPublicId to include a 
       * public identifier as well, or setEncoding to specify
       * the character encoding, if known.</p>
       *
       * <p>If the system identifier is a URL, it must be full resolved.</p>
       *
       * @param systemId The system identifier (URI).
       * @see #setPublicId
       * @see #setSystemId
       * @see #setByteStream
       * @see #setEncoding
       * @see #setCharacterStream
       */
      public InputSource (String systemId)
      {
  	setSystemId(systemId);
      }
      
      
      /**
       * Create a new input source with a byte stream.
       *
       * <p>Application writers may use setSystemId to provide a base 
       * for resolving relative URIs, setPublicId to include a 
       * public identifier, and/or setEncoding to specify the object's
       * character encoding.</p>
       *
       * @param byteStream The raw byte stream containing the document.
       * @see #setPublicId
       * @see #setSystemId
       * @see #setEncoding
       * @see #setByteStream
       * @see #setCharacterStream
       */
      public InputSource (InputStream byteStream)
      {
  	setByteStream(byteStream);
      }
      
      
      /**
       * Create a new input source with a character stream.
       *
       * <p>Application writers may use setSystemId() to provide a base 
       * for resolving relative URIs, and setPublicId to include a 
       * public identifier.</p>
       *
       * <p>The character stream shall not include a byte order mark.</p>
       *
       * @see #setPublicId
       * @see #setSystemId
       * @see #setByteStream
       * @see #setCharacterStream
       */
      public InputSource (Reader characterStream)
      {
  	setCharacterStream(characterStream);
      }
      
      
      /**
       * Set the public identifier for this input source.
       *
       * <p>The public identifier is always optional: if the application
       * writer includes one, it will be provided as part of the
       * location information.</p>
       *
       * @param publicId The public identifier as a string.
       * @see #getPublicId
       * @see org.xml.sax.Locator#getPublicId
       * @see org.xml.sax.SAXParseException#getPublicId
       */
      public void setPublicId (String publicId)
      {
  	this.publicId = publicId;
      }
      
      
      /**
       * Get the public identifier for this input source.
       *
       * @return The public identifier, or null if none was supplied.
       * @see #setPublicId
       */
      public String getPublicId ()
      {
  	return publicId;
      }
      
      
      /**
       * Set the system identifier for this input source.
       *
       * <p>The system identifier is optional if there is a byte stream
       * or a character stream, but it is still useful to provide one,
       * since the application can use it to resolve relative URIs
       * and can include it in error messages and warnings (the parser
       * will attempt to open a connection to the URI only if
       * there is no byte stream or character stream specified).</p>
       *
       * <p>If the application knows the character encoding of the
       * object pointed to by the system identifier, it can register
       * the encoding using the setEncoding method.</p>
       *
       * <p>If the system ID is a URL, it must be fully resolved.</p>
       *
       * @param systemId The system identifier as a string.
       * @see #setEncoding
       * @see #getSystemId
       * @see org.xml.sax.Locator#getSystemId
       * @see org.xml.sax.SAXParseException#getSystemId
       */
      public void setSystemId (String systemId)
      {
  	this.systemId = systemId;
      }
      
      
      /**
       * Get the system identifier for this input source.
       *
       * <p>The getEncoding method will return the character encoding
       * of the object pointed to, or null if unknown.</p>
       *
       * <p>If the system ID is a URL, it will be fully resolved.</p>
       *
       * @return The system identifier.
       * @see #setSystemId
       * @see #getEncoding
       */
      public String getSystemId ()
      {
  	return systemId;
      }
      
      
      /**
       * Set the byte stream for this input source.
       *
       * <p>The SAX parser will ignore this if there is also a character
       * stream specified, but it will use a byte stream in preference
       * to opening a URI connection itself.</p>
       *
       * <p>If the application knows the character encoding of the
       * byte stream, it should set it with the setEncoding method.</p>
       *
       * @param byteStream A byte stream containing an XML document or
       *        other entity.
       * @see #setEncoding
       * @see #getByteStream
       * @see #getEncoding
       * @see java.io.InputStream
       */
      public void setByteStream (InputStream byteStream)
      {
  	this.byteStream = byteStream;
      }
      
      
      /**
       * Get the byte stream for this input source.
       *
       * <p>The getEncoding method will return the character
       * encoding for this byte stream, or null if unknown.</p>
       *
       * @return The byte stream, or null if none was supplied.
       * @see #getEncoding
       * @see #setByteStream
       */
      public InputStream getByteStream ()
      {
  	return byteStream;
      }
      
      
      /** 
       * Set the character encoding, if known.
       *
       * <p>The encoding must be a string acceptable for an
       * XML encoding declaration (see section 4.3.3 of the XML 1.0
       * recommendation).</p>
       *
       * <p>This method has no effect when the application provides a
       * character stream.</p>
       *
       * @param encoding A string describing the character encoding.
       * @see #setSystemId
       * @see #setByteStream
       * @see #getEncoding
       */
      public void setEncoding (String encoding)
      {
  	this.encoding = encoding;
      }
      
      
      /**
       * Get the character encoding for a byte stream or URI.
       *
       * @return The encoding, or null if none was supplied.
       * @see #setByteStream
       * @see #getSystemId
       * @see #getByteStream
       */
      public String getEncoding ()
      {
  	return encoding;
      }
      
      
      /**
       * Set the character stream for this input source.
       *
       * <p>If there is a character stream specified, the SAX parser
       * will ignore any byte stream and will not attempt to open
       * a URI connection to the system identifier.</p>
       *
       * @param characterStream The character stream containing the
       *        XML document or other entity.
       * @see #getCharacterStream
       * @see java.io.Reader
       */
      public void setCharacterStream (Reader characterStream)
      {
  	this.characterStream = characterStream;
      }
      
      
      /**
       * Get the character stream for this input source.
       *
       * @return The character stream, or null if none was supplied.
       * @see #setCharacterStream
       */
      public Reader getCharacterStream ()
      {
  	return characterStream;
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
      
      private String publicId;
      private String systemId;
      private InputStream byteStream;
      private String encoding;
      private Reader characterStream;
      
  }
  
  // end of InputSource.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/Locator.java
  
  Index: Locator.java
  ===================================================================
  // SAX locator interface for document events.
  // No warranty; no copyright -- use this as you will.
  // $Id: Locator.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  
  /**
   * Interface for associating a SAX event with a document location.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>If a SAX parser provides location information to the SAX
   * application, it does so by implementing this interface and then
   * passing an instance to the application using the content
   * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
   * setDocumentLocator} method.  The application can use the
   * object to obtain the location of any other content handler event
   * in the XML source document.</p>
   *
   * <p>Note that the results returned by the object will be valid only
   * during the scope of each content handler method: the application
   * will receive unpredictable results if it attempts to use the
   * locator at any other time.</p>
   *
   * <p>SAX parsers are not required to supply a locator, but they are
   * very strongly encouraged to do so.  If the parser supplies a
   * locator, it must do so before reporting any other document events.
   * If no locator has been set by the time the application receives
   * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
   * event, the application should assume that a locator is not 
   * available.</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.ContentHandler#setDocumentLocator 
   */
  public interface Locator {
      
      
      /**
       * Return the public identifier for the current document event.
       *
       * <p>The return value is the public identifier of the document
       * entity or of the external parsed entity in which the markup
       * triggering the event appears.</p>
       *
       * @return A string containing the public identifier, or
       *         null if none is available.
       * @see #getSystemId
       */
      public abstract String getPublicId ();
      
      
      /**
       * Return the system identifier for the current document event.
       *
       * <p>The return value is the system identifier of the document
       * entity or of the external parsed entity in which the markup
       * triggering the event appears.</p>
       *
       * <p>If the system identifier is a URL, the parser must resolve it
       * fully before passing it to the application.</p>
       *
       * @return A string containing the system identifier, or null
       *         if none is available.
       * @see #getPublicId
       */
      public abstract String getSystemId ();
      
      
      /**
       * Return the line number where the current document event ends.
       *
       * <p><strong>Warning:</strong> The return value from the method
       * is intended only as an approximation for the sake of error
       * reporting; it is not intended to provide sufficient information
       * to edit the character content of the original XML document.</p>
       *
       * <p>The return value is an approximation of the line number
       * in the document entity or external parsed entity where the
       * markup triggering the event appears.</p>
       *
       * <p>If possible, the SAX driver should provide the line position 
       * of the first character after the text associated with the document 
       * event.  The first line in the document is line 1.</p>
       *
       * @return The line number, or -1 if none is available.
       * @see #getColumnNumber
       */
      public abstract int getLineNumber ();
      
      
      /**
       * Return the column number where the current document event ends.
       *
       * <p><strong>Warning:</strong> The return value from the method
       * is intended only as an approximation for the sake of error
       * reporting; it is not intended to provide sufficient information
       * to edit the character content of the original XML document.</p>
       *
       * <p>The return value is an approximation of the column number
       * in the document entity or external parsed entity where the
       * markup triggering the event appears.</p>
       *
       * <p>If possible, the SAX driver should provide the line position 
       * of the first character after the text associated with the document 
       * event.</p>
       *
       * <p>If possible, the SAX driver should provide the line position 
       * of the first character after the text associated with the document 
       * event.  The first column in each line is column 1.</p>
       *
       * @return The column number, or -1 if none is available.
       * @see #getLineNumber
       */
      public abstract int getColumnNumber ();
      
  }
  
  // end of Locator.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/Parser.java
  
  Index: Parser.java
  ===================================================================
  // SAX parser interface.
  // No warranty; no copyright -- use this as you will.
  // $Id: Parser.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  import java.io.IOException;
  import java.util.Locale;
  
  
  /**
   * Basic interface for SAX (Simple API for XML) parsers.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This was the main event supplier interface for SAX1; it has
   * been replaced in SAX2 by {@link org.xml.sax.XMLReader XMLReader},
   * which includes Namespace support and sophisticated configurability
   * and extensibility.</p>
   *
   * <p>All SAX1 parsers must implement this basic interface: it allows
   * applications to register handlers for different types of events
   * and to initiate a parse from a URI, or a character stream.</p>
   *
   * <p>All SAX1 parsers must also implement a zero-argument constructor
   * (though other constructors are also allowed).</p>
   *
   * <p>SAX1 parsers are reusable but not re-entrant: the application
   * may reuse a parser object (possibly with a different input source)
   * once the first parse has completed successfully, but it may not
   * invoke the parse() methods recursively within a parse.</p>
   *
   * @deprecated This interface has been replaced by the SAX2
   *             {@link org.xml.sax.XMLReader XMLReader}
   *             interface, which includes Namespace support.
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.EntityResolver
   * @see org.xml.sax.DTDHandler
   * @see org.xml.sax.DocumentHandler
   * @see org.xml.sax.ErrorHandler
   * @see org.xml.sax.HandlerBase
   * @see org.xml.sax.InputSource
   */
  public interface Parser 
  {
      
      /**
       * Allow an application to request a locale for errors and warnings.
       *
       * <p>SAX parsers are not required to provide localisation for errors
       * and warnings; if they cannot support the requested locale,
       * however, they must throw a SAX exception.  Applications may
       * not request a locale change in the middle of a parse.</p>
       *
       * @param locale A Java Locale object.
       * @exception org.xml.sax.SAXException Throws an exception
       *            (using the previous or default locale) if the 
       *            requested locale is not supported.
       * @see org.xml.sax.SAXException
       * @see org.xml.sax.SAXParseException
       */
      public abstract void setLocale (Locale locale)
  	throws SAXException;
      
      
      /**
       * Allow an application to register a custom entity resolver.
       *
       * <p>If the application does not register an entity resolver, the
       * SAX parser will resolve system identifiers and open connections
       * to entities itself (this is the default behaviour implemented in
       * HandlerBase).</p>
       *
       * <p>Applications may register a new or different entity resolver
       * in the middle of a parse, and the SAX parser must begin using
       * the new resolver immediately.</p>
       *
       * @param resolver The object for resolving entities.
       * @see EntityResolver
       * @see HandlerBase
       */
      public abstract void setEntityResolver (EntityResolver resolver);
      
      
      /**
       * Allow an application to register a DTD event handler.
       *
       * <p>If the application does not register a DTD handler, all DTD
       * events reported by the SAX parser will be silently
       * ignored (this is the default behaviour implemented by
       * HandlerBase).</p>
       *
       * <p>Applications may register a new or different
       * handler in the middle of a parse, and the SAX parser must
       * begin using the new handler immediately.</p>
       *
       * @param handler The DTD handler.
       * @see DTDHandler
       * @see HandlerBase
       */
      public abstract void setDTDHandler (DTDHandler handler);
      
      
      /**
       * Allow an application to register a document event handler.
       *
       * <p>If the application does not register a document handler, all
       * document events reported by the SAX parser will be silently
       * ignored (this is the default behaviour implemented by
       * HandlerBase).</p>
       *
       * <p>Applications may register a new or different handler in the
       * middle of a parse, and the SAX parser must begin using the new
       * handler immediately.</p>
       *
       * @param handler The document handler.
       * @see DocumentHandler
       * @see HandlerBase
       */
      public abstract void setDocumentHandler (DocumentHandler handler);
      
      
      /**
       * Allow an application to register an error event handler.
       *
       * <p>If the application does not register an error event handler,
       * all error events reported by the SAX parser will be silently
       * ignored, except for fatalError, which will throw a SAXException
       * (this is the default behaviour implemented by HandlerBase).</p>
       *
       * <p>Applications may register a new or different handler in the
       * middle of a parse, and the SAX parser must begin using the new
       * handler immediately.</p>
       *
       * @param handler The error handler.
       * @see ErrorHandler
       * @see SAXException
       * @see HandlerBase
       */
      public abstract void setErrorHandler (ErrorHandler handler);
      
      
      /**
       * Parse an XML document.
       *
       * <p>The application can use this method to instruct the SAX parser
       * to begin parsing an XML document from any valid input
       * source (a character stream, a byte stream, or a URI).</p>
       *
       * <p>Applications may not invoke this method while a parse is in
       * progress (they should create a new Parser instead for each
       * additional XML document).  Once a parse is complete, an
       * application may reuse the same Parser object, possibly with a
       * different input source.</p>
       *
       * @param source The input source for the top-level of the
       *        XML document.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException An IO exception from the parser,
       *            possibly from a byte stream or character stream
       *            supplied by the application.
       * @see org.xml.sax.InputSource
       * @see #parse(java.lang.String)
       * @see #setEntityResolver
       * @see #setDTDHandler
       * @see #setDocumentHandler
       * @see #setErrorHandler
       */
      public abstract void parse (InputSource source)
  	throws SAXException, IOException;
      
      
      /**
       * Parse an XML document from a system identifier (URI).
       *
       * <p>This method is a shortcut for the common case of reading a
       * document from a system identifier.  It is the exact
       * equivalent of the following:</p>
       *
       * <pre>
       * parse(new InputSource(systemId));
       * </pre>
       *
       * <p>If the system identifier is a URL, it must be fully resolved
       * by the application before it is passed to the parser.</p>
       *
       * @param systemId The system identifier (URI).
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException An IO exception from the parser,
       *            possibly from a byte stream or character stream
       *            supplied by the application.
       * @see #parse(org.xml.sax.InputSource)
       */
      public abstract void parse (String systemId)
  	throws SAXException, IOException;
      
  }
  
  // end of Parser.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/SAXException.java
  
  Index: SAXException.java
  ===================================================================
  // SAX exception class.
  // No warranty; no copyright -- use this as you will.
  // $Id: SAXException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  /**
   * Encapsulate a general SAX error or warning.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class can contain basic error or warning information from
   * either the XML parser or the application: a parser writer or
   * application writer can subclass it to provide additional
   * functionality.  SAX handlers may throw this exception or
   * any exception subclassed from it.</p>
   *
   * <p>If the application needs to pass through other types of
   * exceptions, it must wrap those exceptions in a SAXException
   * or an exception derived from a SAXException.</p>
   *
   * <p>If the parser or application needs to include information about a
   * specific location in an XML document, it should use the
   * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.SAXParseException
   */
  public class SAXException extends Exception {
      
      
      /**
       * Create a new SAXException.
       *
       * @param message The error or warning message.
       * @see org.xml.sax.Parser#setLocale
       */
      public SAXException (String message) {
  	super(message);
  	this.exception = null;
      }
      
      
      /**
       * Create a new SAXException wrapping an existing exception.
       *
       * <p>The existing exception will be embedded in the new
       * one, and its message will become the default message for
       * the SAXException.</p>
       *
       * @param e The exception to be wrapped in a SAXException.
       */
      public SAXException (Exception e)
      {
  	super();
  	this.exception = e;
      }
      
      
      /**
       * Create a new SAXException from an existing exception.
       *
       * <p>The existing exception will be embedded in the new
       * one, but the new exception will have its own message.</p>
       *
       * @param message The detail message.
       * @param e The exception to be wrapped in a SAXException.
       * @see org.xml.sax.Parser#setLocale
       */
      public SAXException (String message, Exception e)
      {
  	super(message);
  	this.exception = e;
      }
      
      
      /**
       * Return a detail message for this exception.
       *
       * <p>If there is an embedded exception, and if the SAXException
       * has no detail message of its own, this method will return
       * the detail message from the embedded exception.</p>
       *
       * @return The error or warning message.
       * @see org.xml.sax.Parser#setLocale
       */
      public String getMessage ()
      {
  	String message = super.getMessage();
  	
  	if (message == null && exception != null) {
  	    return exception.getMessage();
  	} else {
  	    return message;
  	}
      }
      
      
      /**
       * Return the embedded exception, if any.
       *
       * @return The embedded exception, or null if there is none.
       */
      public Exception getException ()
      {
  	return exception;
      }
  
  
      /**
       * Override toString to pick up any embedded exception.
       *
       * @return A string representation of this exception.
       */
      public String toString ()
      {
  	if (exception != null) {
  	    return exception.toString();
  	} else {
  	    return super.toString();
  	}
      }
      
      
      
      //////////////////////////////////////////////////////////////////////
      // Internal state.
      //////////////////////////////////////////////////////////////////////
  
  
      /**
       * @serial The embedded exception if tunnelling, or null.
       */    
      private Exception exception;
      
  }
  
  // end of SAXException.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/SAXNotRecognizedException.java
  
  Index: SAXNotRecognizedException.java
  ===================================================================
  // SAXNotRecognizedException.java - unrecognized feature or value.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the Public Domain.
  
  // $Id: SAXNotRecognizedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  
  package org.xml.sax;
  
  
  /**
   * Exception class for an unrecognized identifier.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>An XMLReader will throw this exception when it finds an
   * unrecognized feature or property identifier; SAX applications and
   * extensions may use this class for other, similar purposes.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.SAXNotSupportedException
   */
  public class SAXNotRecognizedException extends SAXException
  {
  
      /**
       * Construct a new exception with the given message.
       *
       * @param message The text message of the exception.
       */
      public SAXNotRecognizedException (String message)
      {
  	super(message);
      }
  
  }
  
  // end of SAXNotRecognizedException.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/SAXNotSupportedException.java
  
  Index: SAXNotSupportedException.java
  ===================================================================
  // SAXNotSupportedException.java - unsupported feature or value.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the Public Domain.
  
  // $Id: SAXNotSupportedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  
  package org.xml.sax;
  
  /**
   * Exception class for an unsupported operation.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>An XMLReader will throw this exception when it recognizes a
   * feature or property identifier, but cannot perform the requested
   * operation (setting a state or value).  Other SAX2 applications and
   * extensions may use this class for similar purposes.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.SAXNotRecognizedException 
   */
  public class SAXNotSupportedException extends SAXException
  {
  
      /**
       * Construct a new exception with the given message.
       *
       * @param message The text message of the exception.
       */
      public SAXNotSupportedException (String message)
      {
  	super(message);
      }
  
  }
  
  // end of SAXNotSupportedException.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/SAXParseException.java
  
  Index: SAXParseException.java
  ===================================================================
  // SAX exception class.
  // No warranty; no copyright -- use this as you will.
  // $Id: SAXParseException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  /**
   * Encapsulate an XML parse error or warning.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This exception will include information for locating the error
   * in the original XML document.  Note that although the application
   * will receive a SAXParseException as the argument to the handlers
   * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface, 
   * the application is not actually required to throw the exception; 
   * instead, it can simply read the information in it and take a 
   * different action.</p>
   *
   * <p>Since this exception is a subclass of {@link org.xml.sax.SAXException 
   * SAXException}, it inherits the ability to wrap another exception.</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.SAXException
   * @see org.xml.sax.Locator
   * @see org.xml.sax.ErrorHandler
   */
  public class SAXParseException extends SAXException {
      
      
      //////////////////////////////////////////////////////////////////////
      // Constructors.
      //////////////////////////////////////////////////////////////////////
  
  
      /**
       * Create a new SAXParseException from a message and a Locator.
       *
       * <p>This constructor is especially useful when an application is
       * creating its own exception from within a {@link org.xml.sax.ContentHandler
       * ContentHandler} callback.</p>
       *
       * @param message The error or warning message.
       * @param locator The locator object for the error or warning (may be
       *        null).
       * @see org.xml.sax.Locator
       * @see org.xml.sax.Parser#setLocale 
       */
      public SAXParseException (String message, Locator locator) {
  	super(message);
  	if (locator != null) {
  	    init(locator.getPublicId(), locator.getSystemId(),
  		 locator.getLineNumber(), locator.getColumnNumber());
  	} else {
  	    init(null, null, -1, -1);
  	}
      }
      
      
      /**
       * Wrap an existing exception in a SAXParseException.
       *
       * <p>This constructor is especially useful when an application is
       * creating its own exception from within a {@link org.xml.sax.ContentHandler
       * ContentHandler} callback, and needs to wrap an existing exception that is not a
       * subclass of {@link org.xml.sax.SAXException SAXException}.</p>
       *
       * @param message The error or warning message, or null to
       *                use the message from the embedded exception.
       * @param locator The locator object for the error or warning (may be
       *        null).
       * @param e Any exception.
       * @see org.xml.sax.Locator
       * @see org.xml.sax.Parser#setLocale
       */
      public SAXParseException (String message, Locator locator,
  			      Exception e) {
  	super(message, e);
  	if (locator != null) {
  	    init(locator.getPublicId(), locator.getSystemId(),
  		 locator.getLineNumber(), locator.getColumnNumber());
  	} else {
  	    init(null, null, -1, -1);
  	}
      }
      
      
      /**
       * Create a new SAXParseException.
       *
       * <p>This constructor is most useful for parser writers.</p>
       *
       * <p>If the system identifier is a URL, the parser must resolve it
       * fully before creating the exception.</p>
       *
       * @param message The error or warning message.
       * @param publicId The public identifer of the entity that generated
       *                 the error or warning.
       * @param systemId The system identifer of the entity that generated
       *                 the error or warning.
       * @param lineNumber The line number of the end of the text that
       *                   caused the error or warning.
       * @param columnNumber The column number of the end of the text that
       *                     cause the error or warning.
       * @see org.xml.sax.Parser#setLocale
       */
      public SAXParseException (String message, String publicId, String systemId,
  			      int lineNumber, int columnNumber)
      {
  	super(message);
  	init(publicId, systemId, lineNumber, columnNumber);
      }
      
      
      /**
       * Create a new SAXParseException with an embedded exception.
       *
       * <p>This constructor is most useful for parser writers who
       * need to wrap an exception that is not a subclass of
       * {@link org.xml.sax.SAXException SAXException}.</p>
       *
       * <p>If the system identifier is a URL, the parser must resolve it
       * fully before creating the exception.</p>
       *
       * @param message The error or warning message, or null to use
       *                the message from the embedded exception.
       * @param publicId The public identifer of the entity that generated
       *                 the error or warning.
       * @param systemId The system identifer of the entity that generated
       *                 the error or warning.
       * @param lineNumber The line number of the end of the text that
       *                   caused the error or warning.
       * @param columnNumber The column number of the end of the text that
       *                     cause the error or warning.
       * @param e Another exception to embed in this one.
       * @see org.xml.sax.Parser#setLocale
       */
      public SAXParseException (String message, String publicId, String systemId,
  			      int lineNumber, int columnNumber, Exception e)
      {
  	super(message, e);
  	init(publicId, systemId, lineNumber, columnNumber);
      }
  
  
      /**
       * Internal initialization method.
       *
       * @param publicId The public identifier of the entity which generated the exception,
       *        or null.
       * @param systemId The system identifier of the entity which generated the exception,
       *        or null.
       * @param lineNumber The line number of the error, or -1.
       * @param columnNumber The column number of the error, or -1.
       */
      private void init (String publicId, String systemId,
  		       int lineNumber, int columnNumber)
      {
  	this.publicId = publicId;
  	this.systemId = systemId;
  	this.lineNumber = lineNumber;
  	this.columnNumber = columnNumber;
      }
      
      
      /**
       * Get the public identifier of the entity where the exception occurred.
       *
       * @return A string containing the public identifier, or null
       *         if none is available.
       * @see org.xml.sax.Locator#getPublicId
       */
      public String getPublicId ()
      {
  	return this.publicId;
      }
      
      
      /**
       * Get the system identifier of the entity where the exception occurred.
       *
       * <p>If the system identifier is a URL, it will be resolved
       * fully.</p>
       *
       * @return A string containing the system identifier, or null
       *         if none is available.
       * @see org.xml.sax.Locator#getSystemId
       */
      public String getSystemId ()
      {
  	return this.systemId;
      }
      
      
      /**
       * The line number of the end of the text where the exception occurred.
       *
       * @return An integer representing the line number, or -1
       *         if none is available.
       * @see org.xml.sax.Locator#getLineNumber
       */
      public int getLineNumber ()
      {
  	return this.lineNumber;
      }
      
      
      /**
       * The column number of the end of the text where the exception occurred.
       *
       * <p>The first column in a line is position 1.</p>
       *
       * @return An integer representing the column number, or -1
       *         if none is available.
       * @see org.xml.sax.Locator#getColumnNumber
       */
      public int getColumnNumber ()
      {
  	return this.columnNumber;
      }
      
      
      
      //////////////////////////////////////////////////////////////////////
      // Internal state.
      //////////////////////////////////////////////////////////////////////
  
  
      /**
       * @serial The public identifier, or null.
       * @see #getPublicId
       */    
      private String publicId;
  
  
      /**
       * @serial The system identifier, or null.
       * @see #getSystemId
       */
      private String systemId;
  
  
      /**
       * @serial The line number, or -1.
       * @see #getLineNumber
       */
      private int lineNumber;
  
  
      /**
       * @serial The column number, or -1.
       * @see #getColumnNumber
       */
      private int columnNumber;
      
  }
  
  // end of SAXParseException.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/XMLFilter.java
  
  Index: XMLFilter.java
  ===================================================================
  // XMLFilter.java - filter SAX2 events.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the Public Domain.
  
  // $Id: XMLFilter.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  
  package org.xml.sax;
  
  
  /**
   * Interface for an XML filter.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>An XML filter is like an XML reader, except that it obtains its
   * events from another XML reader rather than a primary source like
   * an XML document or database.  Filters can modify a stream of
   * events as they pass on to the final application.</p>
   *
   * <p>The XMLFilterImpl helper class provides a convenient base
   * for creating SAX2 filters, by passing on all {@link org.xml.sax.EntityResolver
   * EntityResolver}, {@link org.xml.sax.DTDHandler DTDHandler},
   * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler
   * ErrorHandler} events automatically.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.helpers.XMLFilterImpl
   */
  public interface XMLFilter extends XMLReader
  {
  
      /**
       * Set the parent reader.
       *
       * <p>This method allows the application to link the filter to
       * a parent reader (which may be another filter).  The argument
       * may not be null.</p>
       *
       * @param parent The parent reader.
       */
      public abstract void setParent (XMLReader parent);
  
  
      /**
       * Get the parent reader.
       *
       * <p>This method allows the application to query the parent
       * reader (which may be another filter).  It is generally a
       * bad idea to perform any operations on the parent reader
       * directly: they should all pass through this filter.</p>
       *
       * @return The parent filter, or null if none has been set.
       */
      public abstract XMLReader getParent ();
  
  }
  
  // end of XMLFilter.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/XMLReader.java
  
  Index: XMLReader.java
  ===================================================================
  // XMLReader.java - read an XML document.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the Public Domain.
  
  // $Id: XMLReader.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
  
  package org.xml.sax;
  
  import java.io.IOException;
  
  
  /**
   * Interface for reading an XML document using callbacks.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p><strong>Note:</strong> despite its name, this interface does 
   * <em>not</em> extend the standard Java {@link java.io.Reader Reader} 
   * interface, because reading XML is a fundamentally different activity 
   * than reading character data.</p>
   *
   * <p>XMLReader is the interface that an XML parser's SAX2 driver must
   * implement.  This interface allows an application to set and
   * query features and properties in the parser, to register
   * event handlers for document processing, and to initiate
   * a document parse.</p>
   *
   * <p>All SAX interfaces are assumed to be synchronous: the
   * {@link #parse parse} methods must not return until parsing
   * is complete, and readers must wait for an event-handler callback
   * to return before reporting the next event.</p>
   *
   * <p>This interface replaces the (now deprecated) SAX 1.0 {@link
   * org.xml.sax.Parser Parser} interface.  The XMLReader interface
   * contains two important enhancements over the old Parser
   * interface:</p>
   *
   * <ol>
   * <li>it adds a standard way to query and set features and 
   *  properties; and</li>
   * <li>it adds Namespace support, which is required for many
   *  higher-level XML standards.</li>
   * </ol>
   *
   * <p>There are adapters available to convert a SAX1 Parser to
   * a SAX2 XMLReader and vice-versa.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.XMLFilter
   * @see org.xml.sax.helpers.ParserAdapter
   * @see org.xml.sax.helpers.XMLReaderAdapter 
   */
  public interface XMLReader
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Configuration.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Look up the value of a feature.
       *
       * <p>The feature name is any fully-qualified URI.  It is
       * possible for an XMLReader to recognize a feature name but
       * to be unable to return its value; this is especially true
       * in the case of an adapter for a SAX1 Parser, which has
       * no way of knowing whether the underlying parser is
       * performing validation or expanding external entities.</p>
       *
       * <p>All XMLReaders are required to recognize the
       * http://xml.org/sax/features/namespaces and the
       * http://xml.org/sax/features/namespace-prefixes feature names.</p>
       *
       * <p>Some feature values may be available only in specific
       * contexts, such as before, during, or after a parse.</p>
       *
       * <p>Typical usage is something like this:</p>
       *
       * <pre>
       * XMLReader r = new MySAXDriver();
       *
       *                         // try to activate validation
       * try {
       *   r.setFeature("http://xml.org/sax/features/validation", true);
       * } catch (SAXException e) {
       *   System.err.println("Cannot activate validation."); 
       * }
       *
       *                         // register event handlers
       * r.setContentHandler(new MyContentHandler());
       * r.setErrorHandler(new MyErrorHandler());
       *
       *                         // parse the first document
       * try {
       *   r.parse("http://www.foo.com/mydoc.xml");
       * } catch (IOException e) {
       *   System.err.println("I/O exception reading XML document");
       * } catch (SAXException e) {
       *   System.err.println("XML exception reading document.");
       * }
       * </pre>
       *
       * <p>Implementors are free (and encouraged) to invent their own features,
       * using names built on their own URIs.</p>
       *
       * @param name The feature name, which is a fully-qualified URI.
       * @return The current state of the feature (true or false).
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the feature name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the feature name but 
       *            cannot determine its value at this time.
       * @see #setFeature
       */
      public boolean getFeature (String name)
          throws SAXNotRecognizedException, SAXNotSupportedException;
  
  
      /**
       * Set the state of a feature.
       *
       * <p>The feature name is any fully-qualified URI.  It is
       * possible for an XMLReader to recognize a feature name but
       * to be unable to set its value; this is especially true
       * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
       * which has no way of affecting whether the underlying parser is
       * validating, for example.</p>
       *
       * <p>All XMLReaders are required to support setting
       * http://xml.org/sax/features/namespaces to true and
       * http://xml.org/sax/features/namespace-prefixes to false.</p>
       *
       * <p>Some feature values may be immutable or mutable only 
       * in specific contexts, such as before, during, or after 
       * a parse.</p>
       *
       * @param name The feature name, which is a fully-qualified URI.
       * @param state The requested state of the feature (true or false).
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the feature name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the feature name but 
       *            cannot set the requested value.
       * @see #getFeature
       */
      public void setFeature (String name, boolean value)
  	throws SAXNotRecognizedException, SAXNotSupportedException;
  
  
      /**
       * Look up the value of a property.
       *
       * <p>The property name is any fully-qualified URI.  It is
       * possible for an XMLReader to recognize a property name but
       * to be unable to return its state; this is especially true
       * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
       * Parser}.</p>
       *
       * <p>XMLReaders are not required to recognize any specific
       * property names, though an initial core set is documented for
       * SAX2.</p>
       *
       * <p>Some property values may be available only in specific
       * contexts, such as before, during, or after a parse.</p>
       *
       * <p>Implementors are free (and encouraged) to invent their own properties,
       * using names built on their own URIs.</p>
       *
       * @param name The property name, which is a fully-qualified URI.
       * @return The current value of the property.
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the property name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the property name but 
       *            cannot determine its value at this time.
       * @see #setProperty
       */
      public Object getProperty (String name)
  	throws SAXNotRecognizedException, SAXNotSupportedException;
  
  
      /**
       * Set the value of a property.
       *
       * <p>The property name is any fully-qualified URI.  It is
       * possible for an XMLReader to recognize a property name but
       * to be unable to set its value; this is especially true
       * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
       * Parser}.</p>
       *
       * <p>XMLReaders are not required to recognize setting
       * any specific property names, though a core set is provided with 
       * SAX2.</p>
       *
       * <p>Some property values may be immutable or mutable only 
       * in specific contexts, such as before, during, or after 
       * a parse.</p>
       *
       * <p>This method is also the standard mechanism for setting
       * extended handlers.</p>
       *
       * @param name The property name, which is a fully-qualified URI.
       * @param state The requested value for the property.
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the property name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the property name but 
       *            cannot set the requested value.
       */
      public void setProperty (String name, Object value)
  	throws SAXNotRecognizedException, SAXNotSupportedException;
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Event handlers.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Allow an application to register an entity resolver.
       *
       * <p>If the application does not register an entity resolver,
       * the XMLReader will perform its own default resolution.</p>
       *
       * <p>Applications may register a new or different resolver in the
       * middle of a parse, and the SAX parser must begin using the new
       * resolver immediately.</p>
       *
       * @param resolver The entity resolver.
       * @exception java.lang.NullPointerException If the resolver 
       *            argument is null.
       * @see #getEntityResolver
       */
      public void setEntityResolver (EntityResolver resolver);
  
  
      /**
       * Return the current entity resolver.
       *
       * @return The current entity resolver, or null if none
       *         has been registered.
       * @see #setEntityResolver
       */
      public EntityResolver getEntityResolver ();
  
  
      /**
       * Allow an application to register a DTD event handler.
       *
       * <p>If the application does not register a DTD handler, all DTD
       * events reported by the SAX parser will be silently ignored.</p>
       *
       * <p>Applications may register a new or different handler in the
       * middle of a parse, and the SAX parser must begin using the new
       * handler immediately.</p>
       *
       * @param handler The DTD handler.
       * @exception java.lang.NullPointerException If the handler 
       *            argument is null.
       * @see #getDTDHandler
       */
      public void setDTDHandler (DTDHandler handler);
  
  
      /**
       * Return the current DTD handler.
       *
       * @return The current DTD handler, or null if none
       *         has been registered.
       * @see #setDTDHandler
       */
      public DTDHandler getDTDHandler ();
  
  
      /**
       * Allow an application to register a content event handler.
       *
       * <p>If the application does not register a content handler, all
       * content events reported by the SAX parser will be silently
       * ignored.</p>
       *
       * <p>Applications may register a new or different handler in the
       * middle of a parse, and the SAX parser must begin using the new
       * handler immediately.</p>
       *
       * @param handler The content handler.
       * @exception java.lang.NullPointerException If the handler 
       *            argument is null.
       * @see #getContentHandler
       */
      public void setContentHandler (ContentHandler handler);
  
  
      /**
       * Return the current content handler.
       *
       * @return The current content handler, or null if none
       *         has been registered.
       * @see #setContentHandler
       */
      public ContentHandler getContentHandler ();
  
  
      /**
       * Allow an application to register an error event handler.
       *
       * <p>If the application does not register an error handler, all
       * error events reported by the SAX parser will be silently
       * ignored; however, normal processing may not continue.  It is
       * highly recommended that all SAX applications implement an
       * error handler to avoid unexpected bugs.</p>
       *
       * <p>Applications may register a new or different handler in the
       * middle of a parse, and the SAX parser must begin using the new
       * handler immediately.</p>
       *
       * @param handler The error handler.
       * @exception java.lang.NullPointerException If the handler 
       *            argument is null.
       * @see #getErrorHandler
       */
      public void setErrorHandler (ErrorHandler handler);
  
  
      /**
       * Return the current error handler.
       *
       * @return The current error handler, or null if none
       *         has been registered.
       * @see #setErrorHandler
       */
      public ErrorHandler getErrorHandler ();
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Parsing.
      ////////////////////////////////////////////////////////////////////
  
      /**
       * Parse an XML document.
       *
       * <p>The application can use this method to instruct the XML
       * reader to begin parsing an XML document from any valid input
       * source (a character stream, a byte stream, or a URI).</p>
       *
       * <p>Applications may not invoke this method while a parse is in
       * progress (they should create a new XMLReader instead for each
       * nested XML document).  Once a parse is complete, an
       * application may reuse the same XMLReader object, possibly with a
       * different input source.</p>
       *
       * <p>During the parse, the XMLReader will provide information
       * about the XML document through the registered event
       * handlers.</p>
       *
       * <p>This method is synchronous: it will not return until parsing
       * has ended.  If a client application wants to terminate 
       * parsing early, it should throw an exception.</p>
       *
       * @param source The input source for the top-level of the
       *        XML document.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException An IO exception from the parser,
       *            possibly from a byte stream or character stream
       *            supplied by the application.
       * @see org.xml.sax.InputSource
       * @see #parse(java.lang.String)
       * @see #setEntityResolver
       * @see #setDTDHandler
       * @see #setContentHandler
       * @see #setErrorHandler 
       */
      public void parse (InputSource input)
  	throws IOException, SAXException;
  
  
      /**
       * Parse an XML document from a system identifier (URI).
       *
       * <p>This method is a shortcut for the common case of reading a
       * document from a system identifier.  It is the exact
       * equivalent of the following:</p>
       *
       * <pre>
       * parse(new InputSource(systemId));
       * </pre>
       *
       * <p>If the system identifier is a URL, it must be fully resolved
       * by the application before it is passed to the parser.</p>
       *
       * @param systemId The system identifier (URI).
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException An IO exception from the parser,
       *            possibly from a byte stream or character stream
       *            supplied by the application.
       * @see #parse(org.xml.sax.InputSource)
       */
      public void parse (String systemId)
  	throws IOException, SAXException;
  
  }
  
  // end of XMLReader.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/ext/DeclHandler.java
  
  Index: DeclHandler.java
  ===================================================================
  // DeclHandler.java - Optional handler for DTD declaration events.
  // Public Domain: no warranty.
  // $Id: DeclHandler.java,v 1.1 2000/10/02 02:43:19 sboag Exp $
  
  package org.xml.sax.ext;
  
  import org.xml.sax.SAXException;
  
  
  /**
   * SAX2 extension handler for DTD declaration events.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This is an optional extension handler for SAX2 to provide
   * information about DTD declarations in an XML document.  XML
   * readers are not required to support this handler.</p>
   *
   * <p>Note that data-related DTD declarations (unparsed entities and
   * notations) are already reported through the {@link
   * org.xml.sax.DTDHandler DTDHandler} interface.</p>
   *
   * <p>If you are using the declaration handler together with a lexical
   * handler, all of the events will occur between the
   * {@link org.xml.sax.ext.LexicalHandler#startDTD startDTD} and the
   * {@link org.xml.sax.ext.LexicalHandler#endDTD endDTD} events.</p>
   *
   * <p>To set the DeclHandler for an XML reader, use the
   * {@link org.xml.sax.XMLReader#setProperty setProperty} method
   * with the propertyId "http://xml.org/sax/handlers/DeclHandler".
   * If the reader does not support declaration events, it will throw a
   * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
   * or a
   * {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
   * when you attempt to register the handler.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0beta
   * @see org.xml.sax.XMLReader
   */
  public interface DeclHandler
  {
  
      /**
       * Report an element type declaration.
       *
       * <p>The content model will consist of the string "EMPTY", the
       * string "ANY", or a parenthesised group, optionally followed
       * by an occurrence indicator.  The model will be normalized so
       * that all whitespace is removed,and will include the enclosing
       * parentheses.</p>
       *
       * @param name The element type name.
       * @param model The content model as a normalized string.
       * @exception SAXException The application may raise an exception.
       */
      public abstract void elementDecl (String name, String model)
  	throws SAXException;
  
  
      /**
       * Report an attribute type declaration.
       *
       * <p>Only the effective (first) declaration for an attribute will
       * be reported.  The type will be one of the strings "CDATA",
       * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
       * "ENTITIES", or "NOTATION", or a parenthesized token group with 
       * the separator "|" and all whitespace removed.</p>
       *
       * @param eName The name of the associated element.
       * @param aName The name of the attribute.
       * @param type A string representing the attribute type.
       * @param valueDefault A string representing the attribute default
       *        ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
       *        none of these applies.
       * @param value A string representing the attribute's default value,
       *        or null if there is none.
       * @exception SAXException The application may raise an exception.
       */
      public abstract void attributeDecl (String eName,
  					String aName,
  					String type,
  					String valueDefault,
  					String value)
  	throws SAXException;
  
  
      /**
       * Report an internal entity declaration.
       *
       * <p>Only the effective (first) declaration for each entity
       * will be reported.</p>
       *
       * @param name The name of the entity.  If it is a parameter
       *        entity, the name will begin with '%'.
       * @param value The replacement text of the entity.
       * @exception SAXException The application may raise an exception.
       * @see #externalEntityDecl
       * @see org.xml.sax.DTDHandler#unparsedEntityDecl
       */
      public abstract void internalEntityDecl (String name, String value)
  	throws SAXException;
  
  
      /**
       * Report a parsed external entity declaration.
       *
       * <p>Only the effective (first) declaration for each entity
       * will be reported.</p>
       *
       * @param name The name of the entity.  If it is a parameter
       *        entity, the name will begin with '%'.
       * @param publicId The declared public identifier of the entity, or
       *        null if none was declared.
       * @param systemId The declared system identifier of the entity.
       * @exception SAXException The application may raise an exception.
       * @see #internalEntityDecl
       * @see org.xml.sax.DTDHandler#unparsedEntityDecl
       */
      public abstract void externalEntityDecl (String name, String publicId,
  					     String systemId)
  	throws SAXException;
  
  }
  
  // end of DeclHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/ext/LexicalHandler.java
  
  Index: LexicalHandler.java
  ===================================================================
  // LexicalHandler.java - optional handler for lexical parse events.
  // Public Domain: no warranty.
  // $Id: LexicalHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.ext;
  
  import org.xml.sax.SAXException;
  
  /**
   * SAX2 extension handler for lexical events.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This is an optional extension handler for SAX2 to provide
   * lexical information about an XML document, such as comments
   * and CDATA section boundaries; XML readers are not required to 
   * support this handler.</p>
   *
   * <p>The events in the lexical handler apply to the entire document,
   * not just to the document element, and all lexical handler events
   * must appear between the content handler's startDocument and
   * endDocument events.</p>
   *
   * <p>To set the LexicalHandler for an XML reader, use the
   * {@link org.xml.sax.XMLReader#setProperty setProperty} method
   * with the propertyId "http://xml.org/sax/handlers/LexicalHandler".
   * If the reader does not support lexical events, it will throw a
   * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
   * or a
   * {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
   * when you attempt to register the handler.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0beta
   * @see org.xml.sax.XMLReader#setProperty
   * @see org.xml.sax.SAXNotRecognizedException
   * @see org.xml.sax.SAXNotSupportedException
   */
  public interface LexicalHandler
  {
  
      /**
       * Report the start of DTD declarations, if any.
       *
       * <p>Any declarations are assumed to be in the internal subset
       * unless otherwise indicated by a {@link #startEntity startEntity}
       * event.</p>
       *
       * <p>Note that the start/endDTD events will appear within
       * the start/endDocument events from ContentHandler and
       * before the first startElement event.</p>
       *
       * @param name The document type name.
       * @param publicId The declared public identifier for the
       *        external DTD subset, or null if none was declared.
       * @param systemId The declared system identifier for the
       *        external DTD subset, or null if none was declared.
       * @exception SAXException The application may raise an
       *            exception.
       * @see #endDTD
       * @see #startEntity
       */
      public abstract void startDTD (String name, String publicId,
  				   String systemId)
  	throws SAXException;
  
  
      /**
       * Report the end of DTD declarations.
       *
       * @exception SAXException The application may raise an exception.
       * @see #startDTD
       */
      public abstract void endDTD ()
  	throws SAXException;
  
  
      /**
       * Report the beginning of an entity in content.
       *
       * <p><strong>NOTE:</entity> entity references in attribute
       * values -- and the start and end of the document entity --
       * are never reported.</p>
       *
       * <p>The start and end of the external DTD subset are reported
       * using the pseudo-name "[dtd]".  All other events must be
       * properly nested within start/end entity events.</p>
       *
       * <p>Note that skipped entities will be reported through the
       * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
       * event, which is part of the ContentHandler interface.</p>
       *
       * @param name The name of the entity.  If it is a parameter
       *        entity, the name will begin with '%'.
       * @exception SAXException The application may raise an exception.
       * @see #endEntity
       * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
       * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
       */
      public abstract void startEntity (String name)
  	throws SAXException;
  
  
      /**
       * Report the end of an entity.
       *
       * @param name The name of the entity that is ending.
       * @exception SAXException The application may raise an exception.
       * @see #startEntity
       */
      public abstract void endEntity (String name)
  	throws SAXException;
  
  
      /**
       * Report the start of a CDATA section.
       *
       * <p>The contents of the CDATA section will be reported through
       * the regular {@link org.xml.sax.ContentHandler#characters
       * characters} event.</p>
       *
       * @exception SAXException The application may raise an exception.
       * @see #endCDATA
       */
      public abstract void startCDATA ()
  	throws SAXException;
  
  
      /**
       * Report the end of a CDATA section.
       *
       * @exception SAXException The application may raise an exception.
       * @see #startCDATA
       */
      public abstract void endCDATA ()
  	throws SAXException;
  
  
      /**
       * Report an XML comment anywhere in the document.
       *
       * <p>This callback will be used for comments inside or outside the
       * document element, including comments in the external DTD
       * subset (if read).</p>
       *
       * @param ch An array holding the characters in the comment.
       * @param start The starting position in the array.
       * @param length The number of characters to use from the array.
       * @exception SAXException The application may raise an exception.
       */
      public abstract void comment (char ch[], int start, int length)
  	throws SAXException;
  
  }
  
  // end of LexicalHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/AttributeListImpl.java
  
  Index: AttributeListImpl.java
  ===================================================================
  // SAX default implementation for AttributeList.
  // No warranty; no copyright -- use this as you will.
  // $Id: AttributeListImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import org.xml.sax.AttributeList;
  
  import java.util.Vector;
  
  
  /**
   * Default implementation for AttributeList.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>AttributeList implements the deprecated SAX1 {@link
   * org.xml.sax.AttributeList AttributeList} interface, and has been
   * replaced by the new SAX2 {@link org.xml.sax.helpers.AttributesImpl
   * AttributesImpl} interface.</p>
   *
   * <p>This class provides a convenience implementation of the SAX
   * {@link org.xml.sax.AttributeList AttributeList} interface.  This 
   * implementation is useful both for SAX parser writers, who can use 
   * it to provide attributes to the application, and for SAX application 
   * writers, who can use it to create a persistent copy of an element's 
   * attribute specifications:</p>
   *
   * <pre>
   * private AttributeList myatts;
   *
   * public void startElement (String name, AttributeList atts)
   * {
   *              // create a persistent copy of the attribute list
   *              // for use outside this method
   *   myatts = new AttributeListImpl(atts);
   *   [...]
   * }
   * </pre>
   *
   * <p>Please note that SAX parsers are not required to use this
   * class to provide an implementation of AttributeList; it is
   * supplied only as an optional convenience.  In particular, 
   * parser writers are encouraged to invent more efficient
   * implementations.</p>
   *
   * @deprecated This class implements a deprecated interface,
   *             {@link org.xml.sax.AttributeList AttributeList};
   *             that interface has been replaced by
   *             {@link org.xml.sax.Attributes Attributes},
   *             which is implemented in the
   *             {@link org.xml.sax.helpers.AttributesImpl 
   *            AttributesImpl} helper class.
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.AttributeList
   * @see org.xml.sax.DocumentHandler#startElement 
   */
  public class AttributeListImpl implements AttributeList
  {
      
      /**
       * Create an empty attribute list.
       *
       * <p>This constructor is most useful for parser writers, who
       * will use it to create a single, reusable attribute list that
       * can be reset with the clear method between elements.</p>
       *
       * @see #addAttribute
       * @see #clear
       */
      public AttributeListImpl ()
      {
      }
      
      
      /**
       * Construct a persistent copy of an existing attribute list.
       *
       * <p>This constructor is most useful for application writers,
       * who will use it to create a persistent copy of an existing
       * attribute list.</p>
       *
       * @param atts The attribute list to copy
       * @see org.xml.sax.DocumentHandler#startElement
       */
      public AttributeListImpl (AttributeList atts)
      {
  	setAttributeList(atts);
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Methods specific to this class.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Set the attribute list, discarding previous contents.
       *
       * <p>This method allows an application writer to reuse an
       * attribute list easily.</p>
       *
       * @param atts The attribute list to copy.
       */
      public void setAttributeList (AttributeList atts)
      {
  	int count = atts.getLength();
  	
  	clear();
  	
  	for (int i = 0; i < count; i++) {
  	    addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i));
  	}
      }
      
      
      /**
       * Add an attribute to an attribute list.
       *
       * <p>This method is provided for SAX parser writers, to allow them
       * to build up an attribute list incrementally before delivering
       * it to the application.</p>
       *
       * @param name The attribute name.
       * @param type The attribute type ("NMTOKEN" for an enumeration).
       * @param value The attribute value (must not be null).
       * @see #removeAttribute
       * @see org.xml.sax.DocumentHandler#startElement
       */
      public void addAttribute (String name, String type, String value)
      {
  	names.addElement(name);
  	types.addElement(type);
  	values.addElement(value);
      }
      
      
      /**
       * Remove an attribute from the list.
       *
       * <p>SAX application writers can use this method to filter an
       * attribute out of an AttributeList.  Note that invoking this
       * method will change the length of the attribute list and
       * some of the attribute's indices.</p>
       *
       * <p>If the requested attribute is not in the list, this is
       * a no-op.</p>
       *
       * @param name The attribute name.
       * @see #addAttribute
       */
      public void removeAttribute (String name)
      {
  	int i = names.indexOf(name);
  	
  	if (i >= 0) {
  	    names.removeElementAt(i);
  	    types.removeElementAt(i);
  	    values.removeElementAt(i);
  	}
      }
      
      
      /**
       * Clear the attribute list.
       *
       * <p>SAX parser writers can use this method to reset the attribute
       * list between DocumentHandler.startElement events.  Normally,
       * it will make sense to reuse the same AttributeListImpl object
       * rather than allocating a new one each time.</p>
       *
       * @see org.xml.sax.DocumentHandler#startElement
       */
      public void clear ()
      {
  	names.removeAllElements();
  	types.removeAllElements();
  	values.removeAllElements();
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.AttributeList
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Return the number of attributes in the list.
       *
       * @return The number of attributes in the list.
       * @see org.xml.sax.AttributeList#getLength
       */
      public int getLength ()
      {
  	return names.size();
      }
      
      
      /**
       * Get the name of an attribute (by position).
       *
       * @param i The position of the attribute in the list.
       * @return The attribute name as a string, or null if there
       *         is no attribute at that position.
       * @see org.xml.sax.AttributeList#getName(int)
       */
      public String getName (int i)
      {
  	if (i < 0) {
  	    return null;
  	}
  	try {
  	    return (String)names.elementAt(i);
  	} catch (ArrayIndexOutOfBoundsException e) {
  	    return null;
  	}
      }
      
      
      /**
       * Get the type of an attribute (by position).
       *
       * @param i The position of the attribute in the list.
       * @return The attribute type as a string ("NMTOKEN" for an
       *         enumeration, and "CDATA" if no declaration was
       *         read), or null if there is no attribute at
       *         that position.
       * @see org.xml.sax.AttributeList#getType(int)
       */
      public String getType (int i)
      {
  	if (i < 0) {
  	    return null;
  	}
  	try {
  	    return (String)types.elementAt(i);
  	} catch (ArrayIndexOutOfBoundsException e) {
  	    return null;
  	}
      }
      
      
      /**
       * Get the value of an attribute (by position).
       *
       * @param i The position of the attribute in the list.
       * @return The attribute value as a string, or null if
       *         there is no attribute at that position.
       * @see org.xml.sax.AttributeList#getValue(int)
       */
      public String getValue (int i)
      {
  	if (i < 0) {
  	    return null;
  	}
  	try {
  	    return (String)values.elementAt(i);
  	} catch (ArrayIndexOutOfBoundsException e) {
  	    return null;
  	}
      }
      
      
      /**
       * Get the type of an attribute (by name).
       *
       * @param name The attribute name.
       * @return The attribute type as a string ("NMTOKEN" for an
       *         enumeration, and "CDATA" if no declaration was
       *         read).
       * @see org.xml.sax.AttributeList#getType(java.lang.String)
       */
      public String getType (String name)
      {
  	return getType(names.indexOf(name));
      }
      
      
      /**
       * Get the value of an attribute (by name).
       *
       * @param name The attribute name.
       * @see org.xml.sax.AttributeList#getValue(java.lang.String)
       */
      public String getValue (String name)
      {
  	return getValue(names.indexOf(name));
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
  
      Vector names = new Vector();
      Vector types = new Vector();
      Vector values = new Vector();
  
  }
  
  // end of AttributeListImpl.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/AttributesImpl.java
  
  Index: AttributesImpl.java
  ===================================================================
  // AttributesImpl.java - default implementation of Attributes.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the public domain.
  
  // $Id: AttributesImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  
  package org.xml.sax.helpers;
  
  import org.xml.sax.Attributes;
  
  
  /**
   * Default implementation of the Attributes interface.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class provides a default implementation of the SAX2
   * {@link org.xml.sax.Attributes Attributes} interface, with the 
   * addition of manipulators so that the list can be modified or 
   * reused.</p>
   *
   * <p>There are two typical uses of this class:</p>
   *
   * <ol>
   * <li>to take a persistent snapshot of an Attributes object
   *  in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or</li>
   * <li>to construct or modify an Attributes object in a SAX2 driver or filter.</li>
   * </ol>
   *
   * <p>This class replaces the now-deprecated SAX1 {@link 
   * org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
   * class; in addition to supporting the updated Attributes
   * interface rather than the deprecated {@link org.xml.sax.AttributeList
   * AttributeList} interface, it also includes a much more efficient 
   * implementation using a single array rather than a set of Vectors.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   */
  public class AttributesImpl implements Attributes
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Constructors.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Construct a new, empty AttributesImpl object.
       */
      public AttributesImpl ()
      {
  	length = 0;
  	data = null;
      }
  
  
      /**
       * Copy an existing Attributes object.
       *
       * <p>This constructor is especially useful inside a
       * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
       *
       * @param atts The existing Attributes object.
       */
      public AttributesImpl (Attributes atts)
      {
  	setAttributes(atts);
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.Attributes.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Return the number of attributes in the list.
       *
       * @return The number of attributes in the list.
       * @see org.xml.sax.Attributes#getLength
       */
      public int getLength ()
      {
  	return length;
      }
  
  
      /**
       * Return an attribute's Namespace URI.
       *
       * @param index The attribute's index (zero-based).
       * @return The Namespace URI, the empty string if none is
       *         available, or null if the index is out of range.
       * @see org.xml.sax.Attributes#getURI
       */
      public String getURI (int index)
      {
  	if (index >= 0 && index < length) {
  	    return data[index*5];
  	} else {
  	    return null;
  	}
      }
  
  
      /**
       * Return an attribute's local name.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's local name, the empty string if 
       *         none is available, or null if the index if out of range.
       * @see org.xml.sax.Attributes#getLocalName
       */
      public String getLocalName (int index)
      {
  	if (index >= 0 && index < length) {
  	    return data[index*5+1];
  	} else {
  	    return null;
  	}
      }
  
  
      /**
       * Return an attribute's qualified (prefixed) name.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's qualified name, the empty string if 
       *         none is available, or null if the index is out of bounds.
       * @see org.xml.sax.Attributes#getQName
       */
      public String getQName (int index)
      {
  	if (index >= 0 && index < length) {
  	    return data[index*5+2];
  	} else {
  	    return null;
  	}
      }
  
  
      /**
       * Return an attribute's type by index.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's type, "CDATA" if the type is unknown, or null
       *         if the index is out of bounds.
       * @see org.xml.sax.Attributes#getType(int)
       */
      public String getType (int index)
      {
  	if (index >= 0 && index < length) {
  	    return data[index*5+3];
  	} else {
  	    return null;
  	}
      }
  
  
      /**
       * Return an attribute's value by index.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's value or null if the index is out of bounds.
       * @see org.xml.sax.Attributes#getValue(int)
       */
      public String getValue (int index)
      {
  	if (index >= 0 && index < length) {
  	    return data[index*5+4];
  	} else {
  	    return null;
  	}
      }
  
  
      /**
       * Look up an attribute's index by Namespace name.
       *
       * <p>In many cases, it will be more efficient to look up the name once and
       * use the index query methods rather than using the name query methods
       * repeatedly.</p>
       *
       * @param uri The attribute's Namespace URI, or the empty
       *        string if none is available.
       * @param localName The attribute's local name.
       * @return The attribute's index, or -1 if none matches.
       * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)
       */
      public int getIndex (String uri, String localName)
      {
  	int max = length * 5;
  	for (int i = 0; i < max; i += 5) {
  	    if (data[i].equals(uri) && data[i+1].equals(localName)) {
  		return i / 5;
  	    }
  	} 
  	return -1;
      }
  
  
      /**
       * Look up an attribute's index by qualified (prefixed) name.
       *
       * @param qName The qualified name.
       * @return The attribute's index, or -1 if none matches.
       * @see org.xml.sax.Attributes#getIndex(java.lang.String)
       */
      public int getIndex (String qName)
      {
  	int max = length * 5;
  	for (int i = 0; i < max; i += 5) {
  	    if (data[i+2].equals(qName)) {
  		return i / 5;
  	    }
  	} 
  	return -1;
      }
  
  
      /**
       * Look up an attribute's type by Namespace-qualified name.
       *
       * @param uri The Namespace URI, or the empty string for a name
       *        with no explicit Namespace URI.
       * @param localName The local name.
       * @return The attribute's type, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getType(java.lang.String,java.lang.String)
       */
      public String getType (String uri, String localName)
      {
  	int max = length * 5;
  	for (int i = 0; i < max; i += 5) {
  	    if (data[i].equals(uri) && data[i+1].equals(localName)) {
  		return data[i+3];
  	    }
  	} 
  	return null;
      }
  
  
      /**
       * Look up an attribute's type by qualified (prefixed) name.
       *
       * @param qName The qualified name.
       * @return The attribute's type, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getType(java.lang.String)
       */
      public String getType (String qName)
      {
  	int max = length * 5;
  	for (int i = 0; i < max; i += 5) {
  	    if (data[i+2].equals(qName)) {
  		return data[i+3];
  	    }
  	}
  	return null;
      }
  
  
      /**
       * Look up an attribute's value by Namespace-qualified name.
       *
       * @param uri The Namespace URI, or the empty string for a name
       *        with no explicit Namespace URI.
       * @param localName The local name.
       * @return The attribute's value, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getValue(java.lang.String,java.lang.String)
       */
      public String getValue (String uri, String localName)
      {
  	int max = length * 5;
  	for (int i = 0; i < max; i += 5) {
  	    if (data[i].equals(uri) && data[i+1].equals(localName)) {
  		return data[i+4];
  	    }
  	}
  	return null;
      }
  
  
      /**
       * Look up an attribute's value by qualified (prefixed) name.
       *
       * @param qName The qualified name.
       * @return The attribute's value, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getValue(java.lang.String)
       */
      public String getValue (String qName)
      {
  	int max = length * 5;
  	for (int i = 0; i < max; i += 5) {
  	    if (data[i+2].equals(qName)) {
  		return data[i+4];
  	    }
  	}
  	return null;
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Manipulators.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Clear the attribute list for reuse.
       *
       * <p>Note that no memory is actually freed by this call:
       * the current arrays are kept so that they can be 
       * reused.</p>
       */
      public void clear ()
      {
  	length = 0;
      }
  
  
      /**
       * Copy an entire Attributes object.
       *
       * <p>It may be more efficient to reuse an existing object
       * rather than constantly allocating new ones.</p>
       * 
       * @param atts The attributes to copy.
       */
      public void setAttributes (Attributes atts)
      {
  	clear();
  	length = atts.getLength();
  	data = new String[length*5]; 
  	for (int i = 0; i < length; i++) {
  	    data[i*5] = atts.getURI(i);
  	    data[i*5+1] = atts.getLocalName(i);
  	    data[i*5+2] = atts.getQName(i);
  	    data[i*5+3] = atts.getType(i);
  	    data[i*5+4] = atts.getValue(i);
  	}
      }
  
  
      /**
       * Add an attribute to the end of the list.
       *
       * <p>For the sake of speed, this method does no checking
       * to see if the attribute is already in the list: that is
       * the responsibility of the application.</p>
       *
       * @param uri The Namespace URI, or the empty string if
       *        none is available or Namespace processing is not
       *        being performed.
       * @param localName The local name, or the empty string if
       *        Namespace processing is not being performed.
       * @param qName The qualified (prefixed) name, or the empty string
       *        if qualified names are not available.
       * @param type The attribute type as a string.
       * @param value The attribute value.
       */
      public void addAttribute (String uri, String localName, String qName,
  			      String type, String value)
      {
  	ensureCapacity(length+1);
  	data[length*5] = uri;
  	data[length*5+1] = localName;
  	data[length*5+2] = qName;
  	data[length*5+3] = type;
  	data[length*5+4] = value;
  	length++;
      }
  
  
      /**
       * Set an attribute in the list.
       *
       * <p>For the sake of speed, this method does no checking
       * for name conflicts or well-formedness: such checks are the
       * responsibility of the application.</p>
       *
       * @param index The index of the attribute (zero-based).
       * @param uri The Namespace URI, or the empty string if
       *        none is available or Namespace processing is not
       *        being performed.
       * @param localName The local name, or the empty string if
       *        Namespace processing is not being performed.
       * @param qName The qualified name, or the empty string
       *        if qualified names are not available.
       * @param type The attribute type as a string.
       * @param value The attribute value.
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void setAttribute (int index, String uri, String localName,
  			      String qName, String type, String value)
      {
  	if (index >= 0 && index < length) {
  	    data[index*5] = uri;
  	    data[index*5+1] = localName;
  	    data[index*5+2] = qName;
  	    data[index*5+3] = type;
  	    data[index*5+4] = value;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
      /**
       * Remove an attribute from the list.
       *
       * @param index The index of the attribute (zero-based).
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void removeAttribute (int index)
      {
  	if (index >= 0 && index < length) {
  	    data[index] = null;
  	    if (index < length - 1) {
  		System.arraycopy(data, (index+1)*5, data, index*5,
  				 (length-index)*5);
  	    }
  	    length--;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
      /**
       * Set the Namespace URI of a specific attribute.
       *
       * @param index The index of the attribute (zero-based).
       * @param uri The attribute's Namespace URI, or the empty
       *        string for none.
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void setURI (int index, String uri)
      {
  	if (index >= 0 && index < length) {
  	    data[index*5] = uri;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
      /**
       * Set the local name of a specific attribute.
       *
       * @param index The index of the attribute (zero-based).
       * @param localName The attribute's local name, or the empty
       *        string for none.
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void setLocalName (int index, String localName)
      {
  	if (index >= 0 && index < length) {
  	    data[index*5+1] = localName;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
      /**
       * Set the qualified name of a specific attribute.
       *
       * @param index The index of the attribute (zero-based).
       * @param qName The attribute's qualified name, or the empty
       *        string for none.
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void setQName (int index, String qName)
      {
  	if (index >= 0 && index < length) {
  	    data[index*5+2] = qName;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
      /**
       * Set the type of a specific attribute.
       *
       * @param index The index of the attribute (zero-based).
       * @param type The attribute's type.
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void setType (int index, String type)
      {
  	if (index >= 0 && index < length) {
  	    data[index*5+3] = type;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
      /**
       * Set the value of a specific attribute.
       *
       * @param index The index of the attribute (zero-based).
       * @param value The attribute's value.
       * @exception java.lang.ArrayIndexOutOfBoundsException When the
       *            supplied index does not point to an attribute
       *            in the list.
       */
      public void setValue (int index, String value)
      {
  	if (index >= 0 && index < length) {
  	    data[index*5+4] = value;
  	} else {
  	    badIndex(index);
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal methods.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Ensure the internal array's capacity.
       *
       * @param n The minimum number of attributes that the array must
       *        be able to hold.
       */
      private void ensureCapacity (int n)
      {
  	if (n > 0 && data == null) {
  	    data = new String[25];
  	}
  
  	int max = data.length;
  	if (max >= n * 5) {
  	    return;
  	}
  
  
  	while (max < n * 5) {
  	    max *= 2;
  	}
  	String newData[] = new String[max];
  	System.arraycopy(data, 0, newData, 0, length*5);
  	data = newData;
      }
  
  
      /**
       * Report a bad array index in a manipulator.
       *
       * @param index The index to report.
       * @exception java.lang.ArrayIndexOutOfBoundsException Always.
       */
      private void badIndex (int index)
  	throws ArrayIndexOutOfBoundsException
      {
  	String msg =
  	    "Attempt to modify attribute at illegal index: " + index;
  	throw new ArrayIndexOutOfBoundsException(msg);
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
  
      int length;
      String data [];
  
  }
  
  // end of AttributesImpl.java
  
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/DefaultHandler.java
  
  Index: DefaultHandler.java
  ===================================================================
  // DefaultHandler.java - default implementation of the core handlers.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the public domain.
  
  // $Id: DefaultHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import org.xml.sax.InputSource;
  import org.xml.sax.Locator;
  import org.xml.sax.Attributes;
  import org.xml.sax.EntityResolver;
  import org.xml.sax.DTDHandler;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  
  
  /**
   * Default base class for SAX2 event handlers.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class is available as a convenience base class for SAX2
   * applications: it provides default implementations for all of the
   * callbacks in the four core SAX2 handler classes:</p>
   *
   * <ul>
   * <li>{@link org.xml.sax.EntityResolver EntityResolver}</li>
   * <li>{@link org.xml.sax.DTDHandler DTDHandler}</li>
   * <li>{@link org.xml.sax.ContentHandler ContentHandler}</li>
   * <li>{@link org.xml.sax.ErrorHandler ErrorHandler}</li>
   * </ul>
   *
   * <p>Application writers can extend this class when they need to
   * implement only part of an interface; parser writers can
   * instantiate this class to provide default handlers when the
   * application has not supplied its own.</p>
   *
   * <p>This class replaces the deprecated SAX1
   * {@link org.xml.sax.HandlerBase HandlerBase} class.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.EntityResolver
   * @see org.xml.sax.DTDHandler
   * @see org.xml.sax.ContentHandler
   * @see org.xml.sax.ErrorHandler
   */
  public class DefaultHandler
      implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  {
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of the EntityResolver interface.
      ////////////////////////////////////////////////////////////////////
      
      /**
       * Resolve an external entity.
       *
       * <p>Always return null, so that the parser will use the system
       * identifier provided in the XML document.  This method implements
       * the SAX default behaviour: application writers can override it
       * in a subclass to do special translations such as catalog lookups
       * or URI redirection.</p>
       *
       * @param publicId The public identifer, or null if none is
       *                 available.
       * @param systemId The system identifier provided in the XML 
       *                 document.
       * @return The new input source, or null to require the
       *         default behaviour.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.EntityResolver#resolveEntity
       */
      public InputSource resolveEntity (String publicId, String systemId)
  	throws SAXException
      {
  	return null;
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of DTDHandler interface.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Receive notification of a notation declaration.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass if they wish to keep track of the notations
       * declared in a document.</p>
       *
       * @param name The notation name.
       * @param publicId The notation public identifier, or null if not
       *                 available.
       * @param systemId The notation system identifier.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DTDHandler#notationDecl
       */
      public void notationDecl (String name, String publicId, String systemId)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of an unparsed entity declaration.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to keep track of the unparsed entities
       * declared in a document.</p>
       *
       * @param name The entity name.
       * @param publicId The entity public identifier, or null if not
       *                 available.
       * @param systemId The entity system identifier.
       * @param notationName The name of the associated notation.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.DTDHandler#unparsedEntityDecl
       */
      public void unparsedEntityDecl (String name, String publicId,
  				    String systemId, String notationName)
  	throws SAXException
      {
  	// no op
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of ContentHandler interface.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Receive a Locator object for document events.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass if they wish to store the locator for use
       * with other document events.</p>
       *
       * @param locator A locator for all SAX document events.
       * @see org.xml.sax.ContentHandler#setDocumentLocator
       * @see org.xml.sax.Locator
       */
      public void setDocumentLocator (Locator locator)
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the beginning of the document.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the beginning
       * of a document (such as allocating the root node of a tree or
       * creating an output file).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#startDocument
       */
      public void startDocument ()
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the end of the document.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the end
       * of a document (such as finalising a tree or closing an output
       * file).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#endDocument
       */
      public void endDocument ()
  	throws SAXException
      {
  	// no op
      }
  
  
      /**
       * Receive notification of the start of a Namespace mapping.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the start of
       * each Namespace prefix scope (such as storing the prefix mapping).</p>
       *
       * @param prefix The Namespace prefix being declared.
       * @param uri The Namespace URI mapped to the prefix.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#startPrefixMapping
       */
      public void startPrefixMapping (String prefix, String uri)
  	throws SAXException
      {
  	// no op
      }
  
  
      /**
       * Receive notification of the end of a Namespace mapping.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the end of
       * each prefix mapping.</p>
       *
       * @param prefix The Namespace prefix being declared.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#endPrefixMapping
       */
      public void endPrefixMapping (String prefix)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the start of an element.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the start of
       * each element (such as allocating a new tree node or writing
       * output to a file).</p>
       *
       * @param name The element type name.
       * @param attributes The specified or defaulted attributes.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#startElement
       */
      public void startElement (String uri, String localName,
  			      String qName, Attributes attributes)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of the end of an element.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions at the end of
       * each element (such as finalising a tree node or writing
       * output to a file).</p>
       *
       * @param name The element type name.
       * @param attributes The specified or defaulted attributes.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#endElement
       */
      public void endElement (String uri, String localName, String qName)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of character data inside an element.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method to take specific actions for each chunk of character data
       * (such as adding the data to a node or buffer, or printing it to
       * a file).</p>
       *
       * @param ch The characters.
       * @param start The start position in the character array.
       * @param length The number of characters to use from the
       *               character array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#characters
       */
      public void characters (char ch[], int start, int length)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of ignorable whitespace in element content.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method to take specific actions for each chunk of ignorable
       * whitespace (such as adding data to a node or buffer, or printing
       * it to a file).</p>
       *
       * @param ch The whitespace characters.
       * @param start The start position in the character array.
       * @param length The number of characters to use from the
       *               character array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#ignorableWhitespace
       */
      public void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of a processing instruction.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions for each
       * processing instruction, such as setting status variables or
       * invoking other methods.</p>
       *
       * @param target The processing instruction target.
       * @param data The processing instruction data, or null if
       *             none is supplied.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#processingInstruction
       */
      public void processingInstruction (String target, String data)
  	throws SAXException
      {
  	// no op
      }
  
  
      /**
       * Receive notification of a skipped entity.
       *
       * <p>By default, do nothing.  Application writers may override this
       * method in a subclass to take specific actions for each
       * processing instruction, such as setting status variables or
       * invoking other methods.</p>
       *
       * @param name The name of the skipped entity.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ContentHandler#processingInstruction
       */
      public void skippedEntity (String name)
  	throws SAXException
      {
  	// no op
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Default implementation of the ErrorHandler interface.
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Receive notification of a parser warning.
       *
       * <p>The default implementation does nothing.  Application writers
       * may override this method in a subclass to take specific actions
       * for each warning, such as inserting the message in a log file or
       * printing it to the console.</p>
       *
       * @param e The warning information encoded as an exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ErrorHandler#warning
       * @see org.xml.sax.SAXParseException
       */
      public void warning (SAXParseException e)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Receive notification of a recoverable parser error.
       *
       * <p>The default implementation does nothing.  Application writers
       * may override this method in a subclass to take specific actions
       * for each error, such as inserting the message in a log file or
       * printing it to the console.</p>
       *
       * @param e The warning information encoded as an exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ErrorHandler#warning
       * @see org.xml.sax.SAXParseException
       */
      public void error (SAXParseException e)
  	throws SAXException
      {
  	// no op
      }
      
      
      /**
       * Report a fatal XML parsing error.
       *
       * <p>The default implementation throws a SAXParseException.
       * Application writers may override this method in a subclass if
       * they need to take specific actions for each fatal error (such as
       * collecting all of the errors into a single report): in any case,
       * the application must stop all regular processing when this
       * method is invoked, since the document is no longer reliable, and
       * the parser may no longer report parsing events.</p>
       *
       * @param e The error information encoded as an exception.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see org.xml.sax.ErrorHandler#fatalError
       * @see org.xml.sax.SAXParseException
       */
      public void fatalError (SAXParseException e)
  	throws SAXException
      {
  	throw e;
      }
      
  }
  
  // end of DefaultHandler.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/LocatorImpl.java
  
  Index: LocatorImpl.java
  ===================================================================
  // SAX default implementation for Locator.
  // No warranty; no copyright -- use this as you will.
  // $Id: LocatorImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import org.xml.sax.Locator;
  
  
  /**
   * Provide an optional convenience implementation of Locator.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class is available mainly for application writers, who
   * can use it to make a persistent snapshot of a locator at any
   * point during a document parse:</p>
   *
   * <pre>
   * Locator locator;
   * Locator startloc;
   *
   * public void setLocator (Locator locator)
   * {
   *         // note the locator
   *   this.locator = locator;
   * }
   *
   * public void startDocument ()
   * {
   *         // save the location of the start of the document
   *         // for future use.
   *   Locator startloc = new LocatorImpl(locator);
   * }
   *</pre>
   *
   * <p>Normally, parser writers will not use this class, since it
   * is more efficient to provide location information only when
   * requested, rather than constantly updating a Locator object.</p>
   *
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Locator Locator
   */
  public class LocatorImpl implements Locator
  {
      
      
      /**
       * Zero-argument constructor.
       *
       * <p>This will not normally be useful, since the main purpose
       * of this class is to make a snapshot of an existing Locator.</p>
       */
      public LocatorImpl ()
      {
      }
      
      
      /**
       * Copy constructor.
       *
       * <p>Create a persistent copy of the current state of a locator.
       * When the original locator changes, this copy will still keep
       * the original values (and it can be used outside the scope of
       * DocumentHandler methods).</p>
       *
       * @param locator The locator to copy.
       */
      public LocatorImpl (Locator locator)
      {
  	setPublicId(locator.getPublicId());
  	setSystemId(locator.getSystemId());
  	setLineNumber(locator.getLineNumber());
  	setColumnNumber(locator.getColumnNumber());
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.Locator
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Return the saved public identifier.
       *
       * @return The public identifier as a string, or null if none
       *         is available.
       * @see org.xml.sax.Locator#getPublicId
       * @see #setPublicId
       */
      public String getPublicId ()
      {
  	return publicId;
      }
      
      
      /**
       * Return the saved system identifier.
       *
       * @return The system identifier as a string, or null if none
       *         is available.
       * @see org.xml.sax.Locator#getSystemId
       * @see #setSystemId
       */
      public String getSystemId ()
      {
  	return systemId;
      }
      
      
      /**
       * Return the saved line number (1-based).
       *
       * @return The line number as an integer, or -1 if none is available.
       * @see org.xml.sax.Locator#getLineNumber
       * @see #setLineNumber
       */
      public int getLineNumber ()
      {
  	return lineNumber;
      }
      
      
      /**
       * Return the saved column number (1-based).
       *
       * @return The column number as an integer, or -1 if none is available.
       * @see org.xml.sax.Locator#getColumnNumber
       * @see #setColumnNumber
       */
      public int getColumnNumber ()
      {
  	return columnNumber;
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Setters for the properties (not in org.xml.sax.Locator)
      ////////////////////////////////////////////////////////////////////
      
      
      /**
       * Set the public identifier for this locator.
       *
       * @param publicId The new public identifier, or null 
       *        if none is available.
       * @see #getPublicId
       */
      public void setPublicId (String publicId)
      {
  	this.publicId = publicId;
      }
      
      
      /**
       * Set the system identifier for this locator.
       *
       * @param systemId The new system identifier, or null 
       *        if none is available.
       * @see #getSystemId
       */
      public void setSystemId (String systemId)
      {
  	this.systemId = systemId;
      }
      
      
      /**
       * Set the line number for this locator (1-based).
       *
       * @param lineNumber The line number, or -1 if none is available.
       * @see #getLineNumber
       */
      public void setLineNumber (int lineNumber)
      {
  	this.lineNumber = lineNumber;
      }
      
      
      /**
       * Set the column number for this locator (1-based).
       *
       * @param columnNumber The column number, or -1 if none is available.
       * @see #getColumnNumber
       */
      public void setColumnNumber (int columnNumber)
      {
  	this.columnNumber = columnNumber;
      }
      
      
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
      
      private String publicId;
      private String systemId;
      private int lineNumber;
      private int columnNumber;
      
  }
  
  // end of LocatorImpl.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/NamespaceSupport.java
  
  Index: NamespaceSupport.java
  ===================================================================
  // NamespaceSupport.java - generic Namespace support for SAX.
  // Written by David Megginson, sax@megginson.com
  // This class is in the Public Domain.  NO WARRANTY!
  
  // $Id: NamespaceSupport.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import java.util.EmptyStackException;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Vector;
  
  
  /**
   * Encapsulate Namespace logic for use by SAX drivers.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class encapsulates the logic of Namespace processing:
   * it tracks the declarations currently in force for each context
   * and automatically processes qualified XML 1.0 names into their
   * Namespace parts; it can also be used in reverse for generating
   * XML 1.0 from Namespaces.</p>
   *
   * <p>Namespace support objects are reusable, but the reset method
   * must be invoked between each session.</p>
   *
   * <p>Here is a simple session:</p>
   *
   * <pre>
   * String parts[] = new String[3];
   * NamespaceSupport support = new NamespaceSupport();
   *
   * support.pushContext();
   * support.declarePrefix("", "http://www.w3.org/1999/xhtml");
   * support.declarePrefix("dc", "http://www.purl.org/dc#");
   *
   * String parts[] = support.processName("p", parts, false);
   * System.out.println("Namespace URI: " + parts[0]);
   * System.out.println("Local name: " + parts[1]);
   * System.out.println("Raw name: " + parts[2]);
  
   * String parts[] = support.processName("dc:title", parts, false);
   * System.out.println("Namespace URI: " + parts[0]);
   * System.out.println("Local name: " + parts[1]);
   * System.out.println("Raw name: " + parts[2]);
  
   * support.popContext();
   * </pre>
   *
   * <p>Note that this class is optimized for the use case where most
   * elements do not contain Namespace declarations: if the same
   * prefix/URI mapping is repeated for each context (for example), this
   * class will be somewhat less efficient.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   */
  public class NamespaceSupport
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Constants.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * The XML Namespace as a constant.
       *
       * <p>This is the Namespace URI that is automatically mapped
       * to the "xml" prefix.</p>
       */
      public final static String XMLNS =
  	"http://www.w3.org/XML/1998/namespace";
  
  
      /**
       * An empty enumeration.
       */
      private final static Enumeration EMPTY_ENUMERATION =
  	new Vector().elements();
  
  
      ////////////////////////////////////////////////////////////////////
      // Constructor.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Create a new Namespace support object.
       */
      public NamespaceSupport ()
      {
  	reset();
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Context management.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Reset this Namespace support object for reuse.
       *
       * <p>It is necessary to invoke this method before reusing the
       * Namespace support object for a new session.</p>
       */
      public void reset ()
      {
  	contexts = new Context[32];
  	contextPos = 0;
  	contexts[contextPos] = currentContext = new Context();
  	currentContext.declarePrefix("xml", XMLNS);
      }
  
  
      /**
       * Start a new Namespace context.
       *
       * <p>Normally, you should push a new context at the beginning
       * of each XML element: the new context will automatically inherit
       * the declarations of its parent context, but it will also keep
       * track of which declarations were made within this context.</p>
       *
       * <p>The Namespace support object always starts with a base context
       * already in force: in this context, only the "xml" prefix is
       * declared.</p>
       *
       * @see #popContext
       */
      public void pushContext ()
      {
  	int max = contexts.length;
  	contextPos++;
  
  				// Extend the array if necessary
  	if (contextPos >= max) {
  	    Context newContexts[] = new Context[max*2];
  	    System.arraycopy(contexts, 0, newContexts, 0, max);
  	    max *= 2;
  	    contexts = newContexts;
  	}
  
  				// Allocate the context if necessary.
  	currentContext = contexts[contextPos];
  	if (currentContext == null) {
  	    contexts[contextPos] = currentContext = new Context();
  	}
  
  				// Set the parent, if any.
  	if (contextPos > 0) {
  	    currentContext.setParent(contexts[contextPos - 1]);
  	}
      }
  
  
      /**
       * Revert to the previous Namespace context.
       *
       * <p>Normally, you should pop the context at the end of each
       * XML element.  After popping the context, all Namespace prefix
       * mappings that were previously in force are restored.</p>
       *
       * <p>You must not attempt to declare additional Namespace
       * prefixes after popping a context, unless you push another
       * context first.</p>
       *
       * @see #pushContext
       */
      public void popContext ()
      {
  	contextPos--;
  	if (contextPos < 0) {
  	    throw new EmptyStackException();
  	}
  	currentContext = contexts[contextPos];
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Operations within a context.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Declare a Namespace prefix.
       *
       * <p>This method declares a prefix in the current Namespace
       * context; the prefix will remain in force until this context
       * is popped, unless it is shadowed in a descendant context.</p>
       *
       * <p>To declare a default Namespace, use the empty string.  The
       * prefix must not be "xml" or "xmlns".</p>
       *
       * <p>Note that you must <em>not</em> declare a prefix after
       * you've pushed and popped another Namespace.</p>
       *
       * <p>Note that there is an asymmetry in this library: while {@link
       * #getPrefix getPrefix} will not return the default "" prefix,
       * even if you have declared one; to check for a default prefix,
       * you have to look it up explicitly using {@link #getURI getURI}.
       * This asymmetry exists to make it easier to look up prefixes
       * for attribute names, where the default prefix is not allowed.</p>
       *
       * @param prefix The prefix to declare, or null for the empty
       *        string.
       * @param uri The Namespace URI to associate with the prefix.
       * @return true if the prefix was legal, false otherwise
       * @see #processName
       * @see #getURI
       * @see #getPrefix
       */
      public boolean declarePrefix (String prefix, String uri)
      {
  	if (prefix.equals("xml") || prefix.equals("xmlns")) {
  	    return false;
  	} else {
  	    currentContext.declarePrefix(prefix, uri);
  	    return true;
  	}
      }
  
  
      /**
       * Process a raw XML 1.0 name.
       *
       * <p>This method processes a raw XML 1.0 name in the current
       * context by removing the prefix and looking it up among the
       * prefixes currently declared.  The return value will be the
       * array supplied by the caller, filled in as follows:</p>
       *
       * <dl>
       * <dt>parts[0]</dt>
       * <dd>The Namespace URI, or an empty string if none is
       *  in use.</dd>
       * <dt>parts[1]</dt>
       * <dd>The local name (without prefix).</dd>
       * <dt>parts[2]</dt>
       * <dd>The original raw name.</dd>
       * </dl>
       *
       * <p>All of the strings in the array will be internalized.  If
       * the raw name has a prefix that has not been declared, then
       * the return value will be null.</p>
       *
       * <p>Note that attribute names are processed differently than
       * element names: an unprefixed element name will received the
       * default Namespace (if any), while an unprefixed element name
       * will not.</p>
       *
       * @param qName The raw XML 1.0 name to be processed.
       * @param parts An array supplied by the caller, capable of
       *        holding at least three members.
       * @param isAttribute A flag indicating whether this is an
       *        attribute name (true) or an element name (false).
       * @return The supplied array holding three internalized strings 
       *        representing the Namespace URI (or empty string), the
       *        local name, and the raw XML 1.0 name; or null if there
       *        is an undeclared prefix.
       * @see #declarePrefix
       * @see java.lang.String#intern */
      public String [] processName (String qName, String parts[],
  				  boolean isAttribute)
      {
  	String myParts[] = currentContext.processName(qName, isAttribute);
  	if (myParts == null) {
  	    return null;
  	} else {
  	    parts[0] = myParts[0];
  	    parts[1] = myParts[1];
  	    parts[2] = myParts[2];
  	    return parts;
  	}
      }
  
  
      /**
       * Look up a prefix and get the currently-mapped Namespace URI.
       *
       * <p>This method looks up the prefix in the current context.
       * Use the empty string ("") for the default Namespace.</p>
       *
       * @param prefix The prefix to look up.
       * @return The associated Namespace URI, or null if the prefix
       *         is undeclared in this context.
       * @see #getPrefix
       * @see #getPrefixes
       */
      public String getURI (String prefix)
      {
  	return currentContext.getURI(prefix);
      }
  
  
      /**
       * Return an enumeration of all prefixes currently declared.
       *
       * <p><strong>Note:</strong> if there is a default prefix, it will not be
       * returned in this enumeration; check for the default prefix
       * using the {@link #getURI getURI} with an argument of "".</p>
       *
       * @return An enumeration of all prefixes declared in the
       *         current context except for the empty (default)
       *         prefix.
       * @see #getDeclaredPrefixes
       * @see #getURI
       */
      public Enumeration getPrefixes ()
      {
  	return currentContext.getPrefixes();
      }
  
  
      /**
       * Return one of the prefixes mapped to a Namespace URI.
       *
       * <p>If more than one prefix is currently mapped to the same
       * URI, this method will make an arbitrary selection; if you
       * want all of the prefixes, use the {@link #getPrefixes}
       * method instead.</p>
       *
       * <p><strong>Note:</strong> this will never return the empty (default) prefix;
       * to check for a default prefix, use the {@link #getURI getURI}
       * method with an argument of "".</p>
       *
       * @param uri The Namespace URI.
       * @param isAttribute true if this prefix is for an attribute
       *        (and the default Namespace is not allowed).
       * @return One of the prefixes currently mapped to the URI supplied,
       *         or null if none is mapped or if the URI is assigned to
       *         the default Namespace.
       * @see #getPrefixes(java.lang.String)
       * @see #getURI
       */
      public String getPrefix (String uri)
      {
  	return currentContext.getPrefix(uri);
      }
  
  
      /**
       * Return an enumeration of all prefixes currently declared for a URI.
       *
       * <p>This method returns prefixes mapped to a specific Namespace
       * URI.  The xml: prefix will be included.  If you want only one
       * prefix that's mapped to the Namespace URI, and you don't care 
       * which one you get, use the {@link #getPrefix getPrefix}
       *  method instead.</p>
       *
       * <p><strong>Note:</strong> the empty (default) prefix is <em>never</em> included
       * in this enumeration; to check for the presence of a default
       * Namespace, use the {@link #getURI getURI} method with an
       * argument of "".</p>
       *
       * @param uri The Namespace URI.
       * @return An enumeration of all prefixes declared in the
       *         current context.
       * @see #getPrefix
       * @see #getDeclaredPrefixes
       * @see #getURI
       */
      public Enumeration getPrefixes (String uri)
      {
  	Vector prefixes = new Vector();
  	Enumeration allPrefixes = getPrefixes();
  	while (allPrefixes.hasMoreElements()) {
  	    String prefix = (String)allPrefixes.nextElement();
  	    if (uri.equals(getURI(prefix))) {
  		prefixes.addElement(prefix);
  	    }
  	}
  	return prefixes.elements();
      }
  
  
      /**
       * Return an enumeration of all prefixes declared in this context.
       *
       * <p>The empty (default) prefix will be included in this 
       * enumeration; note that this behaviour differs from that of
       * {@link #getPrefix} and {@link #getPrefixes}.</p>
       *
       * @return An enumeration of all prefixes declared in this
       *         context.
       * @see #getPrefixes
       * @see #getURI
       */
      public Enumeration getDeclaredPrefixes ()
      {
  	return currentContext.getDeclaredPrefixes();
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
  
      private Context contexts[];
      private Context currentContext;
      private int contextPos;
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal classes.
      ////////////////////////////////////////////////////////////////////
  
      /**
       * Internal class for a single Namespace context.
       *
       * <p>This module caches and reuses Namespace contexts, so the number allocated
       * will be equal to the element depth of the document, not to the total
       * number of elements (i.e. 5-10 rather than tens of thousands).</p>
       */
      final class Context {
  
  	/**
  	 * Create the root-level Namespace context.
  	 */
  	Context ()
  	{
  	    copyTables();
  	}
  	
  	
  	/**
  	 * (Re)set the parent of this Namespace context.
  	 *
  	 * @param context The parent Namespace context object.
  	 */
  	void setParent (Context parent)
  	{
  	    this.parent = parent;
  	    declarations = null;
  	    prefixTable = parent.prefixTable;
  	    uriTable = parent.uriTable;
  	    elementNameTable = parent.elementNameTable;
  	    attributeNameTable = parent.attributeNameTable;
  	    defaultNS = parent.defaultNS;
  	    tablesDirty = false;
  	}
  	
  	
  	/**
  	 * Declare a Namespace prefix for this context.
  	 *
  	 * @param prefix The prefix to declare.
  	 * @param uri The associated Namespace URI.
  	 * @see org.xml.sax.helpers.NamespaceSupport#declarePrefix
  	 */
  	void declarePrefix (String prefix, String uri)
  	{
  				// Lazy processing...
  	    if (!tablesDirty) {
  		copyTables();
  	    }
  	    if (declarations == null) {
  		declarations = new Vector();
  	    }
  	    
  	    prefix = prefix.intern();
  	    uri = uri.intern();
  	    if ("".equals(prefix)) {
  		if ("".equals(uri)) {
  		    defaultNS = null;
  		} else {
  		    defaultNS = uri;
  		}
  	    } else {
  		prefixTable.put(prefix, uri);
  		uriTable.put(uri, prefix); // may wipe out another prefix
  	    }
  	    declarations.addElement(prefix);
  	}
  
  
  	/**
  	 * Process a raw XML 1.0 name in this context.
  	 *
  	 * @param qName The raw XML 1.0 name.
  	 * @param isAttribute true if this is an attribute name.
  	 * @return An array of three strings containing the
  	 *         URI part (or empty string), the local part,
  	 *         and the raw name, all internalized, or null
  	 *         if there is an undeclared prefix.
  	 * @see org.xml.sax.helpers.NamespaceSupport#processName
  	 */
  	String [] processName (String qName, boolean isAttribute)
  	{
  	    String name[];
  	    Hashtable table;
  	    
  				// Select the appropriate table.
  	    if (isAttribute) {
  		table = elementNameTable;
  	    } else {
  		table = attributeNameTable;
  	    }
  	    
  				// Start by looking in the cache, and
  				// return immediately if the name
  				// is already known in this content
  	    name = (String[])table.get(qName);
  	    if (name != null) {
  		return name;
  	    }
  	    
  				// We haven't seen this name in this
  				// context before.
  	    name = new String[3];
  	    int index = qName.indexOf(':');
  	    
  	    
  				// No prefix.
  	    if (index == -1) {
  		if (isAttribute || defaultNS == null) {
  		    name[0] = "";
  		} else {
  		    name[0] = defaultNS;
  		}
  		name[1] = qName.intern();
  		name[2] = name[1];
  	    }
  	    
  				// Prefix
  	    else {
  		String prefix = qName.substring(0, index);
  		String local = qName.substring(index+1);
  		String uri;
  		if ("".equals(prefix)) {
  		    uri = defaultNS;
  		} else {
  		    uri = (String)prefixTable.get(prefix);
  		}
  		if (uri == null) {
  		    return null;
  		}
  		name[0] = uri;
  		name[1] = local.intern();
  		name[2] = qName.intern();
  	    }
  	    
  				// Save in the cache for future use.
  	    table.put(name[2], name);
  	    tablesDirty = true;
  	    return name;
  	}
  	
  
  	/**
  	 * Look up the URI associated with a prefix in this context.
  	 *
  	 * @param prefix The prefix to look up.
  	 * @return The associated Namespace URI, or null if none is
  	 *         declared.	
  	 * @see org.xml.sax.helpers.NamespaceSupport#getURI
  	 */
  	String getURI (String prefix)
  	{
  	    if ("".equals(prefix)) {
  		return defaultNS;
  	    } else if (prefixTable == null) {
  		return null;
  	    } else {
  		return (String)prefixTable.get(prefix);
  	    }
  	}
  
  
  	/**
  	 * Look up one of the prefixes associated with a URI in this context.
  	 *
  	 * <p>Since many prefixes may be mapped to the same URI,
  	 * the return value may be unreliable.</p>
  	 *
  	 * @param uri The URI to look up.
  	 * @return The associated prefix, or null if none is declared.
  	 * @see org.xml.sax.helpers.NamespaceSupport#getPrefix
  	 */
  	String getPrefix (String uri)
  	{
  	    if (uriTable == null) {
  		return null;
  	    } else {
  		return (String)uriTable.get(uri);
  	    }
  	}
  	
  	
  	/**
  	 * Return an enumeration of prefixes declared in this context.
  	 *
  	 * @return An enumeration of prefixes (possibly empty).
  	 * @see org.xml.sax.helpers.NamespaceSupport#getDeclaredPrefixes
  	 */
  	Enumeration getDeclaredPrefixes ()
  	{
  	    if (declarations == null) {
  		return EMPTY_ENUMERATION;
  	    } else {
  		return declarations.elements();
  	    }
  	}
  	
  	
  	/**
  	 * Return an enumeration of all prefixes currently in force.
  	 *
  	 * <p>The default prefix, if in force, is <em>not</em>
  	 * returned, and will have to be checked for separately.</p>
  	 *
  	 * @return An enumeration of prefixes (never empty).
  	 * @see org.xml.sax.helpers.NamespaceSupport#getPrefixes
  	 */
  	Enumeration getPrefixes ()
  	{
  	    if (prefixTable == null) {
  		return EMPTY_ENUMERATION;
  	    } else {
  		return prefixTable.keys();
  	    }
  	}
  	
  	
  
  	////////////////////////////////////////////////////////////////
  	// Internal methods.
  	////////////////////////////////////////////////////////////////
  
  
  	/**
  	 * Copy on write for the internal tables in this context.
  	 *
  	 * <p>This class is optimized for the normal case where most
  	 * elements do not contain Namespace declarations.</p>
  	 */	
  	private void copyTables ()
  	{
  	    if (prefixTable != null) {
  		prefixTable = (Hashtable)prefixTable.clone();
  	    } else {
  		prefixTable = new Hashtable();
  	    }
  	    if (uriTable != null) {
  		uriTable = (Hashtable)uriTable.clone();
  	    } else {
  		uriTable = new Hashtable();
  	    }
  	    elementNameTable = new Hashtable();
  	    attributeNameTable = new Hashtable();
  	    tablesDirty = true;
  	}
  
  
  
  	////////////////////////////////////////////////////////////////
  	// Protected state.
  	////////////////////////////////////////////////////////////////
  	
  	Hashtable prefixTable;
  	Hashtable uriTable;
  	Hashtable elementNameTable;
  	Hashtable attributeNameTable;
  	String defaultNS = null;
  	
  
  
  	////////////////////////////////////////////////////////////////
  	// Internal state.
  	////////////////////////////////////////////////////////////////
  	
  	private Vector declarations = null;
  	private boolean tablesDirty = false;
  	private Context parent = null;
      }
  }
  
  // end of NamespaceSupport.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/ParserAdapter.java
  
  Index: ParserAdapter.java
  ===================================================================
  // ParserAdapter.java - adapt a SAX1 Parser to a SAX2 XMLReader.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the public domain.
  
  // $Id: ParserAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import java.io.IOException;
  import java.util.Enumeration;
  
  import org.xml.sax.Parser;	// deprecated
  import org.xml.sax.InputSource;
  import org.xml.sax.Locator;
  import org.xml.sax.AttributeList; // deprecated
  import org.xml.sax.EntityResolver;
  import org.xml.sax.DTDHandler;
  import org.xml.sax.DocumentHandler; // deprecated
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  
  import org.xml.sax.XMLReader;
  import org.xml.sax.Attributes;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXNotRecognizedException;
  import org.xml.sax.SAXNotSupportedException;
  
  
  /**
   * Adapt a SAX1 Parser as a SAX2 XMLReader.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class wraps a SAX1 {@link org.xml.sax.Parser Parser}
   * and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader},
   * with feature, property, and Namespace support.  Note
   * that it is not possible to report {@link org.xml.sax.ContentHandler#skippedEntity
   * skippedEntity} events, since SAX1 does not make that information available.</p>
   *
   * <p>This adapter does not test for duplicate Namespace-qualified
   * attribute names.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.helpers.XMLReaderAdapter
   * @see org.xml.sax.XMLReader
   * @see org.xml.sax.Parser
   */
  public class ParserAdapter implements XMLReader, DocumentHandler
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Constructors.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Construct a new parser adapter.
       *
       * <p>Use the "org.xml.sax.parser" property to locate the
       * embedded SAX1 driver.</p>
       *
       * @exception org.xml.sax.SAXException If the embedded driver
       *            cannot be instantiated or if the
       *            org.xml.sax.parser property is not specified.
       */
      public ParserAdapter ()
        throws SAXException
      {
  	super();
  
  	String driver = System.getProperty("org.xml.sax.parser");
  
  	try {
  	    setup(ParserFactory.makeParser());
  	} catch (ClassNotFoundException e1) {
  	    throw new
  		SAXException("Cannot find SAX1 driver class " +
  			     driver, e1);
  	} catch (IllegalAccessException e2) {
  	    throw new
  		SAXException("SAX1 driver class " +
  			     driver +
  			     " found but cannot be loaded", e2);
  	} catch (InstantiationException e3) {
  	    throw new
  		SAXException("SAX1 driver class " +
  			     driver +
  			     " loaded but cannot be instantiated", e3);
  	} catch (ClassCastException e4) {
  	    throw new
  		SAXException("SAX1 driver class " +
  			     driver +
  			     " does not implement org.xml.sax.Parser");
  	} catch (NullPointerException e5) {
  	    throw new 
  		SAXException("System property org.xml.sax.parser not specified");
  	}
      }
  
  
      /**
       * Construct a new parser adapter.
       *
       * <p>Note that the embedded parser cannot be changed once the
       * adapter is created; to embed a different parser, allocate
       * a new ParserAdapter.</p>
       *
       * @param parser The SAX1 parser to embed.
       * @exception java.lang.NullPointerException If the parser parameter
       *            is null.
       */
      public ParserAdapter (Parser parser)
      {
  	super();
  	setup(parser);
      }
  
  
      /**
       * Internal setup method.
       *
       * @param parser The embedded parser.
       * @exception java.lang.NullPointerException If the parser parameter
       *            is null.
       */
      private void setup (Parser parser)
      {
  	if (parser == null) {
  	    throw new
  		NullPointerException("Parser argument must not be null");
  	}
  	this.parser = parser;
  	atts = new AttributesImpl();
  	nsSupport = new NamespaceSupport();
  	attAdapter = new AttributeListAdapter();
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.XMLReader.
      ////////////////////////////////////////////////////////////////////
  
  
      //
      // Internal constants for the sake of convenience.
      //
      private final static String FEATURES = "http://xml.org/sax/features/";
      private final static String NAMESPACES = FEATURES + "namespaces";
      private final static String NAMESPACE_PREFIXES = FEATURES + "namespace-prefixes";
      private final static String VALIDATION = FEATURES + "validation";
      private final static String EXTERNAL_GENERAL =
  	FEATURES + "external-general-entities";
      private final static String EXTERNAL_PARAMETER =
  	FEATURES + "external-parameter-entities";
  
  
      /**
       * Set a feature for the parser.
       *
       * <p>The only features supported are namespaces and 
       * namespace-prefixes.</p>
       *
       * @param name The feature name, as a complete URI.
       * @param state The requested feature state.
       * @exception org.xml.sax.SAXNotRecognizedException If the feature
       *            name is not known.
       * @exception org.xml.sax.SAXNotSupportedException If the feature
       *            state is not supported.
       * @see org.xml.sax.XMLReader#setFeature
       */
      public void setFeature (String name, boolean state)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	if (name.equals(NAMESPACES)) {
  	    checkNotParsing("feature", name);
  	    namespaces = state;
  	    if (!namespaces && !prefixes) {
  		prefixes = true;
  	    }
  	} else if (name.equals(NAMESPACE_PREFIXES)) {
  	    checkNotParsing("feature", name);
  	    prefixes = state;
  	    if (!prefixes && !namespaces) {
  		namespaces = true;
  	    }
  	} else if (name.equals(VALIDATION) ||
  		   name.equals(EXTERNAL_GENERAL) ||
  		   name.equals(EXTERNAL_PARAMETER)) {
  	    throw new SAXNotSupportedException("Feature: " + name);
  	} else {
  	    throw new SAXNotRecognizedException("Feature: " + name);
  	}
      }
  
  
      /**
       * Check a parser feature.
       *
       * <p>The only features supported are namespaces and 
       * namespace-prefixes.</p>
       *
       * @param name The feature name, as a complete URI.
       * @return The current feature state.
       * @exception org.xml.sax.SAXNotRecognizedException If the feature
       *            name is not known.
       * @exception org.xml.sax.SAXNotSupportedException If querying the
       *            feature state is not supported.
       * @see org.xml.sax.XMLReader#setFeature
       */
      public boolean getFeature (String name)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	if (name.equals(NAMESPACES)) {
  	    return namespaces;
  	} else if (name.equals(NAMESPACE_PREFIXES)) {
  	    return prefixes;
  	} else if (name.equals(VALIDATION) ||
  		   name.equals(EXTERNAL_GENERAL) ||
  		   name.equals(EXTERNAL_PARAMETER)) {
  	    throw new SAXNotSupportedException("Feature: " + name);
  	} else {
  	    throw new SAXNotRecognizedException("Feature: " + name);
  	}
      }
  
  
      /**
       * Set a parser property.
       *
       * <p>No special properties are currently supported.</p>
       *
       * @param name The property name.
       * @param value The property value.
       * @exception org.xml.sax.SAXNotRecognizedException If the feature
       *            name is not known.
       * @exception org.xml.sax.SAXNotSupportedException If the feature
       *            state is not supported.
       * @see org.xml.sax.XMLReader#setProperty
       */
      public void setProperty (String name, Object value)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	throw new SAXNotRecognizedException("Property: " + name);
      }
  
  
      /**
       * Get a parser property.
       *
       * <p>No special properties are currently supported.</p>
       *
       * @param name The property name.
       * @return The property value.
       * @exception org.xml.sax.SAXNotRecognizedException If the feature
       *            name is not known.
       * @exception org.xml.sax.SAXNotSupportedException If the feature
       *            state is not supported.
       * @see org.xml.sax.XMLReader#getProperty
       */
      public Object getProperty (String name)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	throw new SAXNotRecognizedException("Property: " + name);
      }
  
  
      /**
       * Set the entity resolver.
       *
       * @param resolver The new entity resolver.
       * @exception java.lang.NullPointerException If the entity resolver
       *            parameter is null.
       * @see org.xml.sax.XMLReader#setEntityResolver
       */
      public void setEntityResolver (EntityResolver resolver)
      {
  	if (resolver == null) {
  	    throw new NullPointerException("Null entity resolver");
  	}
  	entityResolver = resolver;
      }
  
  
      /**
       * Return the current entity resolver.
       *
       * @return The current entity resolver, or null if none was supplied.
       * @see org.xml.sax.XMLReader#getEntityResolver
       */
      public EntityResolver getEntityResolver ()
      {
  	return entityResolver;
      }
  
  
      /**
       * Set the DTD handler.
       *
       * @param resolver The new DTD handler.
       * @exception java.lang.NullPointerException If the DTD handler
       *            parameter is null.
       * @see org.xml.sax.XMLReader#setEntityResolver
       */
      public void setDTDHandler (DTDHandler handler)
      {
  	if (handler == null) {
  	    throw new NullPointerException("Null DTD handler");
  	}
  	dtdHandler = handler;
      }
  
  
      /**
       * Return the current DTD handler.
       *
       * @return The current DTD handler, or null if none was supplied.
       * @see org.xml.sax.XMLReader#getEntityResolver
       */
      public DTDHandler getDTDHandler ()
      {
  	return dtdHandler;
      }
  
  
      /**
       * Set the content handler.
       *
       * @param resolver The new content handler.
       * @exception java.lang.NullPointerException If the content handler
       *            parameter is null.
       * @see org.xml.sax.XMLReader#setEntityResolver
       */
      public void setContentHandler (ContentHandler handler)
      {
  	if (handler == null) {
  	    throw new NullPointerException("Null content handler");
  	}
  	contentHandler = handler;
      }
  
  
      /**
       * Return the current content handler.
       *
       * @return The current content handler, or null if none was supplied.
       * @see org.xml.sax.XMLReader#getEntityResolver
       */
      public ContentHandler getContentHandler ()
      {
  	return contentHandler;
      }
  
  
      /**
       * Set the error handler.
       *
       * @param resolver The new error handler.
       * @exception java.lang.NullPointerException If the error handler
       *            parameter is null.
       * @see org.xml.sax.XMLReader#setEntityResolver
       */
      public void setErrorHandler (ErrorHandler handler)
      {
  	if (handler == null) {
  	    throw new NullPointerException("Null error handler");
  	}
  	errorHandler = handler;
      }
  
  
      /**
       * Return the current error handler.
       *
       * @return The current error handler, or null if none was supplied.
       * @see org.xml.sax.XMLReader#getEntityResolver
       */
      public ErrorHandler getErrorHandler ()
      {
  	return errorHandler;
      }
  
  
      /**
       * Parse an XML document.
       *
       * @param systemId The absolute URL of the document.
       * @exception java.io.IOException If there is a problem reading
       *            the raw content of the document.
       * @exception org.xml.sax.SAXException If there is a problem
       *            processing the document.
       * @see #parse(org.xml.sax.InputSource)
       * @see org.xml.sax.Parser#parse(java.lang.String)
       */
      public void parse (String systemId)
  	throws IOException, SAXException
      {
  	parse(new InputSource(systemId));
      }
  
  
      /**
       * Parse an XML document.
       *
       * @param input An input source for the document.
       * @exception java.io.IOException If there is a problem reading
       *            the raw content of the document.
       * @exception org.xml.sax.SAXException If there is a problem
       *            processing the document.
       * @see #parse(java.lang.String)
       * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
       */
      public void parse (InputSource input)
  	throws IOException, SAXException
      {
  	if (parsing) {
  	    throw new SAXException("Parser is already in use");
  	}
  	setupParser();
  	parsing = true;
  	try {
  	    parser.parse(input);
  	} finally {
  	    parsing = false;
  	}
  	parsing = false;
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.DocumentHandler.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Adapt a SAX1 document locator event.
       *
       * @param locator A document locator.
       * @see org.xml.sax.ContentHandler#setDocumentLocator
       */
      public void setDocumentLocator (Locator locator)
      {
  	this.locator = locator;
  	if (contentHandler != null) {
  	    contentHandler.setDocumentLocator(locator);
  	}
      }
  
  
      /**
       * Adapt a SAX1 start document event.
       *
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.DocumentHandler#startDocument
       */
      public void startDocument ()
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.startDocument();
  	}
      }
  
  
      /**
       * Adapt a SAX1 end document event.
       *
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.DocumentHandler#endDocument
       */
      public void endDocument ()
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.endDocument();
  	}
      }
  
  
      /**
       * Adapt a SAX1 startElement event.
       *
       * <p>If necessary, perform Namespace processing.</p>
       *
       * @param qName The qualified (prefixed) name.
       * @param qAtts The XML 1.0 attribute list (with qnames).
       */
      public void startElement (String qName, AttributeList qAtts)
  	throws SAXException
      {
  				// If we're not doing Namespace
  				// processing, dispatch this quickly.
  	if (!namespaces) {
  	    if (contentHandler != null) {
  		attAdapter.setAttributeList(qAtts);
  		contentHandler.startElement("", "", qName.intern(),
  					    attAdapter);
  	    }
  	    return;
  	}
  
  
  				// OK, we're doing Namespace processing.
  	nsSupport.pushContext();
  	boolean seenDecl = false;
  	atts.clear();
  	
  				// Take a first pass and copy all
  				// attributes into the SAX2 attribute
  				// list, noting any Namespace 
  				// declarations.
  	int length = qAtts.getLength();
  	for (int i = 0; i < length; i++) {
  	    String attQName = qAtts.getName(i);
  	    String type = qAtts.getType(i);
  	    String value = qAtts.getValue(i);
  
  				// Found a declaration...
  	    if (attQName.startsWith("xmlns")) {
  		String prefix;
  		int n = attQName.indexOf(':');
  		if (n == -1) {
  		    prefix = "";
  		} else {
  		    prefix = attQName.substring(n+1);
  		}
  		if (!nsSupport.declarePrefix(prefix, value)) {
  		    reportError("Illegal Namespace prefix: " + prefix);
  		}
  		if (contentHandler != null) {
  		    contentHandler.startPrefixMapping(prefix, value);
  		}
  				// We may still have to add this to
  				// the list.
  		if (prefixes) {
  		    atts.addAttribute("", "", attQName.intern(),
  				      type, value);
  		}
  		seenDecl = true;
  
  				// This isn't a declaration.
  	    } else {
  		String attName[] = processName(attQName, true);
  		atts.addAttribute(attName[0], attName[1], attName[2],
  				  type, value);
  	    }
  	}
  	
  				// If there was a Namespace declaration,
  				// we have to make a second pass just
  				// to be safe -- this will happen very
  				// rarely, possibly only once for each
  				// document.
  	if (seenDecl) {
  	    length = atts.getLength();
  	    for (int i = 0; i < length; i++) {
  		String attQName = atts.getQName(i);
  		if (!attQName.startsWith("xmlns")) {
  		    String attName[] = processName(attQName, true);
  		    atts.setURI(i, attName[0]);
  		    atts.setLocalName(i, attName[1]);
  		}
  	    }
  	}
  
  				// OK, finally report the event.
  	if (contentHandler != null) {
  	    String name[] = processName(qName, false);
  	    contentHandler.startElement(name[0], name[1], name[2], atts);
  	}
      }
  
  
      /**
       * Adapt a SAX1 end element event.
       *
       * @param qName The qualified (prefixed) name.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.DocumentHandler#endElement
       */
      public void endElement (String qName)
  	throws SAXException
      {
  				// If we're not doing Namespace
  				// processing, dispatch this quickly.
  	if (!namespaces) {
  	    if (contentHandler != null) {
  		contentHandler.endElement("", "", qName.intern());
  	    }
  	    return;
  	}
  
  				// Split the name.
  	String names[] = processName(qName, false);
  	if (contentHandler != null) {
  	    contentHandler.endElement(names[0], names[1], names[2]);
  	    Enumeration prefixes = nsSupport.getDeclaredPrefixes();
  	    while (prefixes.hasMoreElements()) {
  		String prefix = (String)prefixes.nextElement();
  		contentHandler.endPrefixMapping(prefix);
  	    }
  	}
  	nsSupport.popContext();
      }
  
  
      /**
       * Adapt a SAX1 characters event.
       *
       * @param ch An array of characters.
       * @param start The starting position in the array.
       * @param length The number of characters to use.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.DocumentHandler#characters
       */
      public void characters (char ch[], int start, int length)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.characters(ch, start, length);
  	}
      }
  
  
      /**
       * Adapt a SAX1 ignorable whitespace event.
       *
       * @param ch An array of characters.
       * @param start The starting position in the array.
       * @param length The number of characters to use.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.DocumentHandler#ignorableWhitespace
       */
      public void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.ignorableWhitespace(ch, start, length);
  	}
      }
  
  
      /**
       * Adapt a SAX1 processing instruction event.
       *
       * @param target The processing instruction target.
       * @param data The remainder of the processing instruction
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.DocumentHandler#processingInstruction
       */
      public void processingInstruction (String target, String data)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.processingInstruction(target, data);
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal utility methods.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Initialize the parser before each run.
       */
      private void setupParser ()
      {
  	nsSupport.reset();
  
  	if (entityResolver != null) {
  	    parser.setEntityResolver(entityResolver);
  	}
  	if (dtdHandler != null) {
  	    parser.setDTDHandler(dtdHandler);
  	}
  	if (errorHandler != null) {
  	    parser.setErrorHandler(errorHandler);
  	}
  	parser.setDocumentHandler(this);
  	locator = null;
      }
  
  
      /**
       * Process a qualified (prefixed) name.
       *
       * <p>If the name has an undeclared prefix, use only the qname
       * and make an ErrorHandler.error callback in case the app is
       * interested.</p>
       *
       * @param qName The qualified (prefixed) name.
       * @param isAttribute true if this is an attribute name.
       * @return The name split into three parts.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception if there is an error callback.
       */
      private String [] processName (String qName, boolean isAttribute)
  	throws SAXException
      {
  	String parts[] = nsSupport.processName(qName, nameParts,
  					       isAttribute);
  	if (parts == null) {
  	    parts = new String[3];
  	    parts[2] = qName.intern();
  	    reportError("Undeclared prefix: " + qName);
  	}
  	return parts;
      }
  
  
      /**
       * Report a non-fatal error.
       *
       * @param message The error message.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception.
       */
      void reportError (String message)
  	throws SAXException
      {
  	if (errorHandler == null) {
  	    return;
  	}
  
  	SAXParseException e;
  	if (locator != null) {
  	    e = new SAXParseException(message, locator);
  	} else {
  	    e = new SAXParseException(message, null, null, -1, -1);
  	}
  	errorHandler.error(e);
      }
  
  
      /**
       * Throw an exception if we are parsing.
       *
       * <p>Use this method to detect illegal feature or
       * property changes.</p>
       *
       * @param type The type of thing (feature or property).
       * @param name The feature or property name.
       * @exception org.xml.sax.SAXNotSupportedException If a
       *            document is currently being parsed.
       */
      private void checkNotParsing (String type, String name)
  	throws SAXNotSupportedException
      {
  	if (parsing) {
  	    throw new SAXNotSupportedException("Cannot change " +
  					       type + ' ' +
  					       name + " while parsing");
  					       
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
  
      private NamespaceSupport nsSupport;
      private AttributeListAdapter attAdapter;
  
      private boolean parsing = false;
      private String nameParts[] = new String[3];
  
      private Parser parser = null;
  
      private AttributesImpl atts = null;
  
  				// Features
      private boolean namespaces = true;
      private boolean prefixes = false;
  
  				// Properties
  
  				// Handlers
      Locator locator;
  
      EntityResolver entityResolver = null;
      DTDHandler dtdHandler = null;
      ContentHandler contentHandler = null;
      ErrorHandler errorHandler = null;
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Inner class to wrap an AttributeList when not doing NS proc.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Adapt a SAX1 AttributeList as a SAX2 Attributes object.
       *
       * <p>This class is in the Public Domain, and comes with NO
       * WARRANTY of any kind.</p>
       *
       * <p>This wrapper class is used only when Namespace support
       * is disabled -- it provides pretty much a direct mapping
       * from SAX1 to SAX2, except that names and types are 
       * interned whenever requested.</p>
       */
      final class AttributeListAdapter implements Attributes
      {
  
  	/**
  	 * Construct a new adapter.
  	 */
  	AttributeListAdapter ()
  	{
  	}
  
  
  	/**
  	 * Set the embedded AttributeList.
  	 *
  	 * <p>This method must be invoked before any of the others
  	 * can be used.</p>
  	 *
  	 * @param The SAX1 attribute list (with qnames).
  	 */
  	void setAttributeList (AttributeList qAtts)
  	{
  	    this.qAtts = qAtts;
  	}
  
  
  	/**
  	 * Return the length of the attribute list.
  	 *
  	 * @return The number of attributes in the list.
  	 * @see org.xml.sax.Attributes#getLength
  	 */
  	public int getLength ()
  	{
  	    return qAtts.getLength();
  	}
  
  
  	/**
  	 * Return the Namespace URI of the specified attribute.
  	 *
  	 * @param The attribute's index.
  	 * @return Always the empty string.
  	 * @see org.xml.sax.Attributes#getURI
  	 */
  	public String getURI (int i)
  	{
  	    return "";
  	}
  
  
  	/**
  	 * Return the local name of the specified attribute.
  	 *
  	 * @param The attribute's index.
  	 * @return Always the empty string.
  	 * @see org.xml.sax.Attributes#getLocalName
  	 */
  	public String getLocalName (int i)
  	{
  	    return "";
  	}
  
  
  	/**
  	 * Return the qualified (prefixed) name of the specified attribute.
  	 *
  	 * @param The attribute's index.
  	 * @return The attribute's qualified name, internalized.
  	 */
  	public String getQName (int i)
  	{
  	    return qAtts.getName(i).intern();
  	}
  
  
  	/**
  	 * Return the type of the specified attribute.
  	 *
  	 * @param The attribute's index.
  	 * @return The attribute's type as an internalized string.
  	 */
  	public String getType (int i)
  	{
  	    return qAtts.getType(i).intern();
  	}
  
  
  	/**
  	 * Return the value of the specified attribute.
  	 *
  	 * @param The attribute's index.
  	 * @return The attribute's value.
  	 */
  	public String getValue (int i)
  	{
  	    return qAtts.getValue(i);
  	}
  
  
  	/**
  	 * Look up an attribute index by Namespace name.
  	 *
  	 * @param uri The Namespace URI or the empty string.
  	 * @param localName The local name.
  	 * @return The attributes index, or -1 if none was found.
  	 * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)
  	 */
  	public int getIndex (String uri, String localName)
  	{
  	    return -1;
  	}
  
  
  	/**
  	 * Look up an attribute index by qualified (prefixed) name.
  	 *
  	 * @param qName The qualified name.
  	 * @return The attributes index, or -1 if none was found.
  	 * @see org.xml.sax.Attributes#getIndex(java.lang.String)
  	 */
  	public int getIndex (String qName)
  	{
  	    int max = atts.getLength();
  	    for (int i = 0; i < max; i++) {
  		if (qAtts.getName(i).equals(qName)) {
  		    return i;
  		}
  	    }
  	    return -1;
  	}
  
  
  	/**
  	 * Look up the type of an attribute by Namespace name.
  	 *
  	 * @param uri The Namespace URI
  	 * @param localName The local name.
  	 * @return The attribute's type as an internalized string.
  	 */
  	public String getType (String uri, String localName)
  	{
  	    return null;
  	}
  
  
  	/**
  	 * Look up the type of an attribute by qualified (prefixed) name.
  	 *
  	 * @param qName The qualified name.
  	 * @return The attribute's type as an internalized string.
  	 */
  	public String getType (String qName)
  	{
  	    return qAtts.getType(qName).intern();
  	}
  
  
  	/**
  	 * Look up the value of an attribute by Namespace name.
  	 *
  	 * @param uri The Namespace URI
  	 * @param localName The local name.
  	 * @return The attribute's value.
  	 */
  	public String getValue (String uri, String localName)
  	{
  	    return null;
  	}
  
  
  	/**
  	 * Look up the value of an attribute by qualified (prefixed) name.
  	 *
  	 * @param qName The qualified name.
  	 * @return The attribute's value.
  	 */
  	public String getValue (String qName)
  	{
  	    return qAtts.getValue(qName);
  	}
  
  	private AttributeList qAtts;
      }
  }
  
  // end of ParserAdapter.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/ParserFactory.java
  
  Index: ParserFactory.java
  ===================================================================
  // SAX parser factory.
  // No warranty; no copyright -- use this as you will.
  // $Id: ParserFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import java.lang.ClassNotFoundException;
  import java.lang.IllegalAccessException;
  import java.lang.InstantiationException;
  import java.lang.SecurityException;
  import java.lang.ClassCastException;
  
  import org.xml.sax.Parser;
  
  
  /**
   * Java-specific class for dynamically loading SAX parsers.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p><strong>Note:</strong> This class is designed to work with the now-deprecated
   * SAX1 {@link org.xml.sax.Parser Parser} class.  SAX2 applications should use
   * {@link org.xml.sax.helpers.XMLReaderFactory XMLReaderFactory} instead.</p>
   *
   * <p>ParserFactory is not part of the platform-independent definition
   * of SAX; it is an additional convenience class designed
   * specifically for Java XML application writers.  SAX applications
   * can use the static methods in this class to allocate a SAX parser
   * dynamically at run-time based either on the value of the
   * `org.xml.sax.parser' system property or on a string containing the class
   * name.</p>
   *
   * <p>Note that the application still requires an XML parser that
   * implements SAX1.</p>
   *
   * @deprecated This class works with the deprecated
   *             {@link org.xml.sax.Parser Parser}
   *             interface.
   * @since SAX 1.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser
   * @see java.lang.Class
   */
  public class ParserFactory {
      
      
      /**
       * Private null constructor.
       */
      private ParserFactory ()
      {
      }
      
      
      /**
       * Create a new SAX parser using the `org.xml.sax.parser' system property.
       *
       * <p>The named class must exist and must implement the
       * {@link org.xml.sax.Parser Parser} interface.</p>
       *
       * @exception java.lang.NullPointerException There is no value
       *            for the `org.xml.sax.parser' system property.
       * @exception java.lang.ClassNotFoundException The SAX parser
       *            class was not found (check your CLASSPATH).
       * @exception IllegalAccessException The SAX parser class was
       *            found, but you do not have permission to load
       *            it.
       * @exception InstantiationException The SAX parser class was
       *            found but could not be instantiated.
       * @exception java.lang.ClassCastException The SAX parser class
       *            was found and instantiated, but does not implement
       *            org.xml.sax.Parser.
       * @see #makeParser(java.lang.String)
       * @see org.xml.sax.Parser
       */
      public static Parser makeParser ()
  	throws ClassNotFoundException,
  	IllegalAccessException, 
  	InstantiationException,
  	NullPointerException,
  	ClassCastException
      {
  	String className = System.getProperty("org.xml.sax.parser");
  	if (className == null) {
  	    throw new NullPointerException("No value for sax.parser property");
  	} else {
  	    return makeParser(className);
  	}
      }
      
      
      /**
       * Create a new SAX parser object using the class name provided.
       *
       * <p>The named class must exist and must implement the
       * {@link org.xml.sax.Parser Parser} interface.</p>
       *
       * @param className A string containing the name of the
       *                  SAX parser class.
       * @exception java.lang.ClassNotFoundException The SAX parser
       *            class was not found (check your CLASSPATH).
       * @exception IllegalAccessException The SAX parser class was
       *            found, but you do not have permission to load
       *            it.
       * @exception InstantiationException The SAX parser class was
       *            found but could not be instantiated.
       * @exception java.lang.ClassCastException The SAX parser class
       *            was found and instantiated, but does not implement
       *            org.xml.sax.Parser.
       * @see #makeParser()
       * @see org.xml.sax.Parser
       */
      public static Parser makeParser (String className)
  	throws ClassNotFoundException,
  	IllegalAccessException, 
  	InstantiationException,
  	ClassCastException
      {
  	return (Parser)(Class.forName(className).newInstance());
      }
      
  }
  
  // end of ParserFactory.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/XMLFilterImpl.java
  
  Index: XMLFilterImpl.java
  ===================================================================
  // XMLFilterImpl.java - base SAX2 filter implementation.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the Public Domain.
  
  // $Id: XMLFilterImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import java.io.IOException;
  
  import org.xml.sax.XMLReader;
  import org.xml.sax.XMLFilter;
  import org.xml.sax.InputSource;
  import org.xml.sax.Locator;
  import org.xml.sax.Attributes;
  import org.xml.sax.EntityResolver;
  import org.xml.sax.DTDHandler;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  import org.xml.sax.SAXNotSupportedException;
  import org.xml.sax.SAXNotRecognizedException;
  
  
  /**
   * Base class for deriving an XML filter.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class is designed to sit between an {@link org.xml.sax.XMLReader
   * XMLReader} and the client application's event handlers.  By default, it
   * does nothing but pass requests up to the reader and events
   * on to the handlers unmodified, but subclasses can override
   * specific methods to modify the event stream or the configuration
   * requests as they pass through.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.XMLFilter
   * @see org.xml.sax.XMLReader
   * @see org.xml.sax.EntityResolver
   * @see org.xml.sax.DTDHandler
   * @see org.xml.sax.ContentHandler
   * @see org.xml.sax.ErrorHandler
   */
  public class XMLFilterImpl
      implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Constructors.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Construct an empty XML filter, with no parent.
       *
       * <p>This filter will have no parent: you must assign a parent
       * before you start a parse or do any configuration with
       * setFeature or setProperty.</p>
       *
       * @see org.xml.sax.XMLReader#setFeature
       * @see org.xml.sax.XMLReader#setProperty
       */
      public XMLFilterImpl ()
      {
  	super();
      }
  
  
      /**
       * Construct an XML filter with the specified parent.
       *
       * @see #setParent
       * @see #getParent
       */
      public XMLFilterImpl (XMLReader parent)
      {
          super();
  	setParent(parent);
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.XMLFilter.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Set the parent reader.
       *
       * <p>This is the {@link org.xml.sax.XMLReader XMLReader} from which 
       * this filter will obtain its events and to which it will pass its 
       * configuration requests.  The parent may itself be another filter.</p>
       *
       * <p>If there is no parent reader set, any attempt to parse
       * or to set or get a feature or property will fail.</p>
       *
       * @param parent The parent XML reader.
       * @exception java.lang.NullPointerException If the parent is null.
       * @see #getParent
       */
      public void setParent (XMLReader parent)
      {
  	if (parent == null) {
  	    throw new NullPointerException("Null parent");
  	}
  	this.parent = parent;
      }
  
  
      /**
       * Get the parent reader.
       *
       * @return The parent XML reader, or null if none is set.
       * @see #setParent
       */
      public XMLReader getParent ()
      {
  	return parent;
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.XMLReader.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Set the state of a feature.
       *
       * <p>This will always fail if the parent is null.</p>
       *
       * @param name The feature name.
       * @param state The requested feature state.
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the feature name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the feature name but 
       *            cannot set the requested value.
       * @see org.xml.sax.XMLReader#setFeature
       */
      public void setFeature (String name, boolean state)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	if (parent != null) {
  	    parent.setFeature(name, state);
  	} else {
  	    throw new SAXNotRecognizedException("Feature: " + name);
  	}
      }
  
  
      /**
       * Look up the state of a feature.
       *
       * <p>This will always fail if the parent is null.</p>
       *
       * @param name The feature name.
       * @return The current state of the feature.
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the feature name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the feature name but 
       *            cannot determine its state at this time.
       * @see org.xml.sax.XMLReader#getFeature
       */
      public boolean getFeature (String name)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	if (parent != null) {
  	    return parent.getFeature(name);
  	} else {
  	    throw new SAXNotRecognizedException("Feature: " + name);
  	}
      }
  
  
      /**
       * Set the value of a property.
       *
       * <p>This will always fail if the parent is null.</p>
       *
       * @param name The property name.
       * @param state The requested property value.
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the property name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the property name but 
       *            cannot set the requested value.
       * @see org.xml.sax.XMLReader#setProperty
       */
      public void setProperty (String name, Object value)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	if (parent != null) {
  	    parent.setProperty(name, value);
  	} else {
  	    throw new SAXNotRecognizedException("Property: " + name);
  	}
      }
  
  
      /**
       * Look up the value of a property.
       *
       * @param name The property name.
       * @return The current value of the property.
       * @exception org.xml.sax.SAXNotRecognizedException When the
       *            XMLReader does not recognize the feature name.
       * @exception org.xml.sax.SAXNotSupportedException When the
       *            XMLReader recognizes the property name but 
       *            cannot determine its value at this time.
       * @see org.xml.sax.XMLReader#setFeature
       */
      public Object getProperty (String name)
  	throws SAXNotRecognizedException, SAXNotSupportedException
      {
  	if (parent != null) {
  	    return parent.getProperty(name);
  	} else {
  	    throw new SAXNotRecognizedException("Property: " + name);
  	}
      }
  
  
      /**
       * Set the entity resolver.
       *
       * @param resolver The new entity resolver.
       * @exception java.lang.NullPointerException If the resolver
       *            is null.
       * @see org.xml.sax.XMLReader#setEntityResolver
       */
      public void setEntityResolver (EntityResolver resolver)
      {
  	if (resolver == null) {
  	    throw new NullPointerException("Null entity resolver");
  	} else {
  	    entityResolver = resolver;
  	}
      }
  
  
      /**
       * Get the current entity resolver.
       *
       * @return The current entity resolver, or null if none was set.
       * @see org.xml.sax.XMLReader#getEntityResolver
       */
      public EntityResolver getEntityResolver ()
      {
  	return entityResolver;
      }
  
  
      /**
       * Set the DTD event handler.
       *
       * @param resolver The new DTD handler.
       * @exception java.lang.NullPointerException If the handler
       *            is null.
       * @see org.xml.sax.XMLReader#setDTDHandler
       */
      public void setDTDHandler (DTDHandler handler)
      {
  	if (handler == null) {
  	    throw new NullPointerException("Null DTD handler");
  	} else {
  	    dtdHandler = handler;
  	}
      }
  
  
      /**
       * Get the current DTD event handler.
       *
       * @return The current DTD handler, or null if none was set.
       * @see org.xml.sax.XMLReader#getDTDHandler
       */
      public DTDHandler getDTDHandler ()
      {
  	return dtdHandler;
      }
  
  
      /**
       * Set the content event handler.
       *
       * @param resolver The new content handler.
       * @exception java.lang.NullPointerException If the handler
       *            is null.
       * @see org.xml.sax.XMLReader#setContentHandler
       */
      public void setContentHandler (ContentHandler handler)
      {
  	if (handler == null) {
  	    throw new NullPointerException("Null content handler");
  	} else {
  	    contentHandler = handler;
  	}
      }
  
  
      /**
       * Get the content event handler.
       *
       * @return The current content handler, or null if none was set.
       * @see org.xml.sax.XMLReader#getContentHandler
       */
      public ContentHandler getContentHandler ()
      {
  	return contentHandler;
      }
  
  
      /**
       * Set the error event handler.
       *
       * @param handle The new error handler.
       * @exception java.lang.NullPointerException If the handler
       *            is null.
       * @see org.xml.sax.XMLReader#setErrorHandler
       */
      public void setErrorHandler (ErrorHandler handler)
      {
  	if (handler == null) {
  	    throw new NullPointerException("Null error handler");
  	} else {
  	    errorHandler = handler;
  	}
      }
  
  
      /**
       * Get the current error event handler.
       *
       * @return The current error handler, or null if none was set.
       * @see org.xml.sax.XMLReader#getErrorHandler
       */
      public ErrorHandler getErrorHandler ()
      {
  	return errorHandler;
      }
  
  
      /**
       * Parse a document.
       *
       * @param input The input source for the document entity.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException An IO exception from the parser,
       *            possibly from a byte stream or character stream
       *            supplied by the application.
       * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
       */
      public void parse (InputSource input)
  	throws SAXException, IOException
      {
  	setupParse();
  	parent.parse(input);
      }
  
  
      /**
       * Parse a document.
       *
       * @param systemId The system identifier as a fully-qualified URI.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @exception java.io.IOException An IO exception from the parser,
       *            possibly from a byte stream or character stream
       *            supplied by the application.
       * @see org.xml.sax.XMLReader#parse(java.lang.String)
       */
      public void parse (String systemId)
  	throws SAXException, IOException
      {
  	parse(new InputSource(systemId));
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.EntityResolver.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Filter an external entity resolution.
       *
       * @param publicId The entity's public identifier, or null.
       * @param systemId The entity's system identifier.
       * @return A new InputSource or null for the default.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @exception java.io.IOException The client may throw an
       *            I/O-related exception while obtaining the
       *            new InputSource.
       * @see org.xml.sax.EntityResolver#resolveEntity
       */
      public InputSource resolveEntity (String publicId, String systemId)
  	throws SAXException, IOException
      {
  	if (entityResolver != null) {
  	    return entityResolver.resolveEntity(publicId, systemId);
  	} else {
  	    return null;
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.DTDHandler.
      ////////////////////////////////////////////////////////////////////
  
      
      /**
       * Filter a notation declaration event.
       *
       * @param name The notation name.
       * @param publicId The notation's public identifier, or null.
       * @param systemId The notation's system identifier, or null.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.DTDHandler#notationDecl
       */
      public void notationDecl (String name, String publicId, String systemId)
  	throws SAXException
      {
  	if (dtdHandler != null) {
  	    dtdHandler.notationDecl(name, publicId, systemId);
  	}
      }
  
      
      /**
       * Filter an unparsed entity declaration event.
       *
       * @param name The entity name.
       * @param publicId The entity's public identifier, or null.
       * @param systemId The entity's system identifier, or null.
       * @param notationName The name of the associated notation.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.DTDHandler#unparsedEntityDecl
       */
      public void unparsedEntityDecl (String name, String publicId,
  				    String systemId, String notationName)
  	throws SAXException
      {
  	if (dtdHandler != null) {
  	    dtdHandler.unparsedEntityDecl(name, publicId, systemId,
  					  notationName);
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.ContentHandler.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Filter a new document locator event.
       *
       * @param locator The document locator.
       * @see org.xml.sax.ContentHandler#setDocumentLocator
       */
      public void setDocumentLocator (Locator locator)
      {
  	this.locator = locator;
  	if (contentHandler != null) {
  	    contentHandler.setDocumentLocator(locator);
  	}
      }
  
  
      /**
       * Filter a start document event.
       *
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#startDocument
       */
      public void startDocument ()
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.startDocument();
  	}
      }
  
  
      /**
       * Filter an end document event.
       *
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#endDocument
       */
      public void endDocument ()
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.endDocument();
  	}
      }
  
  
      /**
       * Filter a start Namespace prefix mapping event.
       *
       * @param prefix The Namespace prefix.
       * @param uri The Namespace URI.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#startPrefixMapping
       */
      public void startPrefixMapping (String prefix, String uri)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.startPrefixMapping(prefix, uri);
  	}
      }
  
  
      /**
       * Filter an end Namespace prefix mapping event.
       *
       * @param prefix The Namespace prefix.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#endPrefixMapping
       */
      public void endPrefixMapping (String prefix)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.endPrefixMapping(prefix);
  	}
      }
  
  
      /**
       * Filter a start element event.
       *
       * @param uri The element's Namespace URI, or the empty string.
       * @param localName The element's local name, or the empty string.
       * @param qName The element's qualified (prefixed) name, or the empty
       *        string.
       * @param atts The element's attributes.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#startElement
       */
      public void startElement (String uri, String localName, String qName,
  			      Attributes atts)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.startElement(uri, localName, qName, atts);
  	}
      }
  
  
      /**
       * Filter an end element event.
       *
       * @param uri The element's Namespace URI, or the empty string.
       * @param localName The element's local name, or the empty string.
       * @param qName The element's qualified (prefixed) name, or the empty
       *        string.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#endElement
       */
      public void endElement (String uri, String localName, String qName)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.endElement(uri, localName, qName);
  	}
      }
  
  
      /**
       * Filter a character data event.
       *
       * @param ch An array of characters.
       * @param start The starting position in the array.
       * @param length The number of characters to use from the array.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#characters
       */
      public void characters (char ch[], int start, int length)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.characters(ch, start, length);
  	}
      }
  
  
      /**
       * Filter an ignorable whitespace event.
       *
       * @param ch An array of characters.
       * @param start The starting position in the array.
       * @param length The number of characters to use from the array.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#ignorableWhitespace
       */
      public void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.ignorableWhitespace(ch, start, length);
  	}
      }
  
  
      /**
       * Filter a processing instruction event.
       *
       * @param target The processing instruction target.
       * @param data The text following the target.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#processingInstruction
       */
      public void processingInstruction (String target, String data)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.processingInstruction(target, data);
  	}
      }
  
  
      /**
       * Filter a skipped entity event.
       *
       * @param name The name of the skipped entity.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ContentHandler#skippedEntity
       */
      public void skippedEntity (String name)
  	throws SAXException
      {
  	if (contentHandler != null) {
  	    contentHandler.skippedEntity(name);
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.ErrorHandler.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Filter a warning event.
       *
       * @param e The nwarning as an exception.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ErrorHandler#warning
       */
      public void warning (SAXParseException e)
  	throws SAXException
      {
  	if (errorHandler != null) {
  	    errorHandler.warning(e);
  	}
      }
  
  
      /**
       * Filter an error event.
       *
       * @param e The error as an exception.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ErrorHandler#error
       */
      public void error (SAXParseException e)
  	throws SAXException
      {
  	if (errorHandler != null) {
  	    errorHandler.error(e);
  	}
      }
  
  
      /**
       * Filter a fatal error event.
       *
       * @param e The error as an exception.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see org.xml.sax.ErrorHandler#fatalError
       */
      public void fatalError (SAXParseException e)
  	throws SAXException
      {
  	if (errorHandler != null) {
  	    errorHandler.fatalError(e);
  	}
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal methods.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Set up before a parse.
       *
       * <p>Before every parse, check whether the parent is
       * non-null, and re-register the filter for all of the 
       * events.</p>
       */
      private void setupParse ()
      {
  	if (parent == null) {
  	    throw new NullPointerException("No parent for filter");
  	}
  	parent.setEntityResolver(this);
  	parent.setDTDHandler(this);
  	parent.setContentHandler(this);
  	parent.setErrorHandler(this);
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
  
      private XMLReader parent = null;
      private Locator locator = null;
      private EntityResolver entityResolver = null;
      private DTDHandler dtdHandler = null;
      private ContentHandler contentHandler = null;
      private ErrorHandler errorHandler = null;
  
  }
  
  // end of XMLFilterImpl.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/XMLReaderAdapter.java
  
  Index: XMLReaderAdapter.java
  ===================================================================
  // XMLReaderAdapter.java - adapt an SAX2 XMLReader to a SAX1 Parser
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the public domain.
  
  // $Id: XMLReaderAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  
  import java.io.IOException;
  import java.util.Locale;
  
  import org.xml.sax.Parser;	// deprecated
  import org.xml.sax.Locator;
  import org.xml.sax.InputSource;
  import org.xml.sax.AttributeList; // deprecated
  import org.xml.sax.EntityResolver;
  import org.xml.sax.DTDHandler;
  import org.xml.sax.DocumentHandler; // deprecated
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.SAXException;
  
  import org.xml.sax.XMLReader;
  import org.xml.sax.Attributes;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXNotSupportedException;
  
  
  /**
   * Adapt a SAX2 XMLReader as a SAX1 Parser.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader}
   * and makes it act as a SAX1 {@link org.xml.sax.Parser Parser}.  The XMLReader 
   * must support a true value for the 
   * http://xml.org/sax/features/namespace-prefixes property or parsing will fail
   * with a {@link org.xml.sax.SAXException SAXException}; if the XMLReader 
   * supports a false value for the http://xml.org/sax/features/namespaces 
   * property, that will also be used to improve efficiency.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.Parser
   * @see org.xml.sax.XMLReader
   */
  public class XMLReaderAdapter implements Parser, ContentHandler
  {
  
  
      ////////////////////////////////////////////////////////////////////
      // Constructor.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Create a new adapter.
       *
       * <p>Use the "org.xml.sax.driver" property to locate the SAX2
       * driver to embed.</p>
       *
       * @exception org.xml.sax.SAXException If the embedded driver
       *            cannot be instantiated or if the
       *            org.xml.sax.driver property is not specified.
       */
      public XMLReaderAdapter ()
        throws SAXException
      {
  	setup(XMLReaderFactory.createXMLReader());
      }
  
  
      /**
       * Create a new adapter.
       *
       * <p>Create a new adapter, wrapped around a SAX2 XMLReader.
       * The adapter will make the XMLReader act like a SAX1
       * Parser.</p>
       *
       * @param xmlReader The SAX2 XMLReader to wrap.
       * @exception java.lang.NullPointerException If the argument is null.
       */
      public XMLReaderAdapter (XMLReader xmlReader)
      {
  	setup(xmlReader);
      }
  
  
  
      /**
       * Internal setup.
       *
       * @param xmlReader The embedded XMLReader.
       */
      private void setup (XMLReader xmlReader)
      {
  	if (xmlReader == null) {
  	    throw new NullPointerException("XMLReader must not be null");
  	}
  	this.xmlReader = xmlReader;
  	qAtts = new AttributesAdapter();
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.Parser.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Set the locale for error reporting.
       *
       * <p>This is not supported in SAX2, and will always throw
       * an exception.</p>
       *
       * @param The locale for error reporting.
       * @see org.xml.sax.Parser#setLocale
       */
      public void setLocale (Locale locale)
  	throws SAXException
      {
  	throw new SAXNotSupportedException("setLocale not supported");
      }
  
  
      /**
       * Register the entity resolver.
       *
       * @param resolver The new resolver.
       * @see org.xml.sax.Parser#setEntityResolver
       */
      public void setEntityResolver (EntityResolver resolver)
      {
  	xmlReader.setEntityResolver(resolver);
      }
  
  
      /**
       * Register the DTD event handler.
       *
       * @param handler The new DTD event handler.
       * @see org.xml.sax.Parser#setDTDHandler
       */
      public void setDTDHandler (DTDHandler handler)
      {
  	xmlReader.setDTDHandler(handler);
      }
  
  
      /**
       * Register the SAX1 document event handler.
       *
       * <p>Note that the SAX1 document handler has no Namespace
       * support.</p>
       *
       * @param handler The new SAX1 document event handler.
       * @see org.xml.sax.Parser#setDocumentHandler
       */
      public void setDocumentHandler (DocumentHandler handler)
      {
  	documentHandler = handler;
      }
  
  
      /**
       * Register the error event handler.
       *
       * @param handler The new error event handler.
       * @see org.xml.sax.Parser#setErrorHandler
       */
      public void setErrorHandler (ErrorHandler handler)
      {
  	xmlReader.setErrorHandler(handler);
      }
  
  
      /**
       * Parse the document.
       *
       * <p>This method will throw an exception if the embedded
       * XMLReader does not support the 
       * http://xml.org/sax/features/namespace-prefixes property.</p>
       *
       * @param systemId The absolute URL of the document.
       * @exception java.io.IOException If there is a problem reading
       *            the raw content of the document.
       * @exception org.xml.sax.SAXException If there is a problem
       *            processing the document.
       * @see #parse(org.xml.sax.InputSource)
       * @see org.xml.sax.Parser#parse(java.lang.String)
       */
      public void parse (String systemId)
  	throws IOException, SAXException
      {
  	parse(new InputSource(systemId));
      }
  
  
      /**
       * Parse the document.
       *
       * <p>This method will throw an exception if the embedded
       * XMLReader does not support the 
       * http://xml.org/sax/features/namespace-prefixes property.</p>
       *
       * @param input An input source for the document.
       * @exception java.io.IOException If there is a problem reading
       *            the raw content of the document.
       * @exception org.xml.sax.SAXException If there is a problem
       *            processing the document.
       * @see #parse(java.lang.String)
       * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
       */
      public void parse (InputSource input)
  	throws IOException, SAXException
      {
  	setupXMLReader();
  	xmlReader.parse(input);
      }
  
  
      /**
       * Set up the XML reader.
       */
      private void setupXMLReader ()
  	throws SAXException
      {
  	xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
  	try {
  	    xmlReader.setFeature("http://xml.org/sax/features/namespaces",
  	                         false);
  	} catch (SAXException e) {
  	    // NO OP: it's just extra information, and we can ignore it
  	}
  	xmlReader.setContentHandler(this);
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.ContentHandler.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Set a document locator.
       *
       * @param locator The document locator.
       * @see org.xml.sax.ContentHandler#setDocumentLocator
       */
      public void setDocumentLocator (Locator locator)
      {
  	documentHandler.setDocumentLocator(locator);
      }
  
  
      /**
       * Start document event.
       *
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#startDocument
       */
      public void startDocument ()
  	throws SAXException
      {
  	documentHandler.startDocument();
      }
  
  
      /**
       * End document event.
       *
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#endDocument
       */
      public void endDocument ()
  	throws SAXException
      {
  	documentHandler.endDocument();
      }
  
  
      /**
       * Adapt a SAX2 start prefix mapping event.
       *
       * @param prefix The prefix being mapped.
       * @param uri The Namespace URI being mapped to.
       * @see org.xml.sax.ContentHandler#startPrefixMapping
       */
      public void startPrefixMapping (String prefix, String uri)
      {
      }
  
  
      /**
       * Adapt a SAX2 end prefix mapping event.
       *
       * @param prefix The prefix being mapped.
       * @see org.xml.sax.ContentHandler#endPrefixMapping
       */
      public void endPrefixMapping (String prefix)
      {
      }
  
  
      /**
       * Adapt a SAX2 start element event.
       *
       * @param uri The Namespace URI.
       * @param localName The Namespace local name.
       * @param qName The qualified (prefixed) name.
       * @param atts The SAX2 attributes.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#endDocument
       */
      public void startElement (String uri, String localName,
  			      String qName, Attributes atts)
  	throws SAXException
      {
  	qAtts.setAttributes(atts);
  	documentHandler.startElement(qName, qAtts);
      }
  
  
      /**
       * Adapt a SAX2 end element event.
       *
       * @param uri The Namespace URI.
       * @param localName The Namespace local name.
       * @param qName The qualified (prefixed) name.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#endElement
       */
      public void endElement (String uri, String localName,
  			    String qName)
  	throws SAXException
      {
  	documentHandler.endElement(qName);
      }
  
  
      /**
       * Adapt a SAX2 characters event.
       *
       * @param ch An array of characters.
       * @param start The starting position in the array.
       * @param length The number of characters to use.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#characters
       */
      public void characters (char ch[], int start, int length)
  	throws SAXException
      {
  	documentHandler.characters(ch, start, length);
      }
  
  
      /**
       * Adapt a SAX2 ignorable whitespace event.
       *
       * @param ch An array of characters.
       * @param start The starting position in the array.
       * @param length The number of characters to use.
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#ignorableWhitespace
       */
      public void ignorableWhitespace (char ch[], int start, int length)
  	throws SAXException
      {
  	documentHandler.ignorableWhitespace(ch, start, length);
      }
  
  
      /**
       * Adapt a SAX2 processing instruction event.
       *
       * @param target The processing instruction target.
       * @param data The remainder of the processing instruction
       * @exception org.xml.sax.SAXException The client may raise a
       *            processing exception.
       * @see org.xml.sax.ContentHandler#processingInstruction
       */
      public void processingInstruction (String target, String data)
  	throws SAXException
      {
  	documentHandler.processingInstruction(target, data);
      }
  
  
      /**
       * Adapt a SAX2 skipped entity event.
       *
       * @param name The name of the skipped entity.
       * @see org.xml.sax.ContentHandler#skippedEntity
       */
      public void skippedEntity (String name)
  	throws SAXException
      {
      }
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal state.
      ////////////////////////////////////////////////////////////////////
  
      XMLReader xmlReader;
      DocumentHandler documentHandler;
      AttributesAdapter qAtts;
  
  
  
      ////////////////////////////////////////////////////////////////////
      // Internal class.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Internal class to wrap a SAX2 Attributes object for SAX1.
       */
      final class AttributesAdapter implements AttributeList
      {
  	AttributesAdapter ()
  	{
  	}
  
  
  	/**
  	 * Set the embedded Attributes object.
  	 *
  	 * @param The embedded SAX2 Attributes.
  	 */ 
  	void setAttributes (Attributes attributes)
  	{
  	    this.attributes = attributes;
  	}
  
  
  	/**
  	 * Return the number of attributes.
  	 *
  	 * @return The length of the attribute list.
  	 * @see org.xml.sax.AttributeList#getLength
  	 */
  	public int getLength ()
  	{
  	    return attributes.getLength();
  	}
  
  
  	/**
  	 * Return the qualified (prefixed) name of an attribute by position.
  	 *
  	 * @return The qualified name.
  	 * @see org.xml.sax.AttributeList#getName
  	 */
  	public String getName (int i)
  	{
  	    return attributes.getQName(i);
  	}
  
  
  	/**
  	 * Return the type of an attribute by position.
  	 *
  	 * @return The type.
  	 * @see org.xml.sax.AttributeList#getType(int)
  	 */
  	public String getType (int i)
  	{
  	    return attributes.getType(i);
  	}
  
  
  	/**
  	 * Return the value of an attribute by position.
  	 *
  	 * @return The value.
  	 * @see org.xml.sax.AttributeList#getValue(int)
  	 */
  	public String getValue (int i)
  	{
  	    return attributes.getValue(i);
  	}
  
  
  	/**
  	 * Return the type of an attribute by qualified (prefixed) name.
  	 *
  	 * @return The type.
  	 * @see org.xml.sax.AttributeList#getType(java.lang.String)
  	 */
  	public String getType (String qName)
  	{
  	    return attributes.getType(qName);
  	}
  
  
  	/**
  	 * Return the value of an attribute by qualified (prefixed) name.
  	 *
  	 * @return The value.
  	 * @see org.xml.sax.AttributeList#getValue(java.lang.String)
  	 */
  	public String getValue (String qName)
  	{
  	    return attributes.getValue(qName);
  	}
  
  	private Attributes attributes;
      }
  
  }
  
  // end of XMLReaderAdapter.java
  
  
  
  1.1                  xml-xalan/java/src/org/xml/sax/helpers/XMLReaderFactory.java
  
  Index: XMLReaderFactory.java
  ===================================================================
  // XMLReaderFactory.java - factory for creating a new reader.
  // Written by David Megginson, sax@megginson.com
  // NO WARRANTY!  This class is in the Public Domain.
  
  // $Id: XMLReaderFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
  
  package org.xml.sax.helpers;
  import org.xml.sax.Parser;
  import org.xml.sax.XMLReader;
  import org.xml.sax.SAXException;
  
  
  /**
   * Factory for creating an XML reader.
   *
   * <blockquote>
   * <em>This module, both source code and documentation, is in the
   * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
   * </blockquote>
   *
   * <p>This class contains static methods for creating an XML reader
   * from an explicit class name, or for creating an XML reader based
   * on the value of the <code>org.xml.sax.driver</code> system 
   * property:</p>
   *
   * <pre>
   * try {
   *   XMLReader myReader = XMLReaderFactory.createXMLReader();
   * } catch (SAXException e) {
   *   System.err.println(e.getMessage());
   * }
   * </pre>
   *
   * <p>Note that these methods will not be usable in environments where
   * system properties are not accessible or where the application or
   * applet is not permitted to load classes dynamically.</p>
   *
   * <p><strong>Note to implementors:</strong> SAX implementations in specialized
   * environments may replace this class with a different one optimized for the
   * environment, as long as its method signatures remain the same.</p>
   *
   * @since SAX 2.0
   * @author David Megginson, 
   *         <a href="mailto:sax@megginson.com">sax@megginson.com</a>
   * @version 2.0
   * @see org.xml.sax.XMLReader
   */
  final public class XMLReaderFactory
  {
  
      /**
       * Private constructor.
       *
       * <p>This constructor prevents the class from being instantiated.</p>
       */
      private XMLReaderFactory ()
      {
      }
  
  
      /**
       * Attempt to create an XML reader from a system property.
       *
       * <p>This method uses the value of the system property
       * "org.xml.sax.driver" as the full name of a Java class
       * and tries to instantiate that class as a SAX2 
       * XMLReader.</p>
       *
       * <p>Note that many Java interpreters allow system properties
       * to be specified on the command line.</p>
       *
       * @return A new XMLReader.
       * @exception org.xml.sax.SAXException If the value of the
       *            "org.xml.sax.driver" system property is null,
       *            or if the class cannot be loaded and instantiated.
       * @see #createXMLReader(java.lang.String)
       */
      public static XMLReader createXMLReader ()
  	throws SAXException
      {
  	String className = System.getProperty("org.xml.sax.driver");
  	if (className == null) {
  	    Parser parser;
  	    try {
  		parser = ParserFactory.makeParser();
  	    } catch (Exception e) {
  		parser = null;
  	    }
  	    if (parser == null) {
  		throw new
  		    SAXException("System property org.xml.sax.driver not specified");
  	    } else {
  		return new ParserAdapter(parser);
  	    }
  	} else {
  	    return createXMLReader(className);
  	}
      }
  
  
      /**
       * Attempt to create an XML reader from a class name.
       *
       * <p>Given a class name, this method attempts to load
       * and instantiate the class as an XML reader.</p>
       *
       * @return A new XML reader.
       * @exception org.xml.sax.SAXException If the class cannot be
       *            loaded, instantiated, and cast to XMLReader.
       * @see #createXMLReader()
       */
      public static XMLReader createXMLReader (String className)
  	throws SAXException
      {
  	try {
  	    return (XMLReader)(Class.forName(className).newInstance());
  	} catch (ClassNotFoundException e1) {
  	    throw new SAXException("SAX2 driver class " + className +
  				   " not found", e1);
  	} catch (IllegalAccessException e2) {
  	    throw new SAXException("SAX2 driver class " + className +
  				   " found but cannot be loaded", e2);
  	} catch (InstantiationException e3) {
  	    throw new SAXException("SAX2 driver class " + className +
  				   " loaded but cannot be instantiated (no empty public constructor?)",
  				   e3);
  	} catch (ClassCastException e4) {
  	    throw new SAXException("SAX2 driver class " + className +
  				   " does not implement XMLReader", e4);
  	}
  				   
      }
  
  }
  
  // end of XMLReaderFactory.java
  
  
  
  1.3       +29 -3     xml-xalan/java/src/serialize/OutputFormat.java
  
  Index: OutputFormat.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/OutputFormat.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OutputFormat.java	2000/09/19 21:07:06	1.2
  +++ OutputFormat.java	2000/10/02 02:43:21	1.3
  @@ -124,10 +124,10 @@
   
   
       /**
  -     * The encoding to use, if an input stream is used, null for
  +     * The encoding to use, if an input stream is used, UTF-8 for
        * the default.
        */
  -    private String _encoding = null;
  +    private String _encoding = "UTF-8";
   
   
       /**
  @@ -174,6 +174,10 @@
        */
       private boolean _preserve = false;
   
  +    /**
  +     * True if the document type should be marked as standalone.
  +     */
  +    private boolean _standalone = false;
   
   
       /**
  @@ -258,7 +262,7 @@
        *
        * @param ident True specifies identiation
        */
  -    public void setIndenting( boolean indent )
  +    public void setIndent( boolean indent )
       {
           _indent = indent;
       }
  @@ -359,6 +363,28 @@
       public String getDoctypeSystemId()
       {
           return _doctypeSystemId;
  +    }
  +    
  +    /**
  +     * Returns true if the document type is standalone.
  +     * The default is false.
  +     */
  +    public boolean getStandalone()
  +    {
  +        return _standalone;
  +    }
  +
  +
  +    /**
  +     * Sets document DTD standalone. The public and system
  +     * identifiers must be null for the document to be
  +     * serialized as standalone.
  +     *
  +     * @param standalone True if document DTD is standalone
  +     */
  +    public void setStandalone( boolean standalone )
  +    {
  +        _standalone = standalone;
       }
   
   
  
  
  
  1.3       +22 -6     xml-xalan/java/src/serialize/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/QName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QName.java	2000/09/19 21:07:06	1.2
  +++ QName.java	2000/10/02 02:43:21	1.3
  @@ -72,20 +72,26 @@
       /**
        * The local name.
        */
  -    private String _localName;
  +    protected String _localName;
   
   
       /**
        * The namespace URI.
        */
  -    private String _namespaceURI;
  +    protected String _namespaceURI;
   
   
       /**
        * The namespace prefix.
        */
  -    private String _prefix;
  +    protected String _prefix;
   
  +    /**
  +     * Constructs an empty QName.
  +     */
  +    protected QName()
  +    {
  +    }
   
   
       /**
  @@ -156,6 +162,18 @@
           return _localName;
       }
   
  +    /**
  +     * Override equals and agree that we're equal if 
  +     * the passed object is a string and it matches 
  +     * the name of the arg.
  +     */
  +    public boolean equals(String ns, String localPart)
  +    {
  +      return ( ( ( _localName == null && localPart == null ) ||
  +                 ( _localName != null && _localName.equals( localPart ) ) ) &&
  +               ( ( _namespaceURI == null && ns == null ) ||
  +                 ( _namespaceURI != null && _namespaceURI.equals( ns ) ) ) );
  +    }
   
       public boolean equals( Object object )
       {
  @@ -165,9 +183,7 @@
               return ( ( ( _localName == null && ( (QName) object )._localName == null ) ||
                          ( _localName != null && _localName.equals( ( (QName) object )._localName ) ) ) &&
                        ( ( _namespaceURI == null && ( (QName) object )._namespaceURI == null ) ||
  -                       ( _namespaceURI != null && _namespaceURI.equals( ( (QName) object )._namespaceURI ) ) ) &&
  -                     ( ( _prefix == null && ( (QName) object )._prefix == null ) ||
  -                       ( _prefix != null && _prefix.equals( ( (QName) object )._prefix ) ) ) );
  +                       ( _namespaceURI != null && _namespaceURI.equals( ( (QName) object )._namespaceURI ) ) ) );
       
           }
           return false;
  
  
  
  1.3       +192 -184  xml-xalan/java/src/serialize/SerializerFactory.java
  
  Index: SerializerFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/SerializerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SerializerFactory.java	2000/09/19 21:07:07	1.2
  +++ SerializerFactory.java	2000/10/02 02:43:22	1.3
  @@ -62,6 +62,7 @@
   import java.util.Properties;
   import java.util.StringTokenizer;
   import java.io.IOException;
  +import java.io.InputStream;
   
   
   /**
  @@ -98,199 +99,206 @@
   {
   
   
  -    /**
  -     * The name of the properties file listing all the supported
  -     * serializers. (<tt>/org/xml/serilize/serializer.properties</tt>).
  -     */
  -    public static final String PropertiesResource =
  -        "/org/xml/serilize/serializer.properties";
  -
  -
  -    /**
  -     * The name of the property listing all the supported output
  -     * methods. Contains a comma delimited list of method names.
  -     * (<tt>serialize.methods</tt>).
  -     */
  -    public static final String PropertyMethods = 
  -        "serialize.methods";
  -
  -
  -    /**
  -     * The prefix of a property supplying the class name for a
  -     * serializer implementing a specific method.
  -     * (<tt>serialize.</tt>).
  -     */
  -    public static final String PropertySerializerPrefix =
  -        "serialize.";
  -
  -
  -    /**
  -     * The prefix of a property supplying the class name for an
  -     * output format implementing a specific method.
  -     * (<tt>serialize.format.</tt>).
  -     */
  -    public static final String PropertyFormatPrefix =
  -        "serialize.format.";
  -
  -
  -    /**
  -     * Associates output methods to serializer classes.
  -     */
  -    private static Hashtable  _serializers = new Hashtable();
  -    
  -
  -    /**
  -     * Associates output methods to default output formats.
  -     */
  -    private static Hashtable  _formats = new Hashtable();
  -
  -
  -    /**
  -     * Returns a serializer for the specified output method. Returns
  -     * null if no implementation exists that supports the specified
  -     * output method. For a list of the default output methods see
  -     * {@link Method}.
  -     *
  -     * @param method The output method
  -     * @return A suitable serializer, or null
  -     */
  -    public static Serializer getSerializer( String method )
  -    {
  -        Serializer ser;
  -        Class      cls;
  -
  -        cls = (Class) _serializers.get( method );
  -        if ( cls == null )
  -            return null;
  -        try {
  -            ser = (Serializer) cls.newInstance();
  -        } catch ( Exception except ) {
  -            return null;
  -        }
  -        return ser;
  +  /**
  +   * The name of the properties file listing all the supported
  +   * serializers. (<tt>/org/xml/serilize/serializer.properties</tt>).
  +   */
  +  public static final String PropertiesResource = "serializer.properties";
  +
  +  /**
  +   * The name of the property listing all the supported output
  +   * methods. Contains a comma delimited list of method names.
  +   * (<tt>serialize.methods</tt>).
  +   */
  +  public static final String PropertyMethods = "serialize.methods";
  +
  +
  +  /**
  +   * The prefix of a property supplying the class name for a
  +   * serializer implementing a specific method.
  +   * (<tt>serialize.</tt>).
  +   */
  +  public static final String PropertySerializerPrefix = "serialize.";
  +
  +
  +  /**
  +   * The prefix of a property supplying the class name for an
  +   * output format implementing a specific method.
  +   * (<tt>serialize.format.</tt>).
  +   */
  +  public static final String PropertyFormatPrefix =
  +                                                   "serialize.format.";
  +
  +
  +  /**
  +   * Associates output methods to serializer classes.
  +   */
  +  private static Hashtable  _serializers = new Hashtable();
  +  
  +
  +  /**
  +   * Associates output methods to default output formats.
  +   */
  +  private static Hashtable  _formats = new Hashtable();
  +
  +
  +  /**
  +   * Returns a serializer for the specified output method. Returns
  +   * null if no implementation exists that supports the specified
  +   * output method. For a list of the default output methods see
  +   * {@link Method}.
  +   *
  +   * @param method The output method
  +   * @return A suitable serializer, or null
  +   */
  +  public static Serializer getSerializer( String method )
  +  {
  +    Serializer ser;
  +    Class      cls;
  +
  +    cls = (Class) _serializers.get( method );
  +    if ( cls == null )
  +      return null;
  +    try {
  +      ser = (Serializer) cls.newInstance();
  +    } catch ( Exception except ) {
  +      return null;
       }
  +    return ser;
  +  }
   
   
  -    /**
  -     * Returns a serializer for the specified output method. Returns
  -     * null if no implementation exists that supports the specified
  -     * output method. For a list of the default output methods see
  -     * {@link Method}.
  -     *
  -     * @param format The output format
  -     * @return A suitable serializer, or null
  -     */
  -    public static Serializer getSerializer( OutputFormat format )
  -    {
  -        Serializer ser;
  -        Class      cls;
  -
  -        if ( format.getMethod() == null )
  -            throw new IllegalArgumentException( "The output format has not method name" );
  -        cls = (Class) _serializers.get( format.getMethod() );
  -        if ( cls == null )
  -            return null;
  -        try {
  -            ser = (Serializer) cls.newInstance();
  -        } catch ( Exception except ) {
  -            return null;
  -        }
  -        ser.setOutputFormat( format );
  -        return ser;
  +  /**
  +   * Returns a serializer for the specified output method. Returns
  +   * null if no implementation exists that supports the specified
  +   * output method. For a list of the default output methods see
  +   * {@link Method}.
  +   *
  +   * @param format The output format
  +   * @return A suitable serializer, or null
  +   */
  +  public static Serializer getSerializer( OutputFormat format )
  +  {
  +    Serializer ser;
  +    Class      cls;
  +
  +    if ( format.getMethod() == null )
  +      throw new IllegalArgumentException( "The output format has not method name" );
  +    cls = (Class) _serializers.get( format.getMethod() );
  +    if ( cls == null )
  +      return null;
  +    try {
  +      ser = (Serializer) cls.newInstance();
  +    } catch ( Exception except ) {
  +      return null;
       }
  -
  -
  -    /**
  -     * Returns an output format for the specified output method.
  -     * An implementation may extend {@link OutputFormat} to provide
  -     * additional properties.
  -     *
  -     * @param method The output method
  -     * @return A suitable output format
  -     */
  -    public static OutputFormat getOutputFormat( String method )
  -    {
  -        OutputFormat format;
  -        Class        cls;
  -
  -        cls = (Class) _formats.get( method );
  -        if ( cls != null ) {
  -            try {
  -                format = (OutputFormat) cls.newInstance();
  -                return format;
  -            } catch ( Exception except ) { }
  -        }
  -        format = new OutputFormat();
  -        format.setMethod( method );
  +    ser.setOutputFormat( format );
  +    return ser;
  +  }
  +
  +
  +  /**
  +   * Returns an output format for the specified output method.
  +   * An implementation may extend {@link OutputFormat} to provide
  +   * additional properties.
  +   *
  +   * @param method The output method
  +   * @return A suitable output format
  +   */
  +  public static OutputFormat getOutputFormat( String method )
  +  {
  +    OutputFormat format;
  +    Class        cls;
  +
  +    cls = (Class) _formats.get( method );
  +    if ( cls != null ) {
  +      try {
  +        format = (OutputFormat) cls.newInstance();
           return format;
  +      } catch ( Exception except ) { }
       }
  -
  -
  -    /**
  -     * Returns an enumeration of all the output methods supported by this
  -     * implementation. The enumeration contains the names of all the output
  -     * methods for which this implementation provides a serializer.
  -     *
  -     * @return An enumeration of all output methods
  -     */
  -    public Enumeration listMethods()
  -    {
  -        return _serializers.keys();
  -    }
  -
  -
  -    /**
  -     * Static constructor loads serializers and output formats
  -     * from properties file.
  -     */
  -    static {
  -        Properties      props;
  -        StringTokenizer token;
  -
  -        try {
  -            props = new Properties();
  -            props.load( SerializerFactory.class.getResourceAsStream( PropertiesResource ) );
  -            if ( props.getProperty ( PropertyMethods ) == null )
  -                System.err.println( "Serializer property file has no " + PropertyMethods + " property" );
  -            else {
  -                token = new StringTokenizer( props.getProperty ( PropertyMethods ) );
  -                while ( token.hasMoreElements() ) {
  -                    String method;
  -                    String clsName;
  -                    Class  cls;
  -                    
  -                    method = token.nextToken();
  -                    // Get the serializer class that matches this output method
  -                    clsName = props.getProperty( PropertySerializerPrefix + method );
  -                    if ( clsName == null ) {
  -                        System.err.println( "Could not find property for serializer implementing output method " + method );
  -                    } else {
  -                        try {
  -                            cls = SerializerFactory.class.getClassLoader().loadClass( clsName );
  -                            _serializers.put( method, cls );
  -                        } catch ( ClassNotFoundException except ) {
  -                            System.err.println( "Could not locate serializer class " + clsName );
  -                        }
  -                    }
  -                    // Get the output format class that matches this output method
  -                    clsName = props.getProperty( PropertyFormatPrefix + method );
  -                    if ( clsName == null ) {
  -                        System.err.println( "Could not find property for output format implementing output method " + method );
  -                    } else {
  -                        try {
  -                            cls = SerializerFactory.class.getClassLoader().loadClass( clsName );
  -                            _formats.put( method, cls );
  -                        } catch ( ClassNotFoundException except ) {
  -                            System.err.println( "Could not locate output format class " + clsName );
  -                        }
  -                    }
  -                }
  +    format = new OutputFormat();
  +    format.setMethod( method );
  +    return format;
  +  }
  +
  +
  +  /**
  +   * Returns an enumeration of all the output methods supported by this
  +   * implementation. The enumeration contains the names of all the output
  +   * methods for which this implementation provides a serializer.
  +   *
  +   * @return An enumeration of all output methods
  +   */
  +  public Enumeration listMethods()
  +  {
  +    return _serializers.keys();
  +  }
  +
  +
  +  /**
  +   * Static constructor loads serializers and output formats
  +   * from properties file.
  +   */
  +  static {
  +    Properties      props;
  +    StringTokenizer token;
  +
  +    try {
  +      props = new Properties();
  +      InputStream is = SerializerFactory.class.getResourceAsStream( PropertiesResource );
  +      if(null == is)
  +        System.err.println( "Can't get serializer property file: " + PropertiesResource );
  +      props.load( is );
  +      if ( props.getProperty ( PropertyMethods ) == null )
  +        System.err.println( "Serializer property file has no " + PropertyMethods + " property" );
  +      else {
  +        token = new StringTokenizer( props.getProperty ( PropertyMethods ), ", " );
  +        while ( token.hasMoreElements() ) 
  +        {
  +          String method;
  +          String clsName;
  +          Class  cls;
  +          
  +          method = token.nextToken();
  +          // Get the serializer class that matches this output method
  +          clsName = props.getProperty( PropertySerializerPrefix + method );
  +          if ( clsName == null ) 
  +          {
  +            System.err.println( "Could not find property for serializer implementing output method " + method );
  +          } 
  +          else 
  +          {
  +            try {
  +              cls = SerializerFactory.class.getClassLoader().loadClass( clsName );
  +              _serializers.put( method, cls );
  +            } catch ( ClassNotFoundException except ) {
  +              System.err.println( "Could not locate serializer class " + clsName );
  +            }
  +          }
  +          // Get the output format class that matches this output method
  +          clsName = props.getProperty( PropertyFormatPrefix + method );
  +          if ( clsName == null ) 
  +          {
  +            // Don't complain in this case.  -sb
  +            // System.err.println( "Could not find property for output format implementing output method " + method );
  +          } 
  +          else 
  +          {
  +            try {
  +              cls = SerializerFactory.class.getClassLoader().loadClass( clsName );
  +              _formats.put( method, cls );
  +            } catch ( ClassNotFoundException except ) {
  +              System.err.println( "Could not locate output format class " + clsName );
               }
  -        } catch ( IOException except ) {
  -            System.err.println( "Error loading " + PropertiesResource + ": " +
  -                                except.toString() );
  +          }
           }
  +      }
  +    } catch ( IOException except ) {
  +      System.err.println( "Error loading " + PropertiesResource + ": " +
  +                          except.toString() );
       }
  +  }
   
   
   }
  
  
  
  1.3       +9 -6      xml-xalan/java/src/serialize/SerializerHandler.java
  
  Index: SerializerHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/SerializerHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SerializerHandler.java	2000/09/19 21:07:09	1.2
  +++ SerializerHandler.java	2000/10/02 02:43:22	1.3
  @@ -56,6 +56,7 @@
    */
   package serialize;
   
  +import org.xml.sax.SAXException;
   
   /**
    * Interface that supplements {@link org.xml.sax.DocumentHandler} and
  @@ -68,8 +69,6 @@
    */
   public interface SerializerHandler
   {
  -
  -
       /**
        * Starts an un-escaping section. All characters printed within an
        * un-escaping section are printed as is, without escaping special
  @@ -79,7 +78,8 @@
        * The contents of the un-escaping section will be delivered through
        * the regular <tt>characters</tt> event.
        */
  -    public void startNonEscaping();
  +    public void startNonEscaping()    
  +      throws SAXException;
   
   
       /**
  @@ -87,7 +87,8 @@
        *
        * @see #startNonEscaping
        */
  -    public void endNonEscaping();
  +    public void endNonEscaping()    
  +      throws SAXException;
   
   
       /**
  @@ -100,7 +101,8 @@
        * The contents of the whitespace preserving section will be delivered
        * through the regular <tt>characters</tt> event.
        */
  -    public void startPreserving();
  +    public void startPreserving()    
  +      throws SAXException;
   
   
       /**
  @@ -108,7 +110,8 @@
        *
        * @see #startPreserving
        */
  -    public void endPreserving();
  +    public void endPreserving()    
  +      throws SAXException;
   
   
   }
  
  
  
  1.2       +12 -12    xml-xalan/java/src/serialize/serializer.properties
  
  Index: serializer.properties
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/serializer.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- serializer.properties	2000/06/20 16:29:50	1.1
  +++ serializer.properties	2000/10/02 02:43:22	1.2
  @@ -1,5 +1,5 @@
   #
  -# $Revision: 1.1 $ $Date: 2000/06/20 16:29:50 $
  +# $Revision: 1.2 $ $Date: 2000/10/02 02:43:22 $
   #
   # Note: This properties file is provided for illustrative purposes
   #       only and is not part of the interface definition.
  @@ -11,21 +11,21 @@
   #
   # Lis the methods supported by this implementation
   #
  -serialize.methods=xml,html,xhtml,text,wml:wml
  +serialize.methods=xml,html,xhtml,text
   
   #
  -# Use the Xerces serializer implementations for the default methods
  +# Use the transition serializer implementations for the default methods
   #
  -serialize.xml=org.apache.xml.serialize.XMLSerializer
  -serialize.html=org.apache.xml.serialize.HTMLSerializer
  -serialize.xhtml=org.apache.xml.serialize.XHTMLSerializer
  -serialize.text=org.apache.xml.serialize.TextSerializer
  -serialize.wml:wml=org.apache.xml.serialize.WMLSerializer
  +serialize.xml=org.apache.xml.serialize.transition.XMLSerializer
  +serialize.html=org.apache.xml.serialize.transition.HTMLSerializer
  +serialize.xhtml=org.apache.xml.serialize.transition.XHTMLSerializer
  +serialize.text=org.apache.xml.serialize.transition.TextSerializer
  +# serialize.wml:wml=org.apache.xml.serialize.transition.WMLSerializer
   
   #
   # Use the helper output formats for the default methods
   #
  -serialize.format.xml=serialize.format.XMLOutputFormat
  -serialize.format.html=serialize.format.HTMLOutputFormat
  -serialize.format.xhtml=serialize.format.XHTMLOutputFormat
  -serialize.format.text=serialize.format.TextOutputFormat
  +serialize.format.xml=serialize.helpers.XMLOutputFormat
  +serialize.format.html=serialize.helpers.HTMLOutputFormat
  +serialize.format.xhtml=serialize.helpers.XHTMLOutputFormat
  +serialize.format.text=serialize.helpers.TextOutputFormat
  
  
  
  1.3       +1 -1      xml-xalan/java/src/serialize/helpers/HTMLOutputFormat.java
  
  Index: HTMLOutputFormat.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/helpers/HTMLOutputFormat.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HTMLOutputFormat.java	2000/09/19 21:07:18	1.2
  +++ HTMLOutputFormat.java	2000/10/02 02:43:22	1.3
  @@ -98,7 +98,7 @@
       public HTMLOutputFormat( boolean indenting )
       {
           this();
  -        setIndenting( indenting );
  +        setIndent( indenting );
       }
   
   
  
  
  
  1.3       +1 -1      xml-xalan/java/src/serialize/helpers/TextOutputFormat.java
  
  Index: TextOutputFormat.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/helpers/TextOutputFormat.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TextOutputFormat.java	2000/09/19 21:07:20	1.2
  +++ TextOutputFormat.java	2000/10/02 02:43:23	1.3
  @@ -95,7 +95,7 @@
       public TextOutputFormat( boolean indenting )
       {
           this();
  -        setIndenting( indenting );
  +        setIndent( indenting );
           setPreserveSpace( false );
       }
   
  
  
  
  1.3       +1 -1      xml-xalan/java/src/serialize/helpers/XHTMLOutputFormat.java
  
  Index: XHTMLOutputFormat.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/helpers/XHTMLOutputFormat.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XHTMLOutputFormat.java	2000/09/19 21:07:21	1.2
  +++ XHTMLOutputFormat.java	2000/10/02 02:43:24	1.3
  @@ -98,7 +98,7 @@
       public XHTMLOutputFormat( boolean indenting )
       {
           this();
  -        setIndenting( indenting );
  +        setIndent( indenting );
       }
   
   
  
  
  
  1.3       +1 -1      xml-xalan/java/src/serialize/helpers/XMLOutputFormat.java
  
  Index: XMLOutputFormat.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/serialize/helpers/XMLOutputFormat.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLOutputFormat.java	2000/09/19 21:07:21	1.2
  +++ XMLOutputFormat.java	2000/10/02 02:43:24	1.3
  @@ -95,7 +95,7 @@
       public XMLOutputFormat( boolean indenting )
       {
           this();
  -        setIndenting( indenting );
  +        setIndent( indenting );
           setPreserveSpace( false );
       }
   
  
  
  
  1.7       +12 -12    xml-xalan/java/src/trax/Examples.java
  
  Index: Examples.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/Examples.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Examples.java	2000/09/19 21:04:58	1.6
  +++ Examples.java	2000/10/02 02:43:24	1.7
  @@ -78,9 +78,9 @@
   import org.w3c.dom.Node;
   
   // Needed Serializer classes
  -import org.apache.xml.serialize.OutputFormat;
  -import org.apache.xml.serialize.Serializer;
  -import org.apache.xml.serialize.SerializerFactory;
  +import serialize.OutputFormat;
  +import serialize.Serializer;
  +import serialize.SerializerFactory;
   
   import javax.xml.parsers.DocumentBuilder;
   import javax.xml.parsers.DocumentBuilderFactory;
  @@ -156,8 +156,8 @@
       Transformer transformer = templates.newTransformer();
       
       // Set the result handling to be a serialization to System.out.
  -    SerializerFactory sf = SerializerFactory.getSerializerFactory("xml");
  -    Serializer serializer = sf.makeSerializer(System.out, new OutputFormat());
  +    Serializer serializer = SerializerFactory.getSerializer("xml");
  +    serializer.setOutputStream(System.out);
       transformer.setContentHandler(serializer.asContentHandler());
       
       // Cause the transformation to occur by asking the parser to send 
  @@ -185,8 +185,8 @@
       Transformer transformer = templates.newTransformer();
   
       // Set the result handling to be a serialization to System.out.
  -    SerializerFactory sf = SerializerFactory.getSerializerFactory("xml");
  -    Serializer serializer = sf.makeSerializer(System.out, new OutputFormat());
  +    Serializer serializer = SerializerFactory.getSerializer(new OutputFormat());
  +    serializer.setOutputStream(System.out);
       transformer.setContentHandler(serializer.asContentHandler());
   
       // The transformer will use a SAX parser as it's reader.    
  @@ -231,8 +231,8 @@
       transformer3.setParent(transformer2);
       
       // transform3 will output the events to the serializer.
  -    SerializerFactory sf = SerializerFactory.getSerializerFactory("xml");
  -    Serializer serializer = sf.makeSerializer(System.out, new OutputFormat());
  +    Serializer serializer = SerializerFactory.getSerializer(new OutputFormat());
  +    serializer.setOutputStream(System.out);
       transformer3.setContentHandler(serializer.asContentHandler());
   
       // Now, when you call transformer3 to parse, it will set  
  @@ -274,8 +274,8 @@
   
         transformer.transformNode(doc, new Result(outNode));
         
  -      SerializerFactory sf = SerializerFactory.getSerializerFactory("xml");
  -      Serializer serializer = sf.makeSerializer(System.out, new OutputFormat());
  +      Serializer serializer = SerializerFactory.getSerializer(new OutputFormat());
  +      serializer.setOutputStream(System.out);
         serializer.asDOMSerializer().serialize(outNode);
       }
       else
  @@ -311,7 +311,7 @@
   
       Templates templates = processor.process(new InputSource(xslID));
       OutputFormat oprops = templates.getOutputFormat();
  -    oprops.setIndenting( true );
  +    oprops.setIndent( true );
       Transformer transformer = templates.newTransformer();
       transformer.setOutputFormat(oprops);
       
  
  
  
  1.4       +1 -1      xml-xalan/java/src/trax/Templates.java
  
  Index: Templates.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/Templates.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Templates.java	2000/09/19 21:05:00	1.3
  +++ Templates.java	2000/10/02 02:43:24	1.4
  @@ -60,7 +60,7 @@
   // Software Foundation.  All rights reserved.
   package trax;
   
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   
   /**
    * The Templates object is the runtime representation of compiled 
  
  
  
  1.4       +1 -1      xml-xalan/java/src/trax/Transformer.java
  
  Index: Transformer.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/trax/Transformer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Transformer.java	2000/09/19 21:05:01	1.3
  +++ Transformer.java	2000/10/02 02:43:25	1.4
  @@ -70,7 +70,7 @@
   import org.xml.sax.ContentHandler;
   import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.ext.DeclHandler;
  -import org.apache.xml.serialize.OutputFormat;
  +import serialize.OutputFormat;
   import org.w3c.dom.Node;
   
   /**