changeset 272:c20bbcc510ff

6923146: Upgrade to JAXP 1.4.3
author andrew
date Wed, 28 Sep 2011 16:53:17 +0100
parents 47ef99bcbcb0
children 0f39aee48121
files sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/dom/NodeCounter.java sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler.java sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/NamespaceContextWrapper.java sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/Encodings.java sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/NamespaceMappings.java sources/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java sources/jaxp_src/src/com/sun/org/apache/xpath/internal/axes/NodeSequence.java sources/jaxp_src/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java sources/jaxp_src/src/com/sun/xml/internal/stream/XMLInputFactoryImpl.java sources/jaxp_src/src/com/sun/xml/internal/stream/events/StartDocumentEvent.java sources/jaxp_src/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java sources/jaxp_src/src/org/xml/sax/SAXException.java sources/jaxp_src/src/org/xml/sax/SAXParseException.java
diffstat 17 files changed, 584 insertions(+), 458 deletions(-) [+]
line wrap: on
line diff
--- a/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/dom/NodeCounter.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/dom/NodeCounter.java	Wed Sep 28 16:53:17 2011 +0100
@@ -29,7 +29,6 @@
 import com.sun.org.apache.xalan.internal.xsltc.Translet;
 import com.sun.org.apache.xml.internal.dtm.DTM;
 import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
-import com.sun.org.apache.xml.internal.dtm.Axis;
 
 /**
  * @author Jacek Ambroziak
@@ -69,7 +68,7 @@
     private final static String[] Ones = 
     {"", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"};
   
-    private StringBuffer _tempBuffer = new StringBuffer();
+    private StringBuilder _tempBuffer = new StringBuilder();
     
     /**
      * Indicates if this instance of xsl:number has a from pattern.
@@ -114,16 +113,70 @@
     _lang = lang;
     _groupSep = groupSep;
     _letterValue = letterValue;
-
-    try {
-        _groupSize = Integer.parseInt(groupSize);
-    }
-    catch (NumberFormatException e) {
-       _groupSize = 0;
-    }
+    _groupSize = parseStringToAnInt(groupSize);
     setTokens(format);
 
  }
+
+    /**
+     * Effectively does the same thing as Integer.parseInt(String s) except
+     * instead of throwing a NumberFormatException, it returns 0.  This method
+     * is used instead of Integer.parseInt() since it does not incur the
+     * overhead of throwing an Exception which is expensive.
+     *
+     * @param s  A String to be parsed into an int.
+     * @return  Either an int represented by the incoming String s, or 0 if
+     *          the parsing is not successful.
+     */
+    private int parseStringToAnInt(String s) {
+        if (s == null)
+            return 0;
+
+        int result = 0;
+        boolean negative = false;
+        int radix = 10, i = 0, max = s.length();
+        int limit, multmin, digit;
+
+        if (max > 0) {
+            if (s.charAt(0) == '-') {
+                negative = true;
+                limit = Integer.MIN_VALUE;
+                i++;
+            } else {
+                limit = -Integer.MAX_VALUE;
+            }
+            multmin = limit / radix;
+            if (i < max) {
+                digit = Character.digit(s.charAt(i++), radix);
+                if (digit < 0)
+                    return 0;
+                else
+                    result = -digit;
+            }
+            while (i < max) {
+                // Accumulating negatively avoids surprises near MAX_VALUE
+                digit = Character.digit(s.charAt(i++), radix);
+                if (digit < 0)
+                    return 0;
+                if (result < multmin)
+                    return 0;
+                result *= radix;
+                if (result < limit + digit)
+                    return 0;
+                result -= digit;
+            }
+        } else {
+            return 0;
+        }
+        if (negative) {
+            if (i > 1)
+                return result;
+            else /* Only got "-" */
+                return 0;
+        } else {
+            return -result;
+        }
+    }
   
   // format == null assumed here 
  private final void setTokens(final String format){
@@ -240,7 +293,6 @@
      */
     protected String formatNumbers(int[] values) {
     final int nValues = values.length;
-    final int length = _format.length();
 
     boolean isEmpty = true;
     for (int i = 0; i < nValues; i++)
@@ -252,7 +304,7 @@
     boolean isFirst = true;
     int t = 0, n = 0, s = 1;
   _tempBuffer.setLength(0);
-    final StringBuffer buffer = _tempBuffer;
+    final StringBuilder buffer = _tempBuffer;
 
     // Append separation token before first digit/letter/numeral
     if (_separFirst) buffer.append((String)_separToks.elementAt(0));
@@ -280,15 +332,15 @@
      * This method is based on saxon (Michael Kay) and only implements
      * lang="en".
      */
-    private void formatValue(int value, String format, StringBuffer buffer) {
+    private void formatValue(int value, String format, StringBuilder buffer) {
         char c = format.charAt(0);
 
         if (Character.isDigit(c)) {
             char zero = (char)(c - Character.getNumericValue(c));
 
-            StringBuffer temp = buffer;
+            StringBuilder temp = buffer;
             if (_groupSize > 0) {
-                temp = new StringBuffer();
+                temp = new StringBuilder();
             }
             String s = "";
             int n = value;
--- a/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler.java	Wed Sep 28 16:53:17 2011 +0100
@@ -34,55 +34,55 @@
  */
 public final class StringValueHandler extends EmptySerializer {
 
-    private StringBuffer _buffer = new StringBuffer();
+    private StringBuilder _buffer = new StringBuilder();
     private String _str = null;
     private static final String EMPTY_STR = "";
     private boolean m_escaping = false;
     private int _nestedLevel = 0;
-
-    public void characters(char[] ch, int off, int len)
-        throws SAXException
+	
+    public void characters(char[] ch, int off, int len) 
+	throws SAXException 
     {
-        if (_nestedLevel > 0)
-            return;
-
-        if (_str != null) {
-            _buffer.append(_str);
-            _str = null;
-        }
-        _buffer.append(ch, off, len);
+	if (_nestedLevel > 0)
+	    return;
+	
+	if (_str != null) {
+	    _buffer.append(_str);
+	    _str = null;
+	}
+	_buffer.append(ch, off, len);
     }
 
     public String getValue() {
-        if (_buffer.length() != 0) {
-            String result = _buffer.toString();
-            _buffer.setLength(0);
-            return result;
-        }
-        else {
-            String result = _str;
-            _str = null;
-            return (result != null) ? result : EMPTY_STR;
-        }
+	if (_buffer.length() != 0) {
+	    String result = _buffer.toString();
+	    _buffer.setLength(0);
+	    return result;
+	}
+	else {
+	    String result = _str;
+	    _str = null;
+	    return (result != null) ? result : EMPTY_STR;
+	}
     }
 
     public void characters(String characters) throws SAXException {
-        if (_nestedLevel > 0)
-            return;
+	if (_nestedLevel > 0)
+	    return;
 
-        if (_str == null && _buffer.length() == 0) {
-            _str = characters;
-        }
-        else {
-            if (_str != null) {
-                _buffer.append(_str);
-                _str = null;
-            }
-
-            _buffer.append(characters);
-        }
+	if (_str == null && _buffer.length() == 0) {
+	    _str = characters;
+	}
+	else {
+	    if (_str != null) {
+	        _buffer.append(_str);
+	        _str = null;
+	    }
+	    
+	    _buffer.append(characters);
+	}
     }
-
+    
     public void startElement(String qname) throws SAXException {
         _nestedLevel++;
     }
@@ -102,26 +102,26 @@
 
     /**
      * The value of a PI must not contain the substring "?>". Should
-     * that substring be present, replace it by "? >".
+     * that substring be present, replace it by "? >". 
      */
     public String getValueOfPI() {
-        final String value = getValue();
+	final String value = getValue();
 
-        if (value.indexOf("?>") > 0) {
-            final int n = value.length();
-            final StringBuffer valueOfPI = new StringBuffer();
+	if (value.indexOf("?>") > 0) {
+	    final int n = value.length(); 
+	    final StringBuilder valueOfPI = new StringBuilder();
 
-            for (int i = 0; i < n;) {
-                final char ch = value.charAt(i++);
-                if (ch == '?' && value.charAt(i) == '>') {
-                    valueOfPI.append("? >"); i++;
-                }
-                else {
-                    valueOfPI.append(ch);
-                }
-            }
-            return valueOfPI.toString();
-        }
-        return value;
+	    for (int i = 0; i < n;) {
+		final char ch = value.charAt(i++);
+		if (ch == '?' && value.charAt(i) == '>') {
+		    valueOfPI.append("? >"); i++;
+		}
+		else {
+		    valueOfPI.append(ch);
+		}
+	    } 
+	    return valueOfPI.toString();
+	}
+	return value;
     }
 }
--- a/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Wed Sep 28 16:53:17 2011 +0100
@@ -207,7 +207,7 @@
     /**
      * <p>State of secure processing feature.</p>
      */
-    private boolean _isSecureProcessing = false;
+    private boolean _isNotSecureProcessing = true;
     /**
      * <p>State of secure mode.</p>
      */
@@ -219,7 +219,7 @@
         m_DTMManagerClass = XSLTCDTMManager.getDTMManagerClass();
         if (System.getSecurityManager() != null) {
             _isSecureMode = true;
-            _isSecureProcessing = true;
+            _isNotSecureProcessing = false;
         }
     }
 
@@ -416,7 +416,7 @@
                 ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_SECUREPROCESSING_FEATURE);
                 throw new TransformerConfigurationException(err.toString());
             }
-	    _isSecureProcessing = value;		
+	    _isNotSecureProcessing = !value;
 	    // all done processing feature
 	    return;
 	}
@@ -465,7 +465,7 @@
 	}
 	// secure processing?
 	if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
-		return _isSecureProcessing;
+		return !_isNotSecureProcessing;
 	}
 
 	// Feature not supported
@@ -546,7 +546,7 @@
                 SAXParserFactory factory = SAXParserFactory.newInstance();
                 factory.setNamespaceAware(true);
                 
-                if (_isSecureProcessing) {
+                if (!_isNotSecureProcessing) {
                     try {
                         factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
                     }
@@ -610,7 +610,7 @@
 	    result.setURIResolver(_uriResolver);
 	}
 	
-	if (_isSecureProcessing) {
+	if (!_isNotSecureProcessing) {
 	    result.setSecureProcessing(true);
 	}
 	return result;
@@ -756,7 +756,7 @@
 	final XSLTC xsltc = new XSLTC();
 	if (_debug) xsltc.setDebug(true);
 	if (_enableInlining) xsltc.setTemplateInlining(true);
-	if (_isSecureProcessing) xsltc.setSecureProcessing(true);
+	if (!_isNotSecureProcessing) xsltc.setSecureProcessing(true);
 	xsltc.init();
 
 	// Set a document loader (for xsl:include/import) if defined
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java	Wed Sep 28 16:53:17 2011 +0100
@@ -40,7 +40,7 @@
  * 
  * @xerces.internal
  *
- * @version $Id: DeferredDocumentImpl.java,v 1.6 2009/09/09 23:09:49 joehw Exp $
+ * @version $Id: DeferredDocumentImpl.java,v 1.7 2009/12/01 06:12:02 joehw Exp $
  * @since  PR-DOM-Level-1-19980818.
  */
 public class DeferredDocumentImpl
@@ -132,7 +132,7 @@
     //
     // private data
     //
-    private transient final StringBuffer fBufferStr = new StringBuffer();
+    private transient final StringBuilder fBufferStr = new StringBuilder();
     private transient final Vector fStrChunks = new Vector();
 
     //
@@ -430,8 +430,6 @@
 		// get element's last attribute
 		int lastAttrNodeIndex = getChunkIndex(fNodeExtra, elementChunk, elementIndex);
 		if (lastAttrNodeIndex != 0) {
-			int lastAttrChunk = lastAttrNodeIndex >> CHUNK_SHIFT;
-			int lastAttrIndex = lastAttrNodeIndex & CHUNK_MASK;
 			// add link from new attribute to last attribute
 			setChunkIndex(fNodePrevSib, lastAttrNodeIndex, attrChunk, attrIndex);
 		}
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java	Wed Sep 28 16:53:17 2011 +0100
@@ -84,6 +84,7 @@
  * @author Andy Clark, IBM
  * @author Elena Litani, IBM
  *
+ * @version $Id: AbstractDOMParser.java,v 1.5 2009/12/01 06:12:03 joehw Exp $
  */
 public class AbstractDOMParser extends AbstractXMLDocumentParser {
 
@@ -216,14 +217,14 @@
     protected int fDeferredEntityDecl;
 
     /** Character buffer */
-    protected final StringBuffer fStringBuffer = new StringBuffer (50);
+    protected final StringBuilder fStringBuilder = new StringBuilder (50);
 
     // internal subset
 
     /** Internal subset buffer. */
-    protected StringBuffer fInternalSubset;
+    protected StringBuilder fInternalSubset;
 
-    // deferred expansion data
+    // deferred expansion datfInternalSubseta
 
     protected boolean              fDeferNodeExpansion;
     protected boolean              fNamespaceAware;
@@ -413,7 +414,7 @@
         fCurrentNode = null;
 
         // reset string buffer
-        fStringBuffer.setLength (0);
+        fStringBuilder.setLength (0);
 
         // reset state information
         fRoot.clear();
@@ -1147,14 +1148,14 @@
                     // collect all the data into the string buffer.
                     if (fFirstChunk) {
                         if (fDocumentImpl != null) {
-                            fStringBuffer.append (((TextImpl)child).removeData ());
+                            fStringBuilder.append (((TextImpl)child).removeData ());
                         } else {
-                            fStringBuffer.append (((Text)child).getData ());
+                            fStringBuilder.append (((Text)child).getData ());
                             ((Text)child).setNodeValue (null);
                         }
                         fFirstChunk = false;
                     }
-                    fStringBuffer.append (value);
+                    fStringBuilder.append (value);
                 }
                 else {
                     fFirstChunk = true;
@@ -1749,7 +1750,7 @@
             fBaseURIStack.push (locator.getBaseSystemId ());
         }
         if (fDeferNodeExpansion || fDocumentImpl != null) {
-            fInternalSubset = new StringBuffer (1024);
+            fInternalSubset = new StringBuilder (1024);
         }
     } // startDTD(XMLLocator)
 
@@ -2525,18 +2526,18 @@
 
         Node child = fCurrentNode.getLastChild ();
         if (child != null) {
-            if (fStringBuffer.length () > 0) {
+            if (fStringBuilder.length () > 0) {
                 // REVISIT: should this check be performed?
                 if (child.getNodeType () == Node.TEXT_NODE) {
                     if (fDocumentImpl != null) {
-                        ((TextImpl)child).replaceData (fStringBuffer.toString ());
+                        ((TextImpl)child).replaceData (fStringBuilder.toString ());
                     }
                     else {
-                        ((Text)child).setData (fStringBuffer.toString ());
+                        ((Text)child).setData (fStringBuilder.toString ());
                     }
                 }
                 // reset string buffer
-                fStringBuffer.setLength (0);
+                fStringBuilder.setLength (0);
             }
 
             if (fDOMFilter !=null && !fInEntityRef) {
--- a/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/NamespaceContextWrapper.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xerces/internal/util/NamespaceContextWrapper.java	Wed Sep 28 16:53:17 2011 +0100
@@ -30,9 +30,9 @@
 import javax.xml.namespace.NamespaceContext;
 
 /**
- * Writing a wrapper to re-use most of the namespace functionality
+ * Writing a wrapper to re-use most of the namespace functionality 
  * already provided by NamespaceSupport, which implements NamespaceContext
- * from XNI. It would be good if we can change the XNI NamespaceContext
+ * from XNI. It would be good if we can change the XNI NamespaceContext 
  * interface to implement the JAXP NamespaceContext interface.
  *
  * Note that NamespaceSupport assumes the use of symbols. Since this class
@@ -44,42 +44,42 @@
  *
  */
 public class NamespaceContextWrapper implements NamespaceContext {
-
+    
     private com.sun.org.apache.xerces.internal.xni.NamespaceContext fNamespaceContext;
-
+    
     public NamespaceContextWrapper(NamespaceSupport namespaceContext) {
         fNamespaceContext = namespaceContext ;
     }
-
+    
     public String getNamespaceURI(String prefix) {
         if (prefix == null) {
             throw new IllegalArgumentException("Prefix can't be null");
         }
         return fNamespaceContext.getURI(prefix.intern());
     }
-
+    
     public String getPrefix(String namespaceURI) {
-        if (namespaceURI == null || namespaceURI.trim().length() == 0) {
-            throw new IllegalArgumentException("URI can't be null or empty String");
+        if (namespaceURI == null) {
+            throw new IllegalArgumentException("URI can't be null.");
         }
         return fNamespaceContext.getPrefix(namespaceURI.intern());
     }
-
+    
     /**
      * TODO: Namespace doesn't give information giving multiple prefixes for
      * the same namespaceURI.
      */
     public java.util.Iterator getPrefixes(String namespaceURI) {
-        if (namespaceURI == null || namespaceURI.trim().length() == 0) {
-            throw new IllegalArgumentException("URI can't be null or empty String");
-        }
+        if (namespaceURI == null) {
+            throw new IllegalArgumentException("URI can't be null.");
+        } 
         else {
-            Vector vector =
+            Vector vector = 
                 ((NamespaceSupport) fNamespaceContext).getPrefixes(namespaceURI.intern());
             return vector.iterator();
         }
     }
-
+    
     /**
      * This method supports all functions in the NamespaceContext utility class
      */
--- a/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java	Wed Sep 28 16:53:17 2011 +0100
@@ -28,7 +28,7 @@
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
 import java.security.AccessController;
@@ -54,7 +54,7 @@
 final class CharInfo
 {
     /** Given a character, lookup a String to output (e.g. a decorated entity reference). */
-    private Hashtable m_charToString = new Hashtable();
+    private HashMap m_charToString = new HashMap();
 
     /**
      * The name of the HTML entities file.
@@ -360,7 +360,7 @@
      */
     private void defineEntity(String name, char value)
     {
-        StringBuffer sb = new StringBuffer("&");
+        StringBuilder sb = new StringBuilder("&");
         sb.append(name);
         sb.append(';');
         String entityString = sb.toString();
@@ -534,7 +534,7 @@
     }
 
     /** Table of user-specified char infos. */
-    private static Hashtable m_getCharInfoCache = new Hashtable();
+    private static HashMap m_getCharInfoCache = new HashMap();
 
     /**
      * Returns the array element holding the bit value for the
--- a/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/Encodings.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/Encodings.java	Wed Sep 28 16:53:17 2011 +0100
@@ -28,14 +28,11 @@
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.io.BufferedWriter;
-import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Properties;
 import java.util.StringTokenizer;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
 
 
 /**
@@ -44,7 +41,7 @@
  * to override encoding names and provide the last printable character
  * for each encoding.
  *
- * @version $Revision: 1.8 $ $Date: 2007/10/12 04:14:45 $
+ * @version $Revision: 1.9 $ $Date: 2009/12/01 22:17:31 $
  * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
  */
 
@@ -308,7 +305,6 @@
      */
     private static EncodingInfo[] loadEncodingInfo()
     {
-        URL url = null;
         try
         {
             String urlString = null;
@@ -323,7 +319,7 @@
             }
 
             if (urlString != null && urlString.length() > 0) {
-                url = new URL(urlString);
+                URL url = new URL(urlString);
                 is = url.openStream();
             }
 
@@ -462,7 +458,7 @@
         return codePoint;
     }
 
-    private static final Hashtable _encodingTableKeyJava = new Hashtable();
-    private static final Hashtable _encodingTableKeyMime = new Hashtable();
+    private static final HashMap _encodingTableKeyJava = new HashMap();
+    private static final HashMap _encodingTableKeyMime = new HashMap();
     private static final EncodingInfo[] _encodings = loadEncodingInfo();
 }
--- a/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/NamespaceMappings.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xml/internal/serializer/NamespaceMappings.java	Wed Sep 28 16:53:17 2011 +0100
@@ -22,8 +22,8 @@
  */
 package com.sun.org.apache.xml.internal.serializer;
 
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Stack;
 
 import org.xml.sax.ContentHandler;
@@ -33,7 +33,7 @@
  * This class keeps track of the currently defined namespaces. Conceptually the
  * prefix/uri/depth triplets are pushed on a stack pushed on a stack. The depth
  * indicates the nesting depth of the element for which the mapping was made.
- *
+ * 
  * <p>For example:
  * <pre>
  * <chapter xmlns:p1="def">
@@ -45,7 +45,7 @@
  *    </paragraph>
  * </chapter>
  * </pre>
- *
+ * 
  * When the <chapter> element is encounted the prefix "p1" associated with uri
  * "def" is pushed on the stack with depth 1.
  * When the first <paragraph> is encountered "p2" and "ghi" are pushed with
@@ -54,14 +54,14 @@
  * When </sentance> occurs the popNamespaces(3) will pop "p3"/"jkl" off the
  * stack.  Of course popNamespaces(2) would pop anything with depth 2 or
  * greater.
- *
+ * 
  * So prefix/uri pairs are pushed and poped off the stack as elements are
  * processed.  At any given moment of processing the currently visible prefixes
  * are on the stack and a prefix can be found given a uri, or a uri can be found
  * given a prefix.
- *
+ * 
  * This class is public only because it is used by Xalan. It is not a public API
- *
+ * 
  * @xsl.usage internal
  */
 public class NamespaceMappings
@@ -70,26 +70,26 @@
      * This member is continually incremented when new prefixes need to be
      * generated. ("ns0"  "ns1" ...)
      */
-    private int count = 0;
+    private int count;
 
     /**
-     * Each entry (prefix) in this hashtable points to a Stack of URIs
-     * This table maps a prefix (String) to a Stack of prefix mappings.
+     * Each entry (prefix) in this hashmap points to a Stack of URIs
+     * This maps a prefix (String) to a Stack of prefix mappings.
      * All mappings in that retrieved stack have the same prefix,
      * though possibly different URI's or depths. Such a stack must have
      * mappings at deeper depths push later on such a stack.  Mappings pushed
      * earlier on the stack will have smaller values for MappingRecord.m_declarationDepth.
      */
-    private Hashtable m_namespaces = new Hashtable();
+    private HashMap m_namespaces = new HashMap();
 
-    /**
+    /** 
      * The top of this stack contains the MapRecord
      * of the last declared a namespace.
      * Used to know how many prefix mappings to pop when leaving
      * the current element depth.
-     * For every prefix mapping the current element depth is
+     * For every prefix mapping the current element depth is 
      * pushed on this stack.
-     * That way all prefixes pushed at the current depth can be
+     * That way all prefixes pushed at the current depth can be 
      * removed at the same time.
      * Used to ensure prefix/uri map scopes are closed correctly
      *
@@ -114,7 +114,7 @@
      */
     private void initNamespaces()
     {
-
+ 
 
         // Define the default namespace (initially maps to "" uri)
         Stack stack;
@@ -131,27 +131,27 @@
 
     /**
      * Use a namespace prefix to lookup a namespace URI.
-     *
+     * 
      * @param prefix String the prefix of the namespace
      * @return the URI corresponding to the prefix
      */
     public String lookupNamespace(String prefix)
     {
         final Stack stack = (Stack) m_namespaces.get(prefix);
-        return stack != null && !stack.isEmpty() ?
+        return stack != null && !stack.isEmpty() ? 
             ((MappingRecord) stack.peek()).m_uri : null;
     }
-
+    
     MappingRecord getMappingFromPrefix(String prefix) {
         final Stack stack = (Stack) m_namespaces.get(prefix);
-        return stack != null && !stack.isEmpty() ?
+        return stack != null && !stack.isEmpty() ? 
             ((MappingRecord) stack.peek()) : null;
     }
 
     /**
-     * Given a namespace uri, and the namespaces mappings for the
+     * Given a namespace uri, and the namespaces mappings for the 
      * current element, return the current prefix for that uri.
-     *
+     * 
      * @param uri the namespace URI to be search for
      * @return an existing prefix that maps to the given URI, null if no prefix
      * maps to the given namespace URI.
@@ -159,10 +159,9 @@
     public String lookupPrefix(String uri)
     {
         String foundPrefix = null;
-        Enumeration prefixes = m_namespaces.keys();
-        while (prefixes.hasMoreElements())
-        {
-            String prefix = (String) prefixes.nextElement();
+        Iterator<String> itr = m_namespaces.keySet().iterator();
+        while (itr.hasNext()) {
+            String prefix = itr.next();
             String uri2 = lookupNamespace(prefix);
             if (uri2 != null && uri2.equals(uri))
             {
@@ -172,14 +171,14 @@
         }
         return foundPrefix;
     }
-
+    
     MappingRecord getMappingFromURI(String uri)
     {
         MappingRecord foundMap = null;
-        Enumeration prefixes = m_namespaces.keys();
-        while (prefixes.hasMoreElements())
+        Iterator<String> itr = m_namespaces.keySet().iterator();
+        while (itr.hasNext())
         {
-            String prefix = (String) prefixes.nextElement();
+            String prefix = itr.next();
             MappingRecord map2 = getMappingFromPrefix(prefix);
             if (map2 != null && (map2.m_uri).equals(uri))
             {
@@ -264,7 +263,7 @@
              */
 
             map = (MappingRecord) m_nodeStack.pop();
-            final String prefix = map.m_prefix;
+            final String prefix = map.m_prefix; 
             popNamespace(prefix);
             if (saxHandler != null)
             {
@@ -277,7 +276,7 @@
                     // not much we can do if they aren't willing to listen
                 }
             }
-
+               
         }
     }
 
@@ -290,7 +289,7 @@
         return "ns" + (count++);
     }
 
-
+ 
     /**
      * This method makes a clone of this object.
      *
@@ -298,21 +297,20 @@
     public Object clone() throws CloneNotSupportedException {
         NamespaceMappings clone = new NamespaceMappings();
         clone.m_nodeStack = (Stack) m_nodeStack.clone();
-        clone.m_namespaces = (Hashtable) m_namespaces.clone();
-
+        clone.m_namespaces = (HashMap) m_namespaces.clone();
         clone.count = count;
         return clone;
-
+        
     }
-
+    
     final void reset()
     {
         this.count = 0;
         this.m_namespaces.clear();
-        this.m_nodeStack.clear();
+        this.m_nodeStack.clear();        
         initNamespaces();
     }
-
+    
     class MappingRecord {
         final String m_prefix;  // the prefix
         final String m_uri;     // the uri
@@ -322,7 +320,7 @@
             m_prefix = prefix;
             m_uri = uri;
             m_declarationDepth = depth;
-
+            
         }
     }
 
--- a/sources/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java	Wed Sep 28 16:53:17 2011 +0100
@@ -22,7 +22,7 @@
  */
 package com.sun.org.apache.xml.internal.utils;
 
-import java.util.Hashtable;
+import java.util.HashMap;
 
 import javax.xml.parsers.FactoryConfigurationError;
 import javax.xml.parsers.ParserConfigurationException;
@@ -58,7 +58,7 @@
     /**
      * Keeps track of whether an XMLReader object is in use.
      */
-    private Hashtable m_inUse;
+    private HashMap m_inUse;
 
     /**
      * Hidden constructor
@@ -81,7 +81,6 @@
      */
     public synchronized XMLReader getXMLReader() throws SAXException {
         XMLReader reader;
-        boolean readerInUse;
 
         if (m_readers == null) {
             // When the m_readers.get() method is called for the first time
@@ -90,7 +89,7 @@
         }
 
         if (m_inUse == null) {
-            m_inUse = new Hashtable();
+            m_inUse = new HashMap();
         }
 
         // If the cached reader for this thread is in use, construct a new
--- a/sources/jaxp_src/src/com/sun/org/apache/xpath/internal/axes/NodeSequence.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xpath/internal/axes/NodeSequence.java	Wed Sep 28 16:53:17 2011 +0100
@@ -34,7 +34,7 @@
 import com.sun.org.apache.xpath.internal.objects.XObject;
 
 /**
- * This class is the dynamic wrapper for a Xalan DTMIterator instance, and
+ * This class is the dynamic wrapper for a Xalan DTMIterator instance, and 
  * provides random access capabilities.
  */
 public class NodeSequence extends XObject
@@ -43,39 +43,39 @@
     static final long serialVersionUID = 3866261934726581044L;
   /** The index of the last node in the iteration. */
   protected int m_last = -1;
-
+  
   /**
    * The index of the next node to be fetched.  Useful if this
    * is a cached iterator, and is being used as random access
    * NodeList.
    */
   protected int m_next = 0;
-
+    
   /**
    * If this iterator needs to cache nodes that are fetched, they
    * are stored in the Vector in the generic object.
    */
   protected NodeVector getVector()
   {
-        return (NodeVector)m_obj;
+  	return (NodeVector)m_obj;
   }
-
+  
   /**
    * Set the vector where nodes will be stored.
    */
   protected void SetVector(NodeVector v)
   {
-        m_obj = v;
+  	m_obj = v;
   }
 
-
+  
   /**
    * If this iterator needs to cache nodes that are fetched, they
    * are stored here.
    */
   public boolean hasCache()
   {
-        return (m_obj != null);
+  	return (m_obj != null);
   }
 
 
@@ -83,36 +83,36 @@
    * The functional iterator that fetches nodes.
    */
   protected DTMIterator m_iter;
-
+  
   /**
    * Set the functional iterator that fetches nodes.
    * @param iter The iterator that is to be contained.
    */
   public final void setIter(DTMIterator iter)
   {
-        m_iter = iter;
+  	m_iter = iter;
   }
-
+  
   /**
    * Get the functional iterator that fetches nodes.
    * @return The contained iterator.
    */
   public final DTMIterator getContainedIter()
   {
-        return m_iter;
+  	return m_iter;
   }
-
+  
   /**
    * The DTMManager to use if we're using a NodeVector only.
    * We may well want to do away with this, and store it in the NodeVector.
    */
   protected DTMManager m_dtmMgr;
-
+  
   // ==== Constructors ====
-
+  
   /**
    * Create a new NodeSequence from a (already cloned) iterator.
-   *
+   * 
    * @param iter Cloned (not static) DTMIterator.
    * @param context The initial context node.
    * @param xctxt The execution context.
@@ -120,34 +120,34 @@
    */
   public NodeSequence(DTMIterator iter, int context, XPathContext xctxt, boolean shouldCacheNodes)
   {
-        setIter(iter);
-        setRoot(context, xctxt);
-        setShouldCacheNodes(shouldCacheNodes);
+  	setIter(iter);
+  	setRoot(context, xctxt);
+  	setShouldCacheNodes(shouldCacheNodes);
   }
-
+  
   /**
    * Create a new NodeSequence from a (already cloned) iterator.
-   *
+   * 
    * @param nodeVector
    */
   public NodeSequence(Object nodeVector)
   {
-        super(nodeVector);
-        if(null != nodeVector)
-        {
-                assertion(nodeVector instanceof NodeVector,
-                        "Must have a NodeVector as the object for NodeSequence!");
-                if(nodeVector instanceof DTMIterator)
-                {
-                        setIter((DTMIterator)nodeVector);
-                        m_last = ((DTMIterator)nodeVector).getLength();
-                }
-
-        }
+  	super(nodeVector);
+  	if(null != nodeVector)
+  	{
+  		assertion(nodeVector instanceof NodeVector, 
+  			"Must have a NodeVector as the object for NodeSequence!");
+  		if(nodeVector instanceof DTMIterator)
+  		{
+  			setIter((DTMIterator)nodeVector);
+  			m_last = ((DTMIterator)nodeVector).getLength();
+  		}
+  		
+  	}
   }
-
+  
   /**
-   * Construct an empty XNodeSet object.  This is used to create a mutable
+   * Construct an empty XNodeSet object.  This is used to create a mutable 
    * nodeset to which random nodes may be added.
    */
   public NodeSequence(DTMManager dtmMgr)
@@ -157,7 +157,7 @@
     m_dtmMgr = dtmMgr;
   }
 
-
+  
   /**
    * Create a new NodeSequence in an invalid (null) state.
    */
@@ -171,13 +171,13 @@
    */
   public DTM getDTM(int nodeHandle)
   {
-        DTMManager mgr = getDTMManager();
-        if(null != mgr)
-        return getDTMManager().getDTM(nodeHandle);
+  	DTMManager mgr = getDTMManager();
+  	if(null != mgr)
+    	return getDTMManager().getDTM(nodeHandle);
     else
     {
-        assertion(false, "Can not get a DTM Unless a DTMManager has been set!");
-        return null;
+    	assertion(false, "Can not get a DTM Unless a DTMManager has been set!");
+    	return null;
     }
   }
 
@@ -194,15 +194,15 @@
    */
   public int getRoot()
   {
-        if(null != m_iter)
-        return m_iter.getRoot();
-        else
-        {
-                // NodeSetDTM will call this, and so it's not a good thing to throw
-                // an assertion here.
-                // assertion(false, "Can not get the root from a non-iterated NodeSequence!");
-                return DTM.NULL;
-        }
+  	if(null != m_iter)
+    	return m_iter.getRoot();
+  	else
+  	{
+  		// NodeSetDTM will call this, and so it's not a good thing to throw 
+  		// an assertion here.
+  		// assertion(false, "Can not get the root from a non-iterated NodeSequence!");
+  		return DTM.NULL;
+  	}
   }
 
   /**
@@ -211,27 +211,27 @@
   public void setRoot(int nodeHandle, Object environment)
   {
         // If root is DTM.NULL, then something's wrong with the context
-        if (nodeHandle == DTM.NULL)
+        if (nodeHandle == DTM.NULL) 
         {
             throw new RuntimeException("Unable to evaluate expression using " +
                     "this context");
         }
-
-        if(null != m_iter)
-        {
-                XPathContext xctxt = (XPathContext)environment;
-                m_dtmMgr = xctxt.getDTMManager();
-                m_iter.setRoot(nodeHandle, environment);
-                if(!m_iter.isDocOrdered())
-                {
-                        if(!hasCache())
-                                setShouldCacheNodes(true);
-                        runTo(-1);
-                        m_next=0;
-                }
-        }
-        else
-                assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
+        
+  	if(null != m_iter)
+  	{
+  		XPathContext xctxt = (XPathContext)environment;
+  		m_dtmMgr = xctxt.getDTMManager();
+  		m_iter.setRoot(nodeHandle, environment);
+  		if(!m_iter.isDocOrdered())
+  		{
+  			if(!hasCache())
+  				setShouldCacheNodes(true);
+  			runTo(-1);
+  			m_next=0;
+  		}
+  	}
+  	else
+  		assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
   }
 
   /**
@@ -239,8 +239,8 @@
    */
   public void reset()
   {
-        m_next = 0;
-        // not resetting the iterator on purpose!!!
+  	m_next = 0;
+  	// not resetting the iterator on purpose!!!
   }
 
   /**
@@ -248,8 +248,8 @@
    */
   public int getWhatToShow()
   {
-    return hasCache() ? (DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE)
-        : m_iter.getWhatToShow();
+    return hasCache() ? (DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE) 
+    	: m_iter.getWhatToShow();
   }
 
   /**
@@ -257,10 +257,10 @@
    */
   public boolean getExpandEntityReferences()
   {
-        if(null != m_iter)
-                return m_iter.getExpandEntityReferences();
-        else
-        return true;
+  	if(null != m_iter)
+  		return m_iter.getExpandEntityReferences();
+  	else
+    	return true;
   }
 
   /**
@@ -268,53 +268,53 @@
    */
   public int nextNode()
   {
-    // If the cache is on, and the node has already been found, then
+    // If the cache is on, and the node has already been found, then 
     // just return from the list.
     NodeVector vec = getVector();
     if (null != vec)
-    {
-        if(m_next < vec.size())
-        {
-                        int next = vec.elementAt(m_next);
-                m_next++;
-                return next;
-        }
-        else if((-1 != m_last) || (null == m_iter))
-        {
-                m_next++;
-                return DTM.NULL;
-        }
+    {	
+    	if(m_next < vec.size())
+    	{
+			int next = vec.elementAt(m_next);
+	    	m_next++;
+	    	return next;
+    	}
+    	else if((-1 != m_last) || (null == m_iter))
+    	{
+    		m_next++;
+    		return DTM.NULL;
+    	}
     }
-
+    
   if (null == m_iter)
     return DTM.NULL;
-
-        int next = m_iter.nextNode();
+  
+ 	int next = m_iter.nextNode();
     if(DTM.NULL != next)
     {
-        if(hasCache())
-        {
-                if(m_iter.isDocOrdered())
-            {
-                        getVector().addElement(next);
-                        m_next++;
-                }
-                else
-                {
-                        int insertIndex = addNodeInDocOrder(next);
-                        if(insertIndex >= 0)
-                                m_next++;
-                }
-        }
-        else
-                m_next++;
+    	if(hasCache())
+    	{
+    		if(m_iter.isDocOrdered())
+    	    {
+    			getVector().addElement(next);
+    			m_next++;
+    		}
+    		else
+    		{
+    			int insertIndex = addNodeInDocOrder(next);
+    			if(insertIndex >= 0)
+    				m_next++;
+    		}
+    	}
+    	else
+    		m_next++;
     }
     else
     {
-        m_last = m_next;
-        m_next++;
+    	m_last = m_next;
+    	m_next++;
     }
-
+    	
     return next;
   }
 
@@ -323,22 +323,22 @@
    */
   public int previousNode()
   {
-        if(hasCache())
-        {
-                if(m_next <= 0)
-                        return DTM.NULL;
-                else
-                {
-                        m_next--;
-                        return item(m_next);
-                }
-        }
-        else
-        {
-            int n = m_iter.previousNode();
-            m_next = m_iter.getCurrentPos();
-            return m_next;
-        }
+  	if(hasCache())
+  	{
+  		if(m_next <= 0)
+  			return DTM.NULL;
+  		else
+  		{
+  			m_next--;
+  			return item(m_next);
+  		}
+  	}
+  	else
+  	{
+	    int n = m_iter.previousNode();
+	    m_next = m_iter.getCurrentPos();
+	    return m_next;
+  	}
   }
 
   /**
@@ -346,26 +346,26 @@
    */
   public void detach()
   {
-        if(null != m_iter)
-                m_iter.detach();
-        super.detach();
+  	if(null != m_iter)
+  		m_iter.detach();
+  	super.detach();
   }
 
   /**
-   * Calling this with a value of false will cause the nodeset
+   * Calling this with a value of false will cause the nodeset 
    * to be cached.
    * @see DTMIterator#allowDetachToRelease(boolean)
    */
   public void allowDetachToRelease(boolean allowRelease)
   {
-        if((false == allowRelease) && !hasCache())
-        {
-                setShouldCacheNodes(true);
-        }
-
-        if(null != m_iter)
-                m_iter.allowDetachToRelease(allowRelease);
-        super.allowDetachToRelease(allowRelease);
+  	if((false == allowRelease) && !hasCache())
+  	{
+  		setShouldCacheNodes(true);
+  	}
+  	
+  	if(null != m_iter)
+  		m_iter.allowDetachToRelease(allowRelease);
+  	super.allowDetachToRelease(allowRelease);
   }
 
   /**
@@ -373,22 +373,22 @@
    */
   public int getCurrentNode()
   {
-        if(hasCache())
-        {
-                int currentIndex = m_next-1;
-                NodeVector vec = getVector();
-                if((currentIndex >= 0) && (currentIndex < vec.size()))
-                        return vec.elementAt(currentIndex);
-                else
-                        return DTM.NULL;
-        }
-
-        if(null != m_iter)
-        {
-        return m_iter.getCurrentNode();
-        }
-        else
-                return DTM.NULL;
+  	if(hasCache())
+  	{
+  		int currentIndex = m_next-1;
+  		NodeVector vec = getVector();
+  		if((currentIndex >= 0) && (currentIndex < vec.size()))
+  			return vec.elementAt(currentIndex);
+  		else
+  			return DTM.NULL;
+  	}
+  	
+  	if(null != m_iter)
+  	{
+    	return m_iter.getCurrentNode();
+  	}
+  	else
+  		return DTM.NULL;
   }
 
   /**
@@ -410,8 +410,8 @@
       {
         SetVector(new NodeVector());
       }
-//        else
-//          getVector().RemoveAllNoClear();  // Is this good?
+//	  else
+//	    getVector().RemoveAllNoClear();  // Is this good?
     }
     else
       SetVector(null);
@@ -439,7 +439,7 @@
   public void runTo(int index)
   {
     int n;
-
+    
     if (-1 == index)
     {
       int pos = m_next;
@@ -450,7 +450,7 @@
     {
       return;
     }
-    else if(hasCache() && m_next < getVector().size())
+    else if(hasCache() && index < getVector().size())
     {
       m_next = index;
     }
@@ -459,10 +459,10 @@
       while ((m_next >= index) && DTM.NULL != (n = previousNode()));
     }
     else
-    {
+    {   
       while ((m_next < index) && DTM.NULL != (n = nextNode()));
     }
-
+    
   }
 
   /**
@@ -470,7 +470,7 @@
    */
   public void setCurrentPos(int i)
   {
-        runTo(i);
+  	runTo(i);
   }
 
   /**
@@ -478,10 +478,10 @@
    */
   public int item(int index)
   {
-        setCurrentPos(index);
-        int n = nextNode();
-        m_next = index;
-        return n;
+  	setCurrentPos(index);
+  	int n = nextNode();
+  	m_next = index;
+  	return n;
   }
 
   /**
@@ -489,14 +489,14 @@
    */
   public void setItem(int node, int index)
   {
-        NodeVector vec = getVector();
-        if(null != vec)
-        {
-                vec.setElementAt(node, index);
-                m_last = vec.size();
-        }
-        else
-                m_iter.setItem(node, index);
+  	NodeVector vec = getVector();
+  	if(null != vec)
+  	{
+  		vec.setElementAt(node, index);
+  		m_last = vec.size();
+  	}
+  	else
+  		m_iter.setItem(node, index);
   }
 
   /**
@@ -504,28 +504,28 @@
    */
   public int getLength()
   {
-        if(hasCache())
-        {
+  	if(hasCache())
+  	{
         // If this NodeSequence wraps a mutable nodeset, then
         // m_last will not reflect the size of the nodeset if
         // it has been mutated...
         if (m_iter instanceof NodeSetDTM)
         {
             return m_iter.getLength();
-        }
-
-                if(-1 == m_last)
-                {
-                        int pos = m_next;
-                        runTo(-1);
-                        m_next = pos;
-                }
-            return m_last;
-        }
-        else
-        {
-                return (-1 == m_last) ? (m_last = m_iter.getLength()) : m_last;
-        }
+        }    
+        
+	  	if(-1 == m_last)
+	  	{
+	  		int pos = m_next;
+	  		runTo(-1);
+	  		m_next = pos;
+	  	}
+	    return m_last;
+  	}
+  	else
+  	{
+  		return (-1 == m_last) ? (m_last = m_iter.getLength()) : m_last;
+  	}
   }
 
   /**
@@ -534,13 +534,13 @@
    */
   public DTMIterator cloneWithReset() throws CloneNotSupportedException
   {
-        NodeSequence seq = (NodeSequence)super.clone();
+  	NodeSequence seq = (NodeSequence)super.clone();
     seq.m_next = 0;
     return seq;
   }
-
+  
   /**
-   * Get a clone of this iterator, but don't reset the iteration in the
+   * Get a clone of this iterator, but don't reset the iteration in the 
    * process, so that it may be used from the current position.
    * Note: Not a deep clone.
    *
@@ -561,10 +561,10 @@
    */
   public boolean isDocOrdered()
   {
-        if(null != m_iter)
-                return m_iter.isDocOrdered();
-        else
-        return true; // can't be sure?
+  	if(null != m_iter)
+  		return m_iter.isDocOrdered();
+  	else
+    	return true; // can't be sure?
   }
 
   /**
@@ -572,12 +572,12 @@
    */
   public int getAxis()
   {
-        if(null != m_iter)
-        return m_iter.getAxis();
+  	if(null != m_iter)
+    	return m_iter.getAxis();
     else
     {
-        assertion(false, "Can not getAxis from a non-iterated node sequence!");
-        return 0;
+    	assertion(false, "Can not getAxis from a non-iterated node sequence!");
+    	return 0;
     }
   }
 
@@ -586,10 +586,10 @@
    */
   public int getAnalysisBits()
   {
-        if((null != m_iter) && (m_iter instanceof PathComponent))
-        return ((PathComponent)m_iter).getAnalysisBits();
+  	if((null != m_iter) && (m_iter instanceof PathComponent))
+    	return ((PathComponent)m_iter).getAnalysisBits();
     else
-        return 0;
+    	return 0;
   }
 
   /**
@@ -597,15 +597,15 @@
    */
   public void fixupVariables(Vector vars, int globalsSize)
   {
-        super.fixupVariables(vars, globalsSize);
-  }
-
+  	super.fixupVariables(vars, globalsSize);
+  }  
+  
   /**
    * Add the node into a vector of nodes where it should occur in
    * document order.
    * @param node The node to be added.
    * @return insertIndex.
-   * @throws RuntimeException thrown if this NodeSetDTM is not of
+   * @throws RuntimeException thrown if this NodeSetDTM is not of 
    * a mutable type.
    */
    protected int addNodeInDocOrder(int node)
@@ -613,11 +613,11 @@
       assertion(hasCache(), "addNodeInDocOrder must be done on a mutable sequence!");
 
       int insertIndex = -1;
-
+      
       NodeVector vec = getVector();
 
-      // This needs to do a binary search, but a binary search
-      // is somewhat tough because the sequence test involves
+      // This needs to do a binary search, but a binary search 
+      // is somewhat tough because the sequence test involves 
       // two nodes.
       int size = vec.size(), i;
 
@@ -650,3 +650,4 @@
       return insertIndex;
     } // end addNodeInDocOrder(Vector v, Object obj)
 }
+
--- a/sources/jaxp_src/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java	Wed Sep 28 16:53:17 2011 +0100
@@ -33,7 +33,7 @@
 /**
  * The XPathFactory builds XPaths.
  *
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
  * @author  Ramesh Mandava
  */
 public  class XPathFactoryImpl extends XPathFactory {
@@ -56,7 +56,7 @@
 	/**
 	 * <p>State of secure processing feature.</p>
 	 */
-	private boolean featureSecureProcessing = false;
+	private boolean _isNotSecureProcessing = true;
         /**
          * <p>State of secure mode.</p>
          */
@@ -67,7 +67,7 @@
         public XPathFactoryImpl() {
             if (System.getSecurityManager() != null) {
                 _isSecureMode = true;
-                featureSecureProcessing = true;
+                _isNotSecureProcessing = false;
             }
         }
 		
@@ -119,7 +119,7 @@
 	public javax.xml.xpath.XPath newXPath() {
 	    return new com.sun.org.apache.xpath.internal.jaxp.XPathImpl(
                     xPathVariableResolver, xPathFunctionResolver,
-                    featureSecureProcessing );
+                    !_isNotSecureProcessing );
 	}
 	    
 	/**
@@ -168,7 +168,7 @@
                     throw new XPathFactoryConfigurationException( fmsg );
                 }
 
-                featureSecureProcessing = value;
+                _isNotSecureProcessing = !value;
 						
                 // all done processing feature
                 return;
@@ -217,7 +217,7 @@
 		
             // secure processing?
             if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
-                return featureSecureProcessing;
+                return !_isNotSecureProcessing;
             }
 		
             // unknown feature
--- a/sources/jaxp_src/src/com/sun/xml/internal/stream/XMLInputFactoryImpl.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/xml/internal/stream/XMLInputFactoryImpl.java	Wed Sep 28 16:53:17 2011 +0100
@@ -280,7 +280,24 @@
     }
     
     XMLInputSource jaxpSourcetoXMLInputSource(Source source){
-        throw new UnsupportedOperationException("Cannot create " +
+         if(source instanceof StreamSource){
+             StreamSource stSource = (StreamSource)source;
+             String systemId = stSource.getSystemId();
+             String publicId = stSource.getPublicId();
+             InputStream istream = stSource.getInputStream();
+             Reader reader = stSource.getReader();
+
+             if(istream != null){
+                 return new XMLInputSource(publicId, systemId, null, istream, null);
+             }
+             else if(reader != null){
+                 return new XMLInputSource(publicId, systemId,null, reader, null);
+             }else{
+                 return new XMLInputSource(publicId, systemId, null);
+             }
+         }
+
+         throw new UnsupportedOperationException("Cannot create " +
                 "XMLStreamReader or XMLEventReader from a " +
                 source.getClass().getName());
     }
--- a/sources/jaxp_src/src/com/sun/xml/internal/stream/events/StartDocumentEvent.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/xml/internal/stream/events/StartDocumentEvent.java	Wed Sep 28 16:53:17 2011 +0100
@@ -43,38 +43,43 @@
     protected String fEncodingScheam;
     protected boolean fStandalone;
     protected String fVersion;
-    private boolean fEncodingSchemeSet;
-    private boolean fStandaloneSet;
-    
+    private boolean fEncodingSchemeSet = false;
+    private boolean fStandaloneSet = false;
+    private boolean nestedCall = false;
+
     public StartDocumentEvent() {
-        this("UTF-8","1.0",true,null);
+        init("UTF-8","1.0",true,null);
     }
     
     public StartDocumentEvent(String encoding){
-        this(encoding,"1.0",true,null);
+        init(encoding,"1.0",true,null);
     }
     
     public StartDocumentEvent(String encoding, String version){
-        this(encoding,version,true,null);
+        init(encoding,version,true,null);
     }
     
     public StartDocumentEvent(String encoding, String version, boolean standalone){
-        this(encoding,version,standalone,null);
+        this.fStandaloneSet = true;
+        init(encoding,version,standalone,null);
     }
     
     public StartDocumentEvent(String encoding, String version, boolean standalone,Location loc){
-        init();
+        this.fStandaloneSet = true;
+        init(encoding, version, standalone, loc);
+    }
+    protected void init(String encoding, String version, boolean standalone,Location loc) {
+        setEventType(XMLStreamConstants.START_DOCUMENT);
         this.fEncodingScheam = encoding;
         this.fVersion = version;
         this.fStandalone = standalone;
-        this.fEncodingSchemeSet = false;
-        this.fStandaloneSet = false;
-        if (loc != null) {
-            this.fLocation = loc;
+        if (encoding != null && !encoding.equals(""))
+            this.fEncodingSchemeSet = true;
+        else {
+            this.fEncodingSchemeSet = false;
+            this.fEncodingScheam = "UTF-8";
         }
-    }
-    protected void init() {
-        setEventType(XMLStreamConstants.START_DOCUMENT);
+        this.fLocation = loc;
     }
     
     public String getSystemId() {
--- a/sources/jaxp_src/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java	Wed Sep 28 16:53:17 2011 +0100
@@ -34,6 +34,7 @@
 import java.nio.charset.CharsetEncoder;
 import java.util.AbstractMap;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Random;
 import java.util.Vector;
@@ -43,6 +44,7 @@
 import javax.xml.XMLConstants;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.stream.StreamResult;
@@ -160,6 +162,13 @@
      */
     private CharsetEncoder fEncoder = null;
 
+     /**
+     * This is used to hold the namespace for attributes which happen to have
+     * the same uri as the default namespace; It's added to avoid changing the 
+     * current impl. which has many redundant code for the repair mode
+     */
+    HashMap fAttrNamespace = null;
+
     /**
      * Creates a new instance of XMLStreamWriterImpl. Uses platform's default
      * encoding.
@@ -1482,7 +1491,7 @@
 
             if (fIsRepairingNamespace) {
                 repair();
-                correctPrefix(currentElement);
+                correctPrefix(currentElement, XMLStreamConstants.START_ELEMENT);
 
                 if ((currentElement.prefix != null) &&
                         (currentElement.prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
@@ -1518,8 +1527,13 @@
                             String tmp = fInternalNamespaceContext.getPrefix(attr.uri);
 
                             if ((tmp == null) || (tmp != attr.prefix)) {
-                                if (fInternalNamespaceContext.declarePrefix(attr.prefix,
-                                    attr.uri)) {
+                                tmp = getAttrPrefix(attr.uri);
+                                if (tmp == null) {
+                                    if (fInternalNamespaceContext.declarePrefix(attr.prefix,
+                                        attr.uri)) {
+                                        writenamespace(attr.prefix, attr.uri);
+                                    }
+                                } else {
                                     writenamespace(attr.prefix, attr.uri);
                                 }
                             }
@@ -1529,7 +1543,7 @@
                     writeAttributeWithPrefix(attr.prefix, attr.localpart,
                         attr.value);
                 }
-
+                fAttrNamespace = null;
                 fAttributeCache.clear();
             }
 
@@ -1561,18 +1575,19 @@
      * @param uri
      * @return
      */
