zongaro     2002/09/26 06:58:38

  Modified:    java/src/org/apache/xalan/lib Tag: XSLTC_DTM ExsltMath.java
                        ExsltSets.java
               java/src/org/apache/xalan/res Tag: XSLTC_DTM
                        XSLTErrorResources.java
               java/src/org/apache/xalan/templates Tag: XSLTC_DTM
                        ElemAttribute.java
               java/src/org/apache/xalan/transformer Tag: XSLTC_DTM
                        ResultTreeHandler.java
               java/src/org/apache/xalan/xsltc/trax Tag: XSLTC_DTM
                        SAX2DOM.java TransformerFactoryImpl.java
               java/src/org/apache/xpath Tag: XSLTC_DTM DOMHelper.java
  Log:
  Folding changes from MAIN branch back into XSLTC_DTM branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.4   +1 -35     xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java
  
  Index: ExsltMath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- ExsltMath.java    20 Sep 2002 22:11:57 -0000      1.2.2.3
  +++ ExsltMath.java    26 Sep 2002 13:58:36 -0000      1.2.2.4
  @@ -58,12 +58,7 @@
   
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  -
   import org.apache.xpath.NodeSet;
  -import org.apache.xpath.DOMHelper;
  -import org.apache.xml.dtm.ref.DTMNodeProxy;
  -
  -import java.util.Hashtable;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -79,7 +74,7 @@
    * @see <a href="http://www.exslt.org/";>EXSLT</a>
   
    */
  -public class ExsltMath
  +public class ExsltMath extends ExsltBase
   {
     // Constants
     private static String PI = 
"3.1415926535897932384626433832795028841971693993751";
  @@ -234,35 +229,6 @@
       return lowNodes;
     }
     
  -  /**
  -   *  Return the string value of a Node
  -   */
  -  private static String toString(Node n)
  -  {
  -     if (n instanceof DTMNodeProxy)
  -      return ((DTMNodeProxy)n).getStringValue();
  -     else
  -      return n.getNodeValue();
  -  }
  -  
  -  /**
  -   * Convert the string value of a Node to a number
  -   */
  -  private static double toNumber(Node n)
  -  {
  -     double d = 0.0;
  -     String str = toString(n);
  -     try
  -     {
  -       d = Double.parseDouble(str);
  -     }
  -     catch (NumberFormatException e)
  -     {
  -       d= Double.NaN;                
  -     }
  -     return d;
  -  }
  -
     /**
      * The math:abs function returns the absolute value of a number. 
      */
  
  
  
  1.2.2.3   +4 -14     xml-xalan/java/src/org/apache/xalan/lib/ExsltSets.java
  
  Index: ExsltSets.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltSets.java,v
  retrieving revision 1.2.2.2
  retrieving revision 1.2.2.3
  diff -u -r1.2.2.2 -r1.2.2.3
  --- ExsltSets.java    12 Sep 2002 16:07:31 -0000      1.2.2.2
  +++ ExsltSets.java    26 Sep 2002 13:58:36 -0000      1.2.2.3
  @@ -58,15 +58,9 @@
   
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  -import org.w3c.dom.traversal.NodeIterator;
  -
   import org.apache.xpath.NodeSet;
   import org.apache.xpath.DOMHelper;
  -import org.apache.xml.dtm.ref.DTMNodeProxy;
   import java.util.Hashtable;
  -
  -import org.apache.xalan.extensions.ExpressionContext;
  -
   import javax.xml.parsers.*;
   
   /**
  @@ -82,7 +76,7 @@
    * 
    * @see <a href="http://www.exslt.org/";>EXSLT</a>
    */
  -public class ExsltSets
  +public class ExsltSets extends ExsltBase
   {   
     /**
      * The set:leading function returns the nodes in the node set passed as 
the first argument that
  @@ -113,7 +107,7 @@
       {
         Node testNode = nl1.item(i);
         if (DOMHelper.isNodeAfter(testNode, endNode) 
  -          && !(testNode == endNode || DOMHelper.isNodeTheSame(testNode, 
endNode)))
  +          && !DOMHelper.isNodeTheSame(testNode, endNode))
           leadNodes.addElement(testNode);
       }
       return leadNodes;
  @@ -148,7 +142,7 @@
       {
         Node testNode = nl1.item(i);
         if (DOMHelper.isNodeAfter(startNode, testNode) 
  -          && !(startNode == testNode || DOMHelper.isNodeTheSame(startNode, 
testNode)))
  +          && !DOMHelper.isNodeTheSame(startNode, testNode))
           trailNodes.addElement(testNode);          
       }
       return trailNodes;
  @@ -237,11 +231,7 @@
       for (int i = 0; i < nl.getLength(); i++)
       {
         Node currNode = nl.item(i);
  -      String key = null;
  -      if (currNode instanceof DTMNodeProxy)
  -        key = ((DTMNodeProxy)currNode).getStringValue();
  -      else
  -        key = currNode.getNodeValue();
  +      String key = toString(currNode);
         
         if (key == null)
           dist.addElement(currNode);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.23.10.2 +23 -0     
xml-xalan/java/src/org/apache/xalan/res/XSLTErrorResources.java
  
  Index: XSLTErrorResources.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/res/XSLTErrorResources.java,v
  retrieving revision 1.23.10.1
  retrieving revision 1.23.10.2
  diff -u -r1.23.10.1 -r1.23.10.2
  --- XSLTErrorResources.java   29 Jul 2002 00:01:18 -0000      1.23.10.1
  +++ XSLTErrorResources.java   26 Sep 2002 13:58:36 -0000      1.23.10.2
  @@ -1051,8 +1051,28 @@
   
     // Illegal value\u003a {1} used for number attribute\u003a {0}. 
     public static final int INVALID_NUMBER = 247;
  +
  +  
     // End of shared codes...
     
  +  // Argument to {0} in match pattern must be a literal.
  +  public static final int ER_ARG_LITERAL             = 248;
  +  
  +  // Duplicate global variable declaration.
  +  public static final int ER_DUPLICATE_GLOBAL_VAR    = 249;
  +  
  +  // Duplicate variable declaration.
  +  public static final int ER_DUPLICATE_VAR           = 250;
  +  
  +  // xsl:template must have a name or match attribute (or both)
  +  public static final int ER_TEMPLATE_NAME_MATCH     = 251;    
  +  
  +  // Prefix in exclude-result-prefixes is not valid\u003a {0}
  +  public static final int ER_INVALID_PREFIX          = 252;
  +  
  +  // attribute-set named {0} does not exist
  +  public static final int ER_NO_ATTRIB_SET           = 253;
  +
   
   
     /*
  @@ -1210,6 +1230,9 @@
     
     /** WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME          */
     public static final int WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME = 28;  
  +  
  +  /** WG_ILLEGAL_ATTRIBUTE_POSITION         */
  +  public static final int WG_ILLEGAL_ATTRIBUTE_POSITION = 29;
     
     
     //The following warning codes are shared with the error codes ... 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.17.2.2  +21 -19    
xml-xalan/java/src/org/apache/xalan/templates/ElemAttribute.java
  
  Index: ElemAttribute.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemAttribute.java,v
  retrieving revision 1.17.2.1
  retrieving revision 1.17.2.2
  diff -u -r1.17.2.1 -r1.17.2.2
  --- ElemAttribute.java        29 Jul 2002 00:01:19 -0000      1.17.2.1
  +++ ElemAttribute.java        26 Sep 2002 13:58:37 -0000      1.17.2.2
  @@ -124,25 +124,27 @@
   
       // If they are trying to add an attribute when there isn't an 
       // element pending, it is an error.
  -    if (!rhandler.isElementPending())
  -    {
  -      // Make sure the trace event is sent.
  -      if (TransformerImpl.S_DEBUG)
  -        transformer.getTraceManager().fireTraceEvent(this);
  -
  -      XPathContext xctxt = transformer.getXPathContext();
  -      int sourceNode = xctxt.getCurrentNode();
  -      String attrName = m_name_avt.evaluate(xctxt, sourceNode, this);
  -      transformer.getMsgMgr().warn(this,
  -                                   XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE,
  -                                   new Object[]{ attrName });
  -
  -      if (TransformerImpl.S_DEBUG)
  -        transformer.getTraceManager().fireTraceEndEvent(this);
  -      return;
  -
  -      // warn(templateChild, sourceNode, "Trying to add attribute after 
element child has been added, ignoring...");
  -    }
  +    // I don't think we need this check here because it is checked in 
  +    // ResultTreeHandler.addAttribute.  (is)
  +//    if (!rhandler.isElementPending())
  +//    {
  +//      // Make sure the trace event is sent.
  +//      if (TransformerImpl.S_DEBUG)
  +//        transformer.getTraceManager().fireTraceEvent(this);
  +//
  +//      XPathContext xctxt = transformer.getXPathContext();
  +//      int sourceNode = xctxt.getCurrentNode();
  +//      String attrName = m_name_avt.evaluate(xctxt, sourceNode, this);
  +//      transformer.getMsgMgr().warn(this,
  +//                                   
XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE_POSITION,
  +//                                   new Object[]{ attrName });
  +//
  +//      if (TransformerImpl.S_DEBUG)
  +//        transformer.getTraceManager().fireTraceEndEvent(this);
  +//      return;
  +//
  +//      // warn(templateChild, sourceNode, "Trying to add attribute after 
element child has been added, ignoring...");
  +//    }
       
       super.execute(transformer);
       
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.55.2.2  +32 -21    
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.55.2.1
  retrieving revision 1.55.2.2
  diff -u -r1.55.2.1 -r1.55.2.2
  --- ResultTreeHandler.java    29 Jul 2002 00:01:20 -0000      1.55.2.1
  +++ ResultTreeHandler.java    26 Sep 2002 13:58:37 -0000      1.55.2.2
  @@ -58,6 +58,8 @@
   
   import java.util.Enumeration;
   
  +import org.apache.xalan.processor.StylesheetHandler;
  +import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xalan.templates.Stylesheet;
   import org.apache.xalan.templates.StylesheetRoot;
   import org.apache.xalan.templates.ElemTemplate;
  @@ -984,6 +986,7 @@
                    n = dtm.getNextSibling(n))
            {
              flushPending(true);  // I think.
  +          startPrefixMapping("","");
              dtm.dispatchToEvents(n, this);
            }
       }
  @@ -1429,34 +1432,42 @@
       // an error? Technically, this can't happen unless the stylesheet
       // is unreasonable... but it's unclear whether silent or noisy
       // failure is called for.
  +    // Will add an "else" and emit a warning message.  This should
  +    // cover testcases such as copyerr04-07, attribset19,34,35, 
  +    // attribseterr08...(is)
       if (m_elemIsPending)
       {
  -      // %REVIEW% %OPT% Is this ever needed?????
  -      // The check is not needed. See Bugzilla 10306. 
  -      // if (!m_nsDeclsHaveBeenAdded)
  -     addNSDeclsToAttrs();
  +        // %REVIEW% %OPT% Is this ever needed?????
  +        // The check is not needed. See Bugzilla 10306. 
  +        // if (!m_nsDeclsHaveBeenAdded)
  +        addNSDeclsToAttrs();
   
  -      if (null == uri)  // defensive, should not really need this.
  -     uri = "";
  +        if (null == uri) { // defensive, should not really need this.
  +            uri = "";
  +        }
   
  -      try
  -      {
  -     if (!rawName.equals("xmlns"))  // don't handle xmlns default namespace.
  -       ensurePrefixIsDeclared(uri, rawName);
  -      }
  -      catch (org.xml.sax.SAXException se)
  -      {
  -     throw new TransformerException(se);
  -      }
  +        try {
  +            if (!rawName.equals("xmlns")) { // don't handle xmlns default 
namespace.
  +                ensurePrefixIsDeclared(uri, rawName);
  +            }    
  +        } catch (org.xml.sax.SAXException se) {
  +            throw new TransformerException(se);
  +        }
         
  -      if (DEBUG)
  -     System.out.println("ResultTreeHandler#addAttribute Adding attr: "
  +        if (DEBUG) {
  +            System.out.println("ResultTreeHandler#addAttribute Adding attr: "
                           + localName + ", " + uri);
  -
  -      if (!isDefinedNSDecl(rawName, value))
  -     m_attributes.addAttribute(uri, localName, rawName, type, value);
  +        }
  +        
  +        if (!isDefinedNSDecl(rawName, value)) {
  +            m_attributes.addAttribute(uri, localName, rawName, type, value);
  +        }
  +    } else {
  +        m_transformer.getMsgMgr().warn(m_stylesheetRoot,
  +                                   
XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE_POSITION,
  +                                   new Object[]{ localName });
       }
  -  }
  +}
   
     /**
      * Return whether or not a namespace declaration is defined
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.2.2  +20 -12    
xml-xalan/java/src/org/apache/xalan/xsltc/trax/SAX2DOM.java
  
  Index: SAX2DOM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/SAX2DOM.java,v
  retrieving revision 1.10.2.1
  retrieving revision 1.10.2.2
  diff -u -r1.10.2.1 -r1.10.2.2
  --- SAX2DOM.java      29 Jul 2002 00:01:29 -0000      1.10.2.1
  +++ SAX2DOM.java      26 Sep 2002 13:58:37 -0000      1.10.2.2
  @@ -86,24 +86,31 @@
   
   public class SAX2DOM implements ContentHandler, LexicalHandler, Constants {
   
  -    private Document _root = null;
  +    private Node _root = null;
  +    private Document _document = null;
       private Stack _nodeStk = new Stack();
       private Vector _namespaceDecls = null;
   
       public SAX2DOM() throws ParserConfigurationException {
        final DocumentBuilderFactory factory = 
                DocumentBuilderFactory.newInstance();
  -     _root = factory.newDocumentBuilder().newDocument();
  +     _document = factory.newDocumentBuilder().newDocument();
  +     _root = _document;
       }
   
       public SAX2DOM(Node root) throws ParserConfigurationException {
  -     if (root != null) {
  -         _root = (Document) root;   // TODO: add support for frags and elems
  +     _root = root;
  +     if (root instanceof Document) {
  +       _document = (Document)root;
  +     }
  +     else if (root != null) {
  +       _document = root.getOwnerDocument();
        }
        else {
  -         final DocumentBuilderFactory factory = 
  +       final DocumentBuilderFactory factory = 
                DocumentBuilderFactory.newInstance();
  -         _root = factory.newDocumentBuilder().newDocument();
  +       _document = factory.newDocumentBuilder().newDocument();
  +       _root = _document;
        }
       }
   
  @@ -115,9 +122,9 @@
        final Node last = (Node)_nodeStk.peek();
   
        // No text nodes can be children of root (DOM006 exception)
  -     if (last != _root) {
  +     if (last != _document) {
            final String text = new String(ch, start, length);
  -         last.appendChild(_root.createTextNode(text));
  +         last.appendChild(_document.createTextNode(text));
        }
       }
   
  @@ -126,12 +133,13 @@
       }
   
       public void endDocument() {
  +        _nodeStk.pop();
       }
   
       public void startElement(String namespace, String localName, String 
qName,
        Attributes attrs) 
       {
  -     final Element tmp = (Element)_root.createElementNS(namespace, qName);
  +     final Element tmp = (Element)_document.createElementNS(namespace, 
qName);
   
        // Add namespace declarations first
        if (_namespaceDecls != null) {
  @@ -199,7 +207,7 @@
        */
       public void processingInstruction(String target, String data) {
        final Node last = (Node)_nodeStk.peek();
  -     ProcessingInstruction pi = _root.createProcessingInstruction(
  +     ProcessingInstruction pi = _document.createProcessingInstruction(
                target, data);
        if (pi != null)  last.appendChild(pi);
       }
  @@ -224,7 +232,7 @@
        */
       public void comment(char[] ch, int start, int length) {
        final Node last = (Node)_nodeStk.peek();
  -     Comment comment = _root.createComment(new String(ch,start,length));
  +     Comment comment = _document.createComment(new String(ch,start,length));
        if (comment != null) last.appendChild(comment);
       }
   
  
  
  
  1.34.2.4  +26 -10    
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
  retrieving revision 1.34.2.3
  retrieving revision 1.34.2.4
  diff -u -r1.34.2.3 -r1.34.2.4
  --- TransformerFactoryImpl.java       18 Sep 2002 15:56:48 -0000      1.34.2.3
  +++ TransformerFactoryImpl.java       26 Sep 2002 13:58:38 -0000      1.34.2.4
  @@ -126,6 +126,12 @@
        */
       private Hashtable _piParams = null;
   
  +
  +    /**
  +     * Use a thread local variable to store a copy of an XML Reader.
  +     */
  +    static ThreadLocal _xmlReader = new ThreadLocal();
  +
       /**
        * The above hashtable stores objects of this class.
        */
  @@ -157,9 +163,9 @@
       private int _indentNumber = -1;
   
       /**
  -     * A reference to an XML reader for parsing.
  +     * A reference to a SAXParserFactory.
        */
  -    private XMLReader _xmlReader = null;
  +    private SAXParserFactory _parserFactory = null;
   
       /**
        * javax.xml.transform.sax.TransformerFactory implementation.
  @@ -724,13 +730,23 @@
        return null;
       }
   
  -    public XMLReader getXMLReader() throws Exception {
  -     if (_xmlReader == null) {
  -         final SAXParserFactory pfactory 
  -             = SAXParserFactory.newInstance();
  -         pfactory.setNamespaceAware(true);
  -         _xmlReader = pfactory.newSAXParser().getXMLReader();
  +    /**
  +     * This method is synchronized to allow instances of this class to 
  +     * be shared among threads. A tranformer object will call this 
  +     * method to get an XMLReader. A different instance of an XMLReader
  +     * is returned/cached for each thread.
  +     */
  +    public synchronized XMLReader getXMLReader() throws Exception {
  +     // First check if factory is instantiated
  +     if (_parserFactory == null) {
  +         _parserFactory = SAXParserFactory.newInstance();
  +         _parserFactory.setNamespaceAware(true);
  +     }
  +     XMLReader result = (XMLReader) _xmlReader.get();
  +     if (result == null) {
  +         _xmlReader.set(
  +             result = _parserFactory.newSAXParser().getXMLReader());
        }
  -     return _xmlReader;
  +     return result;
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.29.2.1  +2 -3      xml-xalan/java/src/org/apache/xpath/DOMHelper.java
  
  Index: DOMHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/DOMHelper.java,v
  retrieving revision 1.29
  retrieving revision 1.29.2.1
  diff -u -r1.29 -r1.29.2.1
  --- DOMHelper.java    22 Mar 2002 14:47:22 -0000      1.29
  +++ DOMHelper.java    26 Sep 2002 13:58:38 -0000      1.29.2.1
  @@ -337,15 +337,14 @@
      * 
      * @param node1 The first DOM node to compare.
      * @param node2 The second DOM node to compare.
  -   * @return true if the two nodes are the same, false if not or if
  -   * the nodes are not DTMNodeProxy.
  +   * @return true if the two nodes are the same.
      */
     public static boolean isNodeTheSame(Node node1, Node node2)
     {
       if (node1 instanceof DTMNodeProxy && node2 instanceof DTMNodeProxy)
         return ((DTMNodeProxy)node1).equals((DTMNodeProxy)node2);
       else
  -      return false;
  +      return (node1 == node2);
     }
   
     /**
  
  
  

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

Reply via email to