You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/09/12 12:02:26 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DOMBuilder.java DOMImpl.java

morten      01/09/12 03:02:26

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMImpl.java
  Added:       java/src/org/apache/xalan/xsltc/dom DOMBuilder.java
  Log:
  Added support for comment nodes in the DOM. This support disappeared when
  we upgraded the DOMBuilder's interface from SAX to SAX2. Added a new
  interface for the DOMBuilder that includes SAX's ContentHandler _and_
  LexicalHandler.
  PR:		bugzilla namespace30
  Obtained from:	n/a
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.22      +29 -5     xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DOMImpl.java	2001/08/27 09:07:21	1.21
  +++ DOMImpl.java	2001/09/12 10:02:25	1.22
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.21 2001/08/27 09:07:21 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.22 2001/09/12 10:02:25 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -84,6 +84,7 @@
   import org.w3c.dom.Document;
   
   import org.xml.sax.*;
  +import org.xml.sax.ext.*;
   import org.apache.xalan.xsltc.*;
   import org.apache.xalan.xsltc.util.IntegerArray;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  @@ -2506,8 +2507,8 @@
        * This class will consume the input document through a SAX2
        * interface and populate the tree.
        */
  -    public ContentHandler getBuilder() {
  -	return new DOMBuilder();
  +    public DOMBuilder getBuilder() {
  +	return new DOMBuilderImpl();
       }
   
       /**
  @@ -2531,7 +2532,7 @@
       /****************************************************************/
       /*               DOM builder class definition                   */
       /****************************************************************/
  -    private final class DOMBuilder implements ContentHandler {
  +    private final class DOMBuilderImpl implements DOMBuilder {
   
   	private final static int ATTR_ARRAY_SIZE = 32;
   	private final static int REUSABLE_TEXT_SIZE = 32;
  @@ -2573,7 +2574,7 @@
   	/**
   	 * Default constructor for the DOMBuiler class
   	 */
  -	public DOMBuilder() {
  +	public DOMBuilderImpl() {
   	    _xmlSpaceStack[0] = DOM.ROOTNODE;
   	}
   
  @@ -3050,6 +3051,29 @@
   	    final Stack stack = (Stack)_nsPrefixes.get(prefix);
   	    if ((stack != null) && (!stack.empty())) stack.pop();
   	}
  +
  +	/**
  +	 * SAX2: Report an XML comment anywhere in the document.
  +	 */
  +	public void comment(char[] ch, int start, int length) {
  +	    if (_currentOffset + length > _text.length) {
  +		resizeTextArray(_text.length * 2);
  +	    }
  +	    System.arraycopy(ch, start, _text, _currentOffset, length);
  +	    _currentOffset += length;
  +	    final int node = makeTextNode(false);
  +	    _type[node] = COMMENT;
  +	}
  +
  +	/**
  +	 * SAX2: Ignored events
  +	 */
  +	public void startCDATA() {}
  +	public void endCDATA() {}
  +	public void startDTD(String name, String publicId, String systemId) {}
  +	public void endDTD() {}
  +	public void startEntity(String name) {}
  +	public void endEntity(String name) {}
   
   	/**
   	 * Similar to the SAX2 method character(char[], int, int), but this
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMBuilder.java
  
  Index: DOMBuilder.java
  ===================================================================
  /*
   * @(#)$Id: DOMBuilder.java,v 1.1 2001/09/12 10:02:25 morten Exp $
   *
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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 "Xalan" 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) 2001, Sun
   * Microsystems., http://www.sun.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * @author Morten Jorgensen
   *
   */
  package org.apache.xalan.xsltc.dom;
  
  import org.xml.sax.ContentHandler;
  import org.xml.sax.ext.LexicalHandler;
  
  public interface DOMBuilder extends ContentHandler, LexicalHandler { }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org