-    private void correctPrefix(QName attr) {
+    private void correctPrefix(QName attr, int type) {
         String tmpPrefix = null;
         String prefix;
         String uri;
         prefix = attr.prefix;
         uri = attr.uri;
+        boolean isSpecialCaseURI = false;
 
         if (prefix == null || prefix.equals("")) {
             if (uri == null) {
                 return;
             }
-
+            
             if (prefix == XMLConstants.DEFAULT_NS_PREFIX && uri == XMLConstants.DEFAULT_NS_PREFIX)
                 return;
             
@@ -1593,7 +1608,14 @@
             tmpPrefix = fNamespaceContext.getPrefix(uri);
 
             if (tmpPrefix == XMLConstants.DEFAULT_NS_PREFIX) {
-                return;
+                if (type == XMLStreamConstants.START_ELEMENT) {
+                    return;
+                }
+                else if (type == XMLStreamConstants.ATTRIBUTE) {
+                    //the uri happens to be the same as that of the default namespace
+                    tmpPrefix = getAttrPrefix(uri);
+                    isSpecialCaseURI = true;
+                }
             }
 
             if (tmpPrefix == null) {
@@ -1610,11 +1632,15 @@
             }
 
             if (tmpPrefix == null) {
-                QName qname = new QName();
-                qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null, uri);
-                fNamespaceDecls.add(qname);
-                fInternalNamespaceContext.declarePrefix(fSymbolTable.addSymbol(
+                if (isSpecialCaseURI) {
+                    addAttrNamespace(prefix, uri);
+                } else {
+                    QName qname = new QName();
+                    qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null, uri);
+                    fNamespaceDecls.add(qname);
+                    fInternalNamespaceContext.declarePrefix(fSymbolTable.addSymbol(
                         prefix), uri);
+                }                
             }
         }
 
@@ -1622,6 +1648,21 @@
     }
 
     /**
+     * return the prefix if the attribute has an uri the same as that of the default namespace
+     */
+    private String getAttrPrefix(String uri) {
+        if (fAttrNamespace != null) {
+            return (String)fAttrNamespace.get(uri);
+        }
+        return null;
+    }
+    private void addAttrNamespace(String prefix, String uri) {
+        if (fAttrNamespace == null) {
+            fAttrNamespace = new HashMap();
+        }
+        fAttrNamespace.put(prefix, uri);
+    }
+    /**
      * @param uri
      * @return
      */
@@ -1713,7 +1754,7 @@
 
         for (i = 0; i < fAttributeCache.size(); i++) {
             attr = (Attribute) fAttributeCache.get(i);
-            correctPrefix(attr);
+            correctPrefix(attr, XMLStreamConstants.ATTRIBUTE);
         }
     }
 
