zongaro     2003/12/04 08:44:54

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMAdapter.java
                        DOMWSFilter.java DocumentCache.java KeyIndex.java
                        LoadDocument.java SAXImpl.java XSLTCDTMManager.java
               java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java BasisLibrary.java
  Added:       java/src/org/apache/xalan/xsltc DOMEnhancedForDTM.java
  Log:
  Changes to permit different DTM implementations to be supplied to XSLTC.
  
  Part of the change was to replace hard-coded references to SAXImpl with
  references to a new interface - DOMEnhancedForDTM.  This part of the change 
was
  supplied by Joseph Kesselman ([EMAIL PROTECTED]).
  
  The other part of the change was to use ObjectFactory to look up a new XSLTC
  DTM Manager service provider (org.apache.xalan.xsltc.dom.XSLTCDTMManager).  
The
  provider is looked up once when a TransformerFactory is created, and used by
  any Transformer objects created by that TransformerFactory.
  
  Revision  Changes    Path
  1.1                  
xml-xalan/java/src/org/apache/xalan/xsltc/DOMEnhancedForDTM.java
  
  Index: DOMEnhancedForDTM.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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 [EMAIL PROTECTED]
   *
   * 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, Lotus
   * Development Corporation., http://www.lotus.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.xalan.xsltc;
  
  /**
   * Interface for SAXImpl which adds methods used at run-time, over and above
   * those provided by the XSLTC DOM interface. An attempt to avoid the current
   * "Is the DTM a DOM, if so is it a SAXImpl, . . .
   * which was producing some ugly replicated code
   * and introducing bugs where that multipathing had not been
   * done.  This makes it easier to provide other DOM/DOMEnhancedForDTM
   * implementations, rather than hard-wiring XSLTC to SAXImpl.
   * 
   * @author Joseph Kesselman
   *
   */
  public interface DOMEnhancedForDTM extends DOM {
      public short[] getMapping(String[] names, String[] uris, int[] types);
      public int[] getReverseMapping(String[] names, String[] uris, int[] 
types);
      public short[] getNamespaceMapping(String[] namespaces);
      public short[] getReverseNamespaceMapping(String[] namespaces);
      public String getDocumentURI();
      public void setDocumentURI(String uri);    
      public int getExpandedTypeID2(int nodeHandle);
      public boolean hasDOMSource();
      public int getElementById(String idString);    
  }
  
  
  
  1.22      +44 -37    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
  
  Index: DOMAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DOMAdapter.java   24 Nov 2003 22:18:51 -0000      1.21
  +++ DOMAdapter.java   4 Dec 2003 16:44:53 -0000       1.22
  @@ -64,6 +64,7 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.StripFilter;
   import org.apache.xalan.xsltc.TransletException;
   import org.apache.xalan.xsltc.runtime.Hashtable;
  @@ -77,7 +78,7 @@
   public final class DOMAdapter implements DOM {
   
       // Mutually exclusive casting of DOM interface to known implementations
  -    private SAXImpl _saxImpl;
  +    private DOMEnhancedForDTM _enhancedDOM;
   
       private DOM _dom;
   
  @@ -101,8 +102,8 @@
                         String[] urisArray,
                         int[] typesArray,
                         String[] namespaceArray) {
  -        if (dom instanceof SAXImpl){
  -            _saxImpl = (SAXImpl) dom;
  +        if (dom instanceof DOMEnhancedForDTM){
  +            _enhancedDOM = (DOMEnhancedForDTM) dom;
           }
   
           _dom = dom;
  @@ -142,8 +143,9 @@
   
       private short[] getMapping() {
           if (_mapping == null) {
  -            if (_saxImpl != null) {
  -                _mapping = _saxImpl.getMapping(_namesArray, _urisArray, 
_typesArray);
  +            if (_enhancedDOM != null) {
  +                _mapping = _enhancedDOM.getMapping(_namesArray, _urisArray,
  +                                                   _typesArray);
               } 
           }
           return _mapping;
  @@ -151,8 +153,10 @@
   
       private int[] getReverse() {
        if (_reverse == null) {
  -            if (_saxImpl != null) {
  -             _reverse = _saxImpl.getReverseMapping(_namesArray, _urisArray, 
_typesArray);
  +            if (_enhancedDOM != null) {
  +             _reverse = _enhancedDOM.getReverseMapping(_namesArray,
  +                                                          _urisArray,
  +                                                          _typesArray);
               }
        }
        return _reverse;
  @@ -160,8 +164,8 @@
   
       private short[] getNSMapping() {
        if (_NSmapping == null) {
  -            if (_saxImpl != null) {
  -             _NSmapping = _saxImpl.getNamespaceMapping(_namespaceArray);
  +            if (_enhancedDOM != null) {
  +             _NSmapping = _enhancedDOM.getNamespaceMapping(_namespaceArray);
               }
        }
        return _NSmapping;
  @@ -169,8 +173,9 @@
   
       private short[] getNSReverse() {
        if (_NSreverse == null) {
  -            if (_saxImpl != null) {
  -             _NSreverse = 
_saxImpl.getReverseNamespaceMapping(_namespaceArray);
  +            if (_enhancedDOM != null) {
  +             _NSreverse = _enhancedDOM
  +                                  
.getReverseNamespaceMapping(_namespaceArray);
               }
        }
        return _NSreverse;
  @@ -188,8 +193,8 @@
       }
       
       public DTMAxisIterator getChildren(final int node) {
  -        if (_saxImpl != null) {
  -            return _saxImpl.getChildren(node);
  +        if (_enhancedDOM != null) {
  +            return _enhancedDOM.getChildren(node);
           }
           else {
               DTMAxisIterator iterator = _dom.getChildren(node);
  @@ -204,8 +209,8 @@
       public DTMAxisIterator getTypedChildren(final int type) {
           final int[] reverse = getReverse();
   
  -        if (_saxImpl != null) {
  -            return _saxImpl.getTypedChildren(reverse[type]);
  +        if (_enhancedDOM != null) {
  +            return _enhancedDOM.getTypedChildren(reverse[type]);
           }
           else {
               return _dom.getTypedChildren(type);
  @@ -218,8 +223,8 @@
       }
   
       public DTMAxisIterator getAxisIterator(final int axis) {
  -        if (_saxImpl != null) {
  -            return _saxImpl.getAxisIterator(axis);
  +        if (_enhancedDOM != null) {
  +            return _enhancedDOM.getAxisIterator(axis);
           }
           else {
               return _dom.getAxisIterator(axis);
  @@ -229,8 +234,8 @@
       public DTMAxisIterator getTypedAxisIterator(final int axis,
                                                   final int type) {
           final int[] reverse = getReverse();
  -        if (_saxImpl != null) {
  -            return _saxImpl.getTypedAxisIterator(axis, reverse[type]);
  +        if (_enhancedDOM != null) {
  +            return _enhancedDOM.getTypedAxisIterator(axis, reverse[type]);
           } else {
               return _dom.getTypedAxisIterator(axis, type);
           }      
  @@ -260,8 +265,8 @@
       }
       
       public int getExpandedTypeID(final int node) {
  -        if (_saxImpl != null) {
  -            return getMapping()[_saxImpl.getExpandedTypeID2(node)];
  +        if (_enhancedDOM != null) {
  +            return getMapping()[_enhancedDOM.getExpandedTypeID2(node)];
           }
           else {
               return getMapping()[_dom.getExpandedTypeID(node)];
  @@ -309,8 +314,8 @@
       
       public String getStringValueX(final int node) 
       {        
  -     if (_saxImpl != null) {
  -            return _saxImpl.getStringValueX(node);
  +     if (_enhancedDOM != null) {
  +            return _enhancedDOM.getStringValueX(node);
           }
           else {
               if (node == DTM.NULL) {
  @@ -335,8 +340,8 @@
       public String shallowCopy(final int node, SerializationHandler handler)
        throws TransletException 
       {
  -        if (_saxImpl != null) {
  -            return _saxImpl.shallowCopy(node, handler);
  +        if (_enhancedDOM != null) {
  +            return _enhancedDOM.shallowCopy(node, handler);
           }
           else {
               return _dom.shallowCopy(node, handler);
  @@ -351,8 +356,8 @@
       public void characters(final int textNode, SerializationHandler handler)
         throws TransletException 
       {
  -        if (_saxImpl != null) {
  -            _saxImpl.characters(textNode, handler);
  +        if (_enhancedDOM != null) {
  +            _enhancedDOM.characters(textNode, handler);
           }
           else {
               _dom.characters(textNode, handler);
  @@ -391,15 +396,15 @@
   
       public void setDocumentURI(String uri) 
       {
  -        if (_saxImpl != null) {
  -            _saxImpl.setDocumentURI(uri);
  +        if (_enhancedDOM != null) {
  +            _enhancedDOM.setDocumentURI(uri);
           }
       }
   
       public String getDocumentURI()
       {
  -        if (_saxImpl != null) {
  -            return _saxImpl.getDocumentURI();
  +        if (_enhancedDOM != null) {
  +            return _enhancedDOM.getDocumentURI();
           }
           else {
               return "";
  @@ -441,8 +446,8 @@
        */ 
       public DOM getResultTreeFrag(int initSize, int rtfType)
       {
  -     if (_saxImpl != null) {
  -         return _saxImpl.getResultTreeFrag(initSize, rtfType);
  +     if (_enhancedDOM != null) {
  +         return _enhancedDOM.getResultTreeFrag(initSize, rtfType);
        }
        else {
            return _dom.getResultTreeFrag(initSize, rtfType);
  @@ -452,10 +457,12 @@
       /**
        * Return a instance of a DOM class to be used as an RTF
        */ 
  -    public DOM getResultTreeFrag(int initSize, int rtfType, boolean 
addToManager)
  +    public DOM getResultTreeFrag(int initSize, int rtfType,
  +                                 boolean addToManager)
       {
  -     if (_saxImpl != null) {
  -         return _saxImpl.getResultTreeFrag(initSize, rtfType, addToManager);
  +     if (_enhancedDOM != null) {
  +         return _enhancedDOM.getResultTreeFrag(initSize, rtfType,
  +                                                  addToManager);
        }
        else {
            return _dom.getResultTreeFrag(initSize, rtfType, addToManager);
  
  
  
  1.4       +8 -6      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMWSFilter.java
  
  Index: DOMWSFilter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMWSFilter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMWSFilter.java  24 Nov 2003 22:18:51 -0000      1.3
  +++ DOMWSFilter.java  4 Dec 2003 16:44:53 -0000       1.4
  @@ -60,6 +60,7 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.StripFilter;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.runtime.Hashtable;
  @@ -119,8 +120,8 @@
               DOM dom = (DOM)dtm;
               int type = 0;
   
  -            if (dtm instanceof SAXImpl) {
  -                SAXImpl saxImpl = (SAXImpl)dtm;
  +            if (dtm instanceof DOMEnhancedForDTM) {
  +                DOMEnhancedForDTM mappableDOM = (DOMEnhancedForDTM)dtm;
                   
                   short[] mapping;
                   if (dtm == m_currentDTM) {
  @@ -129,16 +130,17 @@
                   else {  
                       mapping = (short[])m_mappings.get(dtm);
                       if (mapping == null) {
  -                        mapping = 
saxImpl.getMapping(m_translet.getNamesArray(),
  +                        mapping = mappableDOM.getMapping(
  +                                     m_translet.getNamesArray(),
                                        m_translet.getUrisArray(),
                                        m_translet.getTypesArray());
                           m_mappings.put(dtm, mapping);
  -                        m_currentDTM = saxImpl;
  +                        m_currentDTM = dtm;
                           m_currentMapping = mapping;
                       }
                   }
                   
  -                int expType = saxImpl.getExpandedTypeID(node);
  +                int expType = mappableDOM.getExpandedTypeID(node);
                   
                   // %OPT% The mapping array does not have information about 
all the
                   // exptypes. However it does contain enough information 
about all names
  
  
  
  1.13      +4 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java
  
  Index: DocumentCache.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DocumentCache.java        30 Jun 2003 15:34:51 -0000      1.12
  +++ DocumentCache.java        4 Dec 2003 16:44:53 -0000       1.13
  @@ -78,6 +78,7 @@
   
   import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.DOMCache;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.Translet;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  @@ -115,7 +116,7 @@
        private long _buildTime;
   
        // DOM and DTD handler references
  -     private SAXImpl    _dom = null;
  +     private DOMEnhancedForDTM _dom = null;
        
        /**
         * Constructor - load document and initialise statistics
  @@ -138,7 +139,7 @@
   
            try {
                final long stamp = System.currentTimeMillis();
  -                _dom = (SAXImpl)_dtmManager.getDTM(
  +                _dom = (DOMEnhancedForDTM)_dtmManager.getDTM(
                                    new SAXSource(_reader, new 
InputSource(uri)),
                                    false, null, true, false);
                _dom.setDocumentURI(uri);
  
  
  
  1.12      +14 -11    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
  
  Index: KeyIndex.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- KeyIndex.java     1 Apr 2003 21:39:16 -0000       1.11
  +++ KeyIndex.java     4 Dec 2003 16:44:53 -0000       1.12
  @@ -66,6 +66,7 @@
   import java.util.StringTokenizer;
   
   import org.apache.xalan.xsltc.DOM;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.runtime.Hashtable;
   import org.apache.xalan.xsltc.util.IntegerArray;
   import org.apache.xml.dtm.DTM;
  @@ -91,7 +92,7 @@
        */
       private DOM        _dom;
       
  -    private SAXImpl    _saxImpl;
  +    private DOMEnhancedForDTM    _enhancedDOM;
   
       /**
        * Store position after call to setMark()
  @@ -148,7 +149,8 @@
               final String token = (String) values.nextElement();
            IntegerArray nodes = (IntegerArray) _index.get(token);
   
  -            if (nodes == null && _saxImpl != null && 
_saxImpl.hasDOMSource()) {
  +            if (nodes == null && _enhancedDOM != null
  +                && _enhancedDOM.hasDOMSource()) {
                   nodes = getDOMNodeById(token);
               }
   
  @@ -171,8 +173,8 @@
        */
       public IntegerArray getDOMNodeById(String id) {
           IntegerArray nodes = null;
  -        if (_saxImpl != null) {
  -            int ident = _saxImpl.getElementById(id);
  +        if (_enhancedDOM != null) {
  +            int ident = _enhancedDOM.getElementById(id);
               if (ident != DTM.NULL) {
                nodes = new IntegerArray();
                _index.put(id, nodes);
  @@ -210,7 +212,8 @@
                   final String token = (String) values.nextElement();
                IntegerArray nodes = (IntegerArray) _index.get(token);
   
  -             if (nodes == null && _saxImpl != null && 
_saxImpl.hasDOMSource()) {
  +             if (nodes == null && _enhancedDOM != null
  +                    && _enhancedDOM.hasDOMSource()) {
                    nodes = getDOMNodeById(token);      
                }
                if (nodes != null && nodes.indexOf(node) >= 0) {
  @@ -221,7 +224,7 @@
        }
        else {
            IntegerArray nodes = (IntegerArray) _index.get(value);
  -            if (nodes == null && _saxImpl != null && 
_saxImpl.hasDOMSource()) {
  +            if (nodes == null && _enhancedDOM != null && 
_enhancedDOM.hasDOMSource()) {
                   nodes = getDOMNodeById(string);
               }
            return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
  @@ -311,13 +314,13 @@
       
       public void setDom(DOM dom) {
        _dom = dom;
  -     if (dom instanceof SAXImpl) {
  -         _saxImpl = (SAXImpl)dom;
  +     if (dom instanceof DOMEnhancedForDTM) {
  +         _enhancedDOM = (DOMEnhancedForDTM)dom;
        }
        else if (dom instanceof DOMAdapter) {
            DOM idom = ((DOMAdapter)dom).getDOMImpl();
  -         if (idom instanceof SAXImpl) {
  -             _saxImpl = (SAXImpl)idom;
  +         if (idom instanceof DOMEnhancedForDTM) {
  +             _enhancedDOM = (DOMEnhancedForDTM)idom;
            }
        }
       }
  
  
  
  1.24      +18 -13    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java
  
  Index: LoadDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- LoadDocument.java 30 Jun 2003 18:45:38 -0000      1.23
  +++ LoadDocument.java 4 Dec 2003 16:44:53 -0000       1.24
  @@ -68,6 +68,7 @@
   
   import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.DOMCache;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.TransletException;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.trax.TemplatesImpl;
  @@ -211,20 +212,21 @@
           if (mask != -1) {
               DOM newDom = ((DOMAdapter)multiplexer.getDOMAdapter(uri))
                                          .getDOMImpl();
  -            if (newDom instanceof SAXImpl) {
  -                return new SingletonIterator(((SAXImpl)newDom).getDocument(),
  +            if (newDom instanceof DOMEnhancedForDTM) {
  +                return new SingletonIterator(((DOMEnhancedForDTM)newDom)
  +                                                               
.getDocument(),
                                                true);
               } 
           }
   
           // Check if we can get the DOM from a DOMCache
           DOMCache cache = translet.getDOMCache();
  -        SAXImpl newdom;
  +        DOM newdom;
   
           mask = multiplexer.nextMask(); // peek
   
           if (cache != null) {
  -            newdom = (SAXImpl)cache.retrieveDocument(base, originalUri, 
translet);
  +            newdom = cache.retrieveDocument(base, originalUri, translet);
               if (newdom == null) {
                   final Exception e = new FileNotFoundException(originalUri);
                   throw new TransletException(e);
  @@ -233,21 +235,24 @@
               // Parse the input document and construct DOM object
               // Trust the DTMManager to pick the right parser and
               // set up the DOM correctly.
  -            XSLTCDTMManager dtmManager = 
(XSLTCDTMManager)multiplexer.getDTMManager();
  -            newdom = (SAXImpl)dtmManager.getDTM(new StreamSource(uri),
  -                                       false, null, true, false,
  -                                       translet.hasIdCall(), cacheDOM);
  -                                
  +            XSLTCDTMManager dtmManager = (XSLTCDTMManager)multiplexer
  +                                                              
.getDTMManager();
  +            DOMEnhancedForDTM enhancedDOM =
  +                    (DOMEnhancedForDTM) dtmManager.getDTM(new 
StreamSource(uri),
  +                                            false, null, true, false,
  +                                            translet.hasIdCall(), cacheDOM);
  +            newdom = enhancedDOM;
  +
               // Cache the stylesheet DOM in the Templates object
               if (cacheDOM) {
                   TemplatesImpl templates = 
(TemplatesImpl)translet.getTemplates();
                   if (templates != null) {
  -                    templates.setStylesheetDOM(newdom);
  +                    templates.setStylesheetDOM(enhancedDOM);
                   }
               }
               
  -            translet.prepassDocument(newdom);
  -            newdom.setDocumentURI(uri);
  +            translet.prepassDocument(enhancedDOM);
  +            enhancedDOM.setDocumentURI(uri);
           }
   
           // Wrap the DOM object in a DOM adapter and add to multiplexer
  
  
  
  1.15      +4 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java
  
  Index: SAXImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SAXImpl.java      24 Nov 2003 22:18:51 -0000      1.14
  +++ SAXImpl.java      4 Dec 2003 16:44:53 -0000       1.15
  @@ -73,6 +73,7 @@
   import javax.xml.transform.dom.DOMSource;
   
   import org.apache.xalan.xsltc.DOM;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.StripFilter;
   import org.apache.xalan.xsltc.TransletException;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  @@ -113,7 +114,8 @@
    *
    * <p>SAXImpl extends SAX2DTM2 instead of SAX2DTM for better performance.
    */
  -public final class SAXImpl extends SAX2DTM2 implements DOM, DOMBuilder
  +public final class SAXImpl extends SAX2DTM2
  +                           implements DOMEnhancedForDTM, DOMBuilder
   {
       
       /* ------------------------------------------------------------------- */
  
  
  
  1.4       +36 -9     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/XSLTCDTMManager.java
  
  Index: XSLTCDTMManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/XSLTCDTMManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLTCDTMManager.java      23 Jun 2003 15:23:39 -0000      1.3
  +++ XSLTCDTMManager.java      4 Dec 2003 16:44:53 -0000       1.4
  @@ -68,6 +68,7 @@
   import org.apache.xml.dtm.ref.DTMManagerDefault;
   import org.apache.xml.res.XMLErrorResources;
   import org.apache.xml.res.XMLMessages;
  +import org.apache.xml.utils.ObjectFactory;
   import org.apache.xml.utils.SystemIDResolver;
   import org.apache.xalan.xsltc.trax.DOM2SAX;
   
  @@ -83,7 +84,10 @@
   {
        
       /** The default class name to use as the manager. */
  -    private static String defaultClassName =
  +    private static final String DEFAULT_CLASS_NAME =
  +        "org.apache.xalan.xsltc.dom.XSLTCDTMManager";
  +
  +    private static final String DEFAULT_PROP_NAME =
           "org.apache.xalan.xsltc.dom.XSLTCDTMManager";
   
       /** Set this to true if you want a dump of the DTM after creation */
  @@ -92,7 +96,6 @@
       /** Set this to true if you want basic diagnostics */
       private static final boolean DEBUG = false;
   
  -
       /**
        * Constructor DTMManagerDefault
        *
  @@ -101,23 +104,43 @@
       {
           super();
       } 
  -  
  +
       /**
        * Obtain a new instance of a <code>DTMManager</code>.
        * This static method creates a new factory instance.
        * The current implementation just returns a new XSLTCDTMManager 
instance.
  -     *
  -     * %REVISIT% Do we need the factory lookup mechanism for class loading 
here?
  -     * Factory lookup will add a lot of complexity and also has a 
performance hit.
  -     * There is currently no need to do it unless it is proved to be useful.
        */
       public static XSLTCDTMManager newInstance()
       {
  -        XSLTCDTMManager factoryImpl = new XSLTCDTMManager();
  -        return factoryImpl;
  +        return new XSLTCDTMManager();
       } 
   
       /**
  +     * Look up the class that provides the XSLTC DTM Manager service.
  +     * The following lookup procedure is used to find the service provider.
  +     * <ol>
  +     * <li>The value of the
  +     * <code>org.apache.xalan.xsltc.dom.XSLTCDTMManager</code> property, is
  +     * checked.</li>
  +     * <li>The <code>xalan.propeties</code> file is checked for a property
  +     * of the same name.</li>
  +     * <li>The
  +     * 
<code>META-INF/services/org.apache.xalan.xsltc.dom.XSLTCDTMManager</code>
  +     * file is checked.
  +     * </ol>
  +     * The default is 
<code>org.apache.xalan.xsltc.dom.XSLTCDTMManager</code>.
  +     */
  +    public static Class getDTMManagerClass() {
  +        Class mgrClass = ObjectFactory.lookUpFactoryClass(DEFAULT_PROP_NAME,
  +                                                          null,
  +                                                          
DEFAULT_CLASS_NAME);
  +        // If no class found, default to this one.  (This should never 
happen -
  +        // the ObjectFactory has already been told that the current class is
  +        // the default).
  +        return (mgrClass != null) ? mgrClass : XSLTCDTMManager.class;
  +    }
  +
  +    /**
        * Get an instance of a DTM, loaded with the content from the
        * specified source.  If the unique flag is true, a new instance will
        * always be returned.  Otherwise it is up to the DTMManager to return a
  @@ -407,6 +430,10 @@
                   }
                   catch (Exception e) {
                       throw new 
org.apache.xml.utils.WrappedRuntimeException(e);
  +                } finally {
  +                    if (!hasUserReader) {
  +                        releaseXMLReader(reader);
  +                    }
                   }
   
                   if (DUMPTREE) {
  
  
  
  1.51      +6 -6      
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- AbstractTranslet.java     24 Nov 2003 22:18:54 -0000      1.50
  +++ AbstractTranslet.java     4 Dec 2003 16:44:53 -0000       1.51
  @@ -77,11 +77,11 @@
   
   import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.DOMCache;
  +import org.apache.xalan.xsltc.DOMEnhancedForDTM;
   import org.apache.xalan.xsltc.Translet;
   import org.apache.xalan.xsltc.TransletException;
   import org.apache.xalan.xsltc.dom.DOMAdapter;
   import org.apache.xalan.xsltc.dom.KeyIndex;
  -import org.apache.xalan.xsltc.dom.SAXImpl;
   import org.apache.xalan.xsltc.runtime.output.TransletOutputHandlerFactory;
   import org.apache.xml.dtm.DTMAxisIterator;
   import org.apache.xml.serializer.SerializationHandler;
  @@ -343,18 +343,18 @@
        */
       private final void buildIDIndex(DOM document) {
           
  -        if (document instanceof SAXImpl) {
  -            SAXImpl saxImpl = (SAXImpl)document;
  +        if (document instanceof DOMEnhancedForDTM) {
  +            DOMEnhancedForDTM enhancedDOM = (DOMEnhancedForDTM)document;
               
               // If the input source is DOMSource, the KeyIndex table is not
               // built at this time. It will be built later by the lookupId()
               // and containsId() methods of the KeyIndex class.
  -            if (saxImpl.hasDOMSource()) {
  +            if (enhancedDOM.hasDOMSource()) {
                   buildKeyIndex(ID_INDEX_NAME, document);
                   return;
               }
               else {
  -                final Hashtable elementsByID = saxImpl.getElementsWithIDs();
  +                final Hashtable elementsByID = 
enhancedDOM.getElementsWithIDs();
   
                   if (elementsByID == null) {
                    return;
  
  
  
  1.65      +3 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- BasisLibrary.java 24 Nov 2003 22:18:54 -0000      1.64
  +++ BasisLibrary.java 4 Dec 2003 16:44:53 -0000       1.65
  @@ -82,7 +82,6 @@
   import org.apache.xalan.xsltc.dom.AbsoluteIterator;
   import org.apache.xalan.xsltc.dom.Axis;
   import org.apache.xalan.xsltc.dom.DOMAdapter;
  -import org.apache.xalan.xsltc.dom.SAXImpl;
   import org.apache.xalan.xsltc.dom.MultiDOM;
   import org.apache.xalan.xsltc.dom.SingletonIterator;
   import org.apache.xalan.xsltc.dom.StepIterator;
  @@ -1191,8 +1190,8 @@
            DTMDefaultBase dtm = 
(DTMDefaultBase)((DOMAdapter)multiDOM.getMain()).getDOMImpl();
            DTMManager dtmManager = dtm.getManager();
            
  -         SAXImpl idom = (SAXImpl)dtmManager.getDTM(new DOMSource(doc), false,
  -                                                   null, true, false);
  +         DOM idom = (DOM)dtmManager.getDTM(new DOMSource(doc), false,
  +                                           null, true, false);
            // Create DOMAdapter and register with MultiDOM
            DOMAdapter domAdapter = new DOMAdapter(idom, 
                   translet.getNamesArray(),
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to