--- a/sources/jaxp_src/src/org/xml/sax/SAXException.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/org/xml/sax/SAXException.java	Wed Sep 28 16:53:17 2011 +0100
@@ -163,7 +163,7 @@
     public String toString ()
     {
 	if (exception != null) {
-	    return exception.toString();
+	    return super.toString() + "\n" + exception.toString();
 	} else {
 	    return super.toString();
 	}
--- a/sources/jaxp_src/src/org/xml/sax/SAXParseException.java	Wed Sep 28 16:49:43 2011 +0100
+++ b/sources/jaxp_src/src/org/xml/sax/SAXParseException.java	Wed Sep 28 16:53:17 2011 +0100
@@ -44,23 +44,24 @@
  * in the original XML document, as if it came from a {@link Locator}
  * object.  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
+ * 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
+ * <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
+ * @version 2.0.1 (sax2r2)
  * @see org.xml.sax.SAXException
  * @see org.xml.sax.Locator
  * @see org.xml.sax.ErrorHandler
  */
 public class SAXParseException extends SAXException {
-
-
+    
+    
     //////////////////////////////////////////////////////////////////////
     // Constructors.
     //////////////////////////////////////////////////////////////////////
@@ -79,16 +80,16 @@
      * @see org.xml.sax.Locator
      */
     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);
-        }
+	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.
      *
@@ -105,17 +106,17 @@
      * @see org.xml.sax.Locator
      */
     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);
-        }
+			      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.
      *
@@ -138,13 +139,13 @@
      *                     cause the error or warning.
      */
     public SAXParseException (String message, String publicId, String systemId,
-                              int lineNumber, int columnNumber)
+			      int lineNumber, int columnNumber)
     {
-        super(message);
-        init(publicId, systemId, lineNumber, columnNumber);
+	super(message);
+	init(publicId, systemId, lineNumber, columnNumber);
     }
-
-
+    
+    
     /**
      * Create a new SAXParseException with an embedded exception.
      *
@@ -170,10 +171,10 @@
      * @param e Another exception to embed in this one.
      */
     public SAXParseException (String message, String publicId, String systemId,
-                              int lineNumber, int columnNumber, Exception e)
+			      int lineNumber, int columnNumber, Exception e)
     {
-        super(message, e);
-        init(publicId, systemId, lineNumber, columnNumber);
+	super(message, e);
+	init(publicId, systemId, lineNumber, columnNumber);
     }
 
 
@@ -188,15 +189,15 @@
      * @param columnNumber The column number of the error, or -1.
      */
     private void init (String publicId, String systemId,
-                       int lineNumber, int columnNumber)
+		       int lineNumber, int columnNumber)
     {
-        this.publicId = publicId;
-        this.systemId = systemId;
-        this.lineNumber = lineNumber;
-        this.columnNumber = columnNumber;
+	this.publicId = publicId;
+	this.systemId = systemId;
+	this.lineNumber = lineNumber;
+	this.columnNumber = columnNumber;
     }
-
-
+    
+    
     /**
      * Get the public identifier of the entity where the exception occurred.
      *
@@ -206,10 +207,10 @@
      */
     public String getPublicId ()
     {
-        return this.publicId;
+	return this.publicId;
     }
-
-
+    
+    
     /**
      * Get the system identifier of the entity where the exception occurred.
      *
@@ -222,10 +223,10 @@
      */
     public String getSystemId ()
     {
-        return this.systemId;
+	return this.systemId;
     }
-
-
+    
+    
     /**
      * The line number of the end of the text where the exception occurred.
      *
@@ -237,10 +238,10 @@
      */
     public int getLineNumber ()
     {
-        return this.lineNumber;
+	return this.lineNumber;
     }
-
-
+    
+    
     /**
      * The column number of the end of the text where the exception occurred.
      *
@@ -252,10 +253,27 @@
      */
     public int getColumnNumber ()
     {
-        return this.columnNumber;
+	return this.columnNumber;
     }
+    
+    /**
+     * Override toString to provide more detailed error message.
+     *
+     * @return A string representation of this exception.
+     */
+    public String toString() {
+        StringBuilder buf = new StringBuilder(getClass().getName());
+        String message = getLocalizedMessage();
+        if (publicId!=null)    buf.append("publicId: ").append(publicId);
+        if (systemId!=null)    buf.append("; systemId: ").append(systemId);
+        if (lineNumber!=-1)    buf.append("; lineNumber: ").append(lineNumber);
+        if (columnNumber!=-1)  buf.append("; columnNumber: ").append(columnNumber);
 
-
+       //append the exception message at the end
+        if (message!=null)     buf.append("; ").append(message);
+        return buf.toString();    
+    }
+    
     //////////////////////////////////////////////////////////////////////
     // Internal state.
     //////////////////////////////////////////////////////////////////////
@@ -264,7 +282,7 @@
     /**
      * @serial The public identifier, or null.
      * @see #getPublicId
-     */
+     */    
     private String publicId;
 
 
@@ -287,7 +305,7 @@
      * @see #getColumnNumber
      */
     private int columnNumber;
-
+    
     // Added serialVersionUID to preserve binary compatibility
     static final long serialVersionUID = -5651165872476709336L;
 }