Mercurial > hg > openjdk > icedtea > jdk7 > jaxp
changeset 353:723995d0ef7f
Merge
author | lana |
---|---|
date | Thu, 02 Feb 2012 13:30:54 -0800 |
parents | 7a37651d304d (current diff) 013b8473c684 (diff) |
children | 3fbd87d50fbf |
files | .hgtags |
diffstat | 59 files changed, 832 insertions(+), 864 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri Jan 27 08:49:27 2012 -0800 +++ b/.hgtags Thu Feb 02 13:30:54 2012 -0800 @@ -141,10 +141,13 @@ 0e61ef309edd2deb71f53f2bdaf6dcff1c80bfb8 jdk7u2-b12 d9ac427e5149d1db12c6f3e4aa4280587c06aed5 jdk7u2-b13 0efaf5c97fba2ee7864240efaa0df651a2635ae5 jdk7u2-b21 +98759b436636acf39d07cbc206737fcd831efab0 jdk7u4-b200 26f5422f16af5f4a64157e90b61402ae979e6ffd jdk7u4-b04 c09b58cfa2c61a945614886b82fd284389785770 jdk7u4-b02 f98a23328572f0c586640af1a171d2ccbdfed046 jdk7u4-b05 4ec17260df0f5447c01c57fbc184d97f1e71a029 jdk7u4-b06 +a7da5cf6decbc391fe598d7eae89535e90866c01 jdk7u4-b225 4b20a76b4f0f0bf3d43b065e50570d2cc6676610 jdk7u4-b07 052450632c84ea0cbed641205c752351c46fae54 jdk7u4-b08 +d3b2c77daf2cdb0aa1c50d93e49317727e2eae95 jdk7u4-b227 72cab8feaf319bc3ba688f461fd9aa62ab73a1cb jdk7u4-b09
--- a/make/jprt.properties Fri Jan 27 08:49:27 2012 -0800 +++ b/make/jprt.properties Thu Feb 02 13:30:54 2012 -0800 @@ -25,12 +25,24 @@ # Properties for jprt -# Use whatever release that the submitted job requests -jprt.tools.default.release=${jprt.submit.release} +# Locked down to jdk7 +jprt.tools.default.release=jdk7 # The different build flavors we want, we override here so we just get these 2 jprt.build.flavors=product,fastdebug +# Standard list of jprt build targets for this source tree +jprt.build.targets= \ + solaris_sparc_5.10-{product|fastdebug}, \ + solaris_sparcv9_5.10-{product|fastdebug}, \ + solaris_i586_5.10-{product|fastdebug}, \ + solaris_x64_5.10-{product|fastdebug}, \ + linux_i586_2.6-{product|fastdebug}, \ + linux_x64_2.6-{product|fastdebug}, \ + macosx_x64_10.7-{product|fastdebug}, \ + windows_i586_5.1-{product|fastdebug}, \ + windows_x64_5.2-{product|fastdebug} + # Directories to be excluded from the source bundles jprt.bundle.exclude.src.dirs=build dist webrev
--- a/src/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java Thu Feb 02 13:30:54 2012 -0800 @@ -97,7 +97,7 @@ // In a few cases, the time zone may be +/-hh:30. int min = offset%(60*60*1000); char posneg = hrs < 0? '-': '+'; - buff.append(posneg + formatDigits(hrs) + ':' + formatDigits(min)); + buff.append(posneg).append(formatDigits(hrs)).append(':').append(formatDigits(min)); } return buff.toString(); } @@ -164,7 +164,7 @@ */ public static String date() { - String datetime = dateTime(); + String datetime = dateTime().toString(); String date = datetime.substring(0, datetime.indexOf("T")); String zone = datetime.substring(getZoneStart(datetime)); return (date + zone); @@ -215,7 +215,7 @@ */ public static String time() { - String datetime = dateTime(); + String datetime = dateTime().toString(); String time = datetime.substring(datetime.indexOf("T")+1); // The datetime() function returns the zone on the datetime string. If we @@ -659,6 +659,7 @@ */ public static String monthName() { + Calendar cal = Calendar.getInstance(); String format = "MMMM"; return getNameOrAbbrev(format); }
--- a/src/com/sun/org/apache/xalan/internal/lib/ExsltMath.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/lib/ExsltMath.java Thu Feb 02 13:30:54 2012 -0800 @@ -381,7 +381,7 @@ if (bits <= value.length()) value = value.substring(0, bits); - return new Double(value).doubleValue(); + return Double.parseDouble(value); } else return Double.NaN;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java Thu Feb 02 13:30:54 2012 -0800 @@ -55,11 +55,10 @@ public static void printUsage() { - StringBuffer vers = new StringBuffer("XSLTC version " + - VERSION_MAJOR + "." + VERSION_MINOR + - ((VERSION_DELTA > 0) ? ("."+VERSION_DELTA) : (""))); - System.err.println(vers + "\n" + - new ErrorMsg(ErrorMsg.COMPILE_USAGE_STR)); + System.err.println("XSLTC version " + + VERSION_MAJOR + "." + VERSION_MINOR + + ((VERSION_DELTA > 0) ? ("." + VERSION_DELTA) : ("")) + "\n" + + new ErrorMsg(ErrorMsg.COMPILE_USAGE_STR)); if (_allowExit) System.exit(-1); }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyImports.java Thu Feb 02 13:30:54 2012 -0800 @@ -23,9 +23,13 @@ package com.sun.org.apache.xalan.internal.xsltc.compiler; +import java.util.Enumeration; + import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; +import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; import com.sun.org.apache.bcel.internal.generic.InstructionList; +import com.sun.org.apache.bcel.internal.generic.NEW; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; @@ -85,6 +89,9 @@ _modeName = template.getModeName(); _precedence = template.getImportPrecedence(); + // Get the method name for <xsl:apply-imports/> in this mode + stylesheet = parser.getTopLevelStylesheet(); + parseChildren(parser); // with-params }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java Thu Feb 02 13:30:54 2012 -0800 @@ -378,12 +378,6 @@ = "namespaceArray"; public static final String NAMESPACE_INDEX_SIG = "[" + STRING_SIG; - public static final String NS_ANCESTORS_INDEX_SIG - = "[I"; - public static final String PREFIX_URIS_IDX_SIG - = "[I"; - public static final String PREFIX_URIS_ARRAY_SIG - = "[" + STRING_SIG; public static final String HASIDCALL_INDEX = "_hasIdCall"; public static final String HASIDCALL_INDEX_SIG @@ -392,24 +386,6 @@ = "transletVersion"; public static final String TRANSLET_VERSION_INDEX_SIG = "I"; - public static final String LOOKUP_STYLESHEET_QNAME_NS_REF - = "lookupStylesheetQNameNamespace"; - public static final String LOOKUP_STYLESHEET_QNAME_NS_SIG - = "(" + STRING_SIG - + "I" - + NS_ANCESTORS_INDEX_SIG - + PREFIX_URIS_IDX_SIG - + PREFIX_URIS_ARRAY_SIG - + "Z)" + STRING_SIG; - public static final String EXPAND_STYLESHEET_QNAME_REF - = "expandStylesheetQNameRef"; - public static final String EXPAND_STYLESHEET_QNAME_SIG - = "(" + STRING_SIG - + "I" - + NS_ANCESTORS_INDEX_SIG - + PREFIX_URIS_IDX_SIG - + PREFIX_URIS_ARRAY_SIG - + "Z)" + STRING_SIG; public static final String DOM_FIELD = "_dom"; @@ -421,12 +397,6 @@ = "_sTypesArray"; public static final String STATIC_NAMESPACE_ARRAY_FIELD = "_sNamespaceArray"; - public static final String STATIC_NS_ANCESTORS_ARRAY_FIELD - = "_sNamespaceAncestorsArray"; - public static final String STATIC_PREFIX_URIS_IDX_ARRAY_FIELD - = "_sPrefixURIsIdxArray"; - public static final String STATIC_PREFIX_URIS_ARRAY_FIELD - = "_sPrefixURIPairsArray"; public static final String STATIC_CHAR_DATA_FIELD = "_scharData"; public static final String STATIC_CHAR_DATA_FIELD_SIG
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionAvailableCall.java Thu Feb 02 13:30:54 2012 -0800 @@ -100,6 +100,7 @@ * the specified method is found in the specifed class. */ private boolean hasMethods() { + LiteralExpr arg = (LiteralExpr)_arg; // Get the class name from the namespace uri String className = getClassNameFromUri(_namespaceOfFunct);
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java Thu Feb 02 13:30:54 2012 -0800 @@ -113,8 +113,6 @@ */ private Vector _allValidTemplates = null; - private Vector _elementsWithNamespacesUsedDynamically = null; - /** * Counter to generate unique mode suffixes. */ @@ -747,59 +745,10 @@ } /** - * <p>Compile the namesArray, urisArray, typesArray, namespaceArray, - * namespaceAncestorsArray, prefixURIsIdxArray and prefixURIPairsArray into + * Compile the namesArray, urisArray and typesArray into * the static initializer. They are read-only from the * translet. All translet instances can share a single - * copy of this informtion.</p> - * <p>The <code>namespaceAncestorsArray</code>, - * <code>prefixURIsIdxArray</code> and <code>prefixURIPairsArray</code> - * contain namespace information accessible from the stylesheet: - * <dl> - * <dt><code>namespaceAncestorsArray</code></dt> - * <dd>Array indexed by integer stylesheet node IDs containing node IDs of - * the nearest ancestor node in the stylesheet with namespace - * declarations or <code>-1</code> if there is no such ancestor. There - * can be more than one disjoint tree of nodes - one for each stylesheet - * module</dd> - * <dt><code>prefixURIsIdxArray</code></dt> - * <dd>Array indexed by integer stylesheet node IDs containing the index - * into <code>prefixURIPairsArray</code> of the first namespace prefix - * declared for the node. The values are stored in ascending order, so - * the next value in this array (if any) can be used to find the last such - * prefix-URI pair</dd> - * <dt>prefixURIPairsArray</dt> - * <dd>Array of pairs of namespace prefixes and URIs. A zero-length - * string represents the default namespace if it appears as a prefix and - * a namespace undeclaration if it appears as a URI.</dd> - * </dl> - * </p> - * <p>For this stylesheet - * <pre><code> - * <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> - * <xsl:template match="/"> - * <xsl:for-each select="*" xmlns:foo="foouri"> - * <xsl:element name="{n}" xmlns:foo="baruri"> - * </xsl:for-each> - * <out xmlns="lumpit"/> - * <xsl:element name="{n}" xmlns="foouri"/> - * <xsl:element name="{n}" namespace="{ns}" xmlns="limpit"/gt; - * </xsl:template> - * </xsl:stylesheet> - * </code></pre> - * there will be four stylesheet nodes whose namespace information is - * needed, and - * <ul> - * <li><code>namespaceAncestorsArray</code> will have the value - * <code>[-1,0,1,0]</code>;</li> - * <li><code>prefixURIsIdxArray</code> will have the value - * <code>[0,4,6,8]</code>; and</li> - * <li><code>prefixURIPairsArray</code> will have the value - * <code>["xml","http://www.w3.org/XML/1998/namespace", - * "xsl","http://www.w3.org/1999/XSL/Transform" - * "foo","foouri","foo","baruri","","foouri"].</code></li> - * </ul> - * </p> + * copy of this informtion. */ private void compileStaticInitializer(ClassGenerator classGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); @@ -933,83 +882,6 @@ staticConst.markChunkEnd(); } - // Put the tree of stylesheet namespace declarations into the translet - final Vector namespaceAncestors = getXSLTC().getNSAncestorPointers(); - if (namespaceAncestors != null && namespaceAncestors.size() != 0) { - addStaticField(classGen, NS_ANCESTORS_INDEX_SIG, - STATIC_NS_ANCESTORS_ARRAY_FIELD); - staticConst.markChunkStart(); - il.append(new PUSH(cpg, namespaceAncestors.size())); - il.append(new NEWARRAY(BasicType.INT)); - int namespaceAncestorsArrayRef = - cpg.addFieldref(_className, STATIC_NS_ANCESTORS_ARRAY_FIELD, - NS_ANCESTORS_INDEX_SIG); - il.append(new PUTSTATIC(namespaceAncestorsArrayRef)); - staticConst.markChunkEnd(); - for (int i = 0; i < namespaceAncestors.size(); i++) { - int ancestor = ((Integer) namespaceAncestors.get(i)).intValue(); - staticConst.markChunkStart(); - il.append(new GETSTATIC(namespaceAncestorsArrayRef)); - il.append(new PUSH(cpg, i)); - il.append(new PUSH(cpg, ancestor)); - il.append(IASTORE); - staticConst.markChunkEnd(); - } - } - // Put the array of indices into the namespace prefix/URI pairs array - // into the translet - final Vector prefixURIPairsIdx = getXSLTC().getPrefixURIPairsIdx(); - if (prefixURIPairsIdx != null && prefixURIPairsIdx.size() != 0) { - addStaticField(classGen, PREFIX_URIS_IDX_SIG, - STATIC_PREFIX_URIS_IDX_ARRAY_FIELD); - staticConst.markChunkStart(); - il.append(new PUSH(cpg, prefixURIPairsIdx.size())); - il.append(new NEWARRAY(BasicType.INT)); - int prefixURIPairsIdxArrayRef = - cpg.addFieldref(_className, - STATIC_PREFIX_URIS_IDX_ARRAY_FIELD, - PREFIX_URIS_IDX_SIG); - il.append(new PUTSTATIC(prefixURIPairsIdxArrayRef)); - staticConst.markChunkEnd(); - for (int i = 0; i < prefixURIPairsIdx.size(); i++) { - int idx = ((Integer) prefixURIPairsIdx.get(i)).intValue(); - staticConst.markChunkStart(); - il.append(new GETSTATIC(prefixURIPairsIdxArrayRef)); - il.append(new PUSH(cpg, i)); - il.append(new PUSH(cpg, idx)); - il.append(IASTORE); - staticConst.markChunkEnd(); - } - } - - // Put the array of pairs of namespace prefixes and URIs into the - // translet - final Vector prefixURIPairs = getXSLTC().getPrefixURIPairs(); - if (prefixURIPairs != null && prefixURIPairs.size() != 0) { - addStaticField(classGen, PREFIX_URIS_ARRAY_SIG, - STATIC_PREFIX_URIS_ARRAY_FIELD); - - staticConst.markChunkStart(); - il.append(new PUSH(cpg, prefixURIPairs.size())); - il.append(new ANEWARRAY(cpg.addClass(STRING))); - int prefixURIPairsRef = - cpg.addFieldref(_className, - STATIC_PREFIX_URIS_ARRAY_FIELD, - PREFIX_URIS_ARRAY_SIG); - il.append(new PUTSTATIC(prefixURIPairsRef)); - staticConst.markChunkEnd(); - for (int i = 0; i < prefixURIPairs.size(); i++) { - String prefixOrURI = (String) prefixURIPairs.get(i); - staticConst.markChunkStart(); - il.append(new GETSTATIC(prefixURIPairsRef)); - il.append(new PUSH(cpg, i)); - il.append(new PUSH(cpg, prefixOrURI)); - il.append(AASTORE); - staticConst.markChunkEnd(); - } - } - - // Grab all the literal text in the stylesheet and put it in a char[] final int charDataCount = getXSLTC().getCharacterDataCount(); final int toCharArray = cpg.addMethodref(STRING, "toCharArray", "()[C");
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java Thu Feb 02 13:30:54 2012 -0800 @@ -160,7 +160,7 @@ private int _nsCounter = 0; public String generateNamespacePrefix() { - return(new String("ns"+(_nsCounter++))); + return("ns"+(_nsCounter++)); } /**
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java Thu Feb 02 13:30:54 2012 -0800 @@ -77,11 +77,6 @@ private int _line; // Source file line number protected AttributesImpl _attributes = null; // Attributes of this element private Hashtable _prefixMapping = null; // Namespace declarations - public static final int UNKNOWN_STYLESHEET_NODE_ID = -1; - - // Records whether this node or any descendant needs to know the - // in-scope namespaces at transform-time - private int _nodeIDForStylesheetNSLookup = UNKNOWN_STYLESHEET_NODE_ID; // Sentinel - used to denote unrecognised syntaxt tree nodes. protected static final SyntaxTreeNode Dummy = new AbsolutePathPattern(null); @@ -756,35 +751,6 @@ il.append(SWAP); il.append(methodGen.storeHandler()); } - /** - * Retrieve an ID to identify the namespaces in scope at this point in the - * stylesheet - * @return An <code>int</code> representing the node ID or <code>-1</code> - * if no namespace declarations are in scope - */ - protected final int getNodeIDForStylesheetNSLookup() { - if (_nodeIDForStylesheetNSLookup == UNKNOWN_STYLESHEET_NODE_ID) { - Hashtable prefixMapping = getPrefixMapping(); - int parentNodeID = - (_parent != null) ? _parent.getNodeIDForStylesheetNSLookup() - : UNKNOWN_STYLESHEET_NODE_ID; - - // If this node in the stylesheet has no namespace declarations of - // its own, use the ID of the nearest ancestor element that does - // have namespace declarations. - if (prefixMapping == null) { - _nodeIDForStylesheetNSLookup = parentNodeID; - } else { - // Inform the XSLTC object that we'll need to know about this - // node's namespace declarations. - _nodeIDForStylesheetNSLookup = - getXSLTC().registerStylesheetPrefixMappingForRuntime( - prefixMapping, parentNodeID); - } - } - - return _nodeIDForStylesheetNSLookup; - } /** * Returns true if this expression/instruction depends on the context. By
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/TestSeq.java Thu Feb 02 13:30:54 2012 -0800 @@ -108,10 +108,10 @@ (LocationPathPattern) _patterns.elementAt(i); if (i == 0) { - result.append("Testseq for kernel " + _kernelType) + result.append("Testseq for kernel ").append(_kernelType) .append('\n'); } - result.append(" pattern " + i + ": ") + result.append(" pattern ").append(i).append(": ") .append(pattern.toString()) .append('\n'); }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Whitespace.java Thu Feb 02 13:30:54 2012 -0800 @@ -157,8 +157,7 @@ if (col != -1) { namespace = lookupNamespace(token.substring(0,col)); if (namespace != null) { - elements.append(namespace+":"+ - token.substring(col+1,token.length())); + elements.append(namespace).append(':').append(token.substring(col + 1)); } else { elements.append(token); }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Thu Feb 02 13:30:54 2012 -0800 @@ -33,7 +33,6 @@ import java.util.Date; import java.util.Enumeration; import java.util.Hashtable; -import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Vector; @@ -118,9 +117,7 @@ private boolean _callsNodeset = false; private boolean _multiDocument = false; private boolean _hasIdCall = false; - private Vector _stylesheetNSAncestorPointers; - private Vector _prefixURIPairs; - private Vector _prefixURIPairsIdx; + /** * Set to true if template inlining is requested. Template * inlining used to be the default, but we have found that @@ -223,9 +220,6 @@ _attributeSetSerial = 0; _multiDocument = false; _hasIdCall = false; - _stylesheetNSAncestorPointers = null; - _prefixURIPairs = null; - _prefixURIPairsIdx = null; _numberFieldIndexes = new int[] { -1, // LEVEL_SINGLE -1, // LEVEL_MULTIPLE @@ -714,20 +708,6 @@ * Registers a namespace and gives it a type so that it can be mapped to * DOM namespace types at run-time. */ - public int registerNamespacePrefix(String name) { - Integer code = (Integer)_namespacePrefixes.get(name); - if (code == null) { - code = new Integer(_nextGType++); - _namespacePrefixes.put(name, code); - _namesIndex.addElement("?"+name); - } - return code.intValue(); - } - - /** - * Registers a namespace and gives it a type so that it can be mapped to - * DOM namespace types at run-time. - */ public int registerNamespace(String namespaceURI) { Integer code = (Integer)_namespaces.get(namespaceURI); if (code == null) { @@ -738,66 +718,6 @@ return code.intValue(); } - /** - * Registers namespace declarations that the stylesheet might need to - * look up dynamically - for instance, if an <code>xsl:element</code> has a - * a <code>name</code> attribute with variable parts and has no - * <code>namespace</code> attribute. - * - * @param prefixMap a <code>Hashtable</code> mapping namespace prefixes to - * URIs. Must not be <code>null</code>. The default - * namespace and namespace undeclarations are represented - * by a zero-length string. - * @param ancestorID The <code>int</code> node ID of the nearest ancestor in - * the stylesheet that declares namespaces, or a value less - * than zero if there is no such ancestor - * @return A new node ID for the stylesheet element - */ - public int registerStylesheetPrefixMappingForRuntime(Hashtable prefixMap, - int ancestorID) { - if (_stylesheetNSAncestorPointers == null) { - _stylesheetNSAncestorPointers = new Vector(); - } - - if (_prefixURIPairs == null) { - _prefixURIPairs = new Vector(); - } - - if (_prefixURIPairsIdx == null) { - _prefixURIPairsIdx = new Vector(); - } - - int currentNodeID = _stylesheetNSAncestorPointers.size(); - _stylesheetNSAncestorPointers.add(new Integer(ancestorID)); - - Iterator prefixMapIterator = prefixMap.entrySet().iterator(); - int prefixNSPairStartIdx = _prefixURIPairs.size(); - _prefixURIPairsIdx.add(new Integer(prefixNSPairStartIdx)); - - while (prefixMapIterator.hasNext()) { - Map.Entry entry = (Map.Entry) prefixMapIterator.next(); - String prefix = (String) entry.getKey(); - String uri = (String) entry.getValue(); - _prefixURIPairs.add(prefix); - _prefixURIPairs.add(uri); - } - - return currentNodeID; - } - - public Vector getNSAncestorPointers() { - return _stylesheetNSAncestorPointers; - } - - public Vector getPrefixURIPairs() { - return _prefixURIPairs; - } - - public Vector getPrefixURIPairsIdx() { - return _prefixURIPairsIdx; - } - - public int nextModeSerial() { return _modeSerial++; }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XslElement.java Thu Feb 02 13:30:54 2012 -0800 @@ -26,7 +26,6 @@ import com.sun.org.apache.bcel.internal.generic.ALOAD; import com.sun.org.apache.bcel.internal.generic.ASTORE; import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; -import com.sun.org.apache.bcel.internal.generic.GETSTATIC; import com.sun.org.apache.bcel.internal.generic.ICONST; import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; import com.sun.org.apache.bcel.internal.generic.InstructionList; @@ -141,9 +140,6 @@ } } else { - // name attribute contains variable parts. If there is no namespace - // attribute, the generated code needs to be prepared to look up - // any prefix in the stylesheet at run-time. _namespace = (namespace == EMPTYSTRING) ? null : new AttributeValueTemplate(namespace, parser, this); } @@ -255,34 +251,7 @@ _namespace.translate(classGen, methodGen); } else { - // If name is an AVT and namespace is not specified, need to - // look up any prefix in the stylesheet by calling - // BasisLibrary.lookupStylesheetQNameNamespace( - // name, stylesheetNode, ancestorsArray, - // prefixURIsIndexArray, prefixURIPairsArray, - // !ignoreDefaultNamespace) - String transletClassName = getXSLTC().getClassName(); - il.append(DUP); - il.append(new PUSH(cpg, getNodeIDForStylesheetNSLookup())); - il.append(new GETSTATIC(cpg.addFieldref( - transletClassName, - STATIC_NS_ANCESTORS_ARRAY_FIELD, - NS_ANCESTORS_INDEX_SIG))); - il.append(new GETSTATIC(cpg.addFieldref( - transletClassName, - STATIC_PREFIX_URIS_IDX_ARRAY_FIELD, - PREFIX_URIS_IDX_SIG))); - il.append(new GETSTATIC(cpg.addFieldref( - transletClassName, - STATIC_PREFIX_URIS_ARRAY_FIELD, - PREFIX_URIS_ARRAY_SIG))); - // Default namespace is significant - il.append(ICONST_0); - il.append( - new INVOKESTATIC( - cpg.addMethodref(BASIS_LIBRARY_CLASS, - LOOKUP_STYLESHEET_QNAME_NS_REF, - LOOKUP_STYLESHEET_QNAME_NS_SIG))); + il.append(ACONST_NULL); } // Push additional arguments
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java Thu Feb 02 13:30:54 2012 -0800 @@ -269,7 +269,7 @@ */ public String toString() { String suffix = (_params == null) ? - (null != _code ? new String(getErrorMessage()) : _message) + (null != _code ? getErrorMessage() : _message) : MessageFormat.format(getErrorMessage(), _params); return formatLine() + suffix; }
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java Thu Feb 02 13:30:54 2012 -0800 @@ -688,6 +688,7 @@ // Get the current number of local variable slots int maxLocals = super.getMaxLocals(); + int prevLocals = maxLocals; // Get numer of actual variables final LocalVariableGen[] localVars = super.getLocalVariables();
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Thu Feb 02 13:30:54 2012 -0800 @@ -53,6 +53,7 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import com.sun.org.apache.xml.internal.serializer.NamespaceMappings; import com.sun.org.apache.xml.internal.serializer.SerializationHandler; import com.sun.org.apache.xml.internal.utils.XML11Char; @@ -1473,7 +1474,18 @@ // Handle case when prefix is not known at compile time if (namespace == null || namespace.length() == 0) { - runTimeError(NAMESPACE_PREFIX_ERR,prefix); + try { + // not sure if this line of code ever works + namespace = dom.lookupNamespace(node, prefix); + } + catch(RuntimeException e) { + handler.flushPending(); // need to flush or else can't get namespacemappings + NamespaceMappings nm = handler.getNamespaceMappings(); + namespace = nm.lookupNamespace(prefix); + if (namespace == null) { + runTimeError(NAMESPACE_PREFIX_ERR,prefix); + } + } } handler.startElement(namespace, qname.substring(index+1), @@ -1501,141 +1513,6 @@ } /** - * <p>Look up the namespace for a lexical QName using the namespace - * declarations available at a particular location in the stylesheet.</p> - * <p>See {@link org.apache.xalan.xsltc.compiler.Stylesheet#compileStaticInitializer(org.apache.xalan.xsltc.compiler.util.ClassGenerator)} - * for more information about the <code>ancestorNodeIDs</code>, - * <code>prefixURIsIndex</code> and <code>prefixURIPairs</code arrays.</p> - * - * @param lexicalQName The QName as a <code>java.lang.String</code> - * @param stylesheetNodeID An <code>int</code> representing the element in - * the stylesheet relative to which the namespace of - * the lexical QName is to be determined - * @param ancestorNodeIDs An <code>int</code> array, indexed by stylesheet - * node IDs, containing the ID of the nearest ancestor - * node in the stylesheet that has namespace - * declarations, or <code>-1</code> if there is no - * such ancestor - * @param prefixURIsIndex An <code>int</code> array, indexed by stylesheet - * node IDs, containing the index into the - * <code>prefixURIPairs</code> array of the first - * prefix declared on that stylesheet node - * @param prefixURIPairs A <code>java.lang.String</code> array that contains - * pairs of - * @param ignoreDefault A <code>boolean</code> indicating whether any - * default namespace decarlation should be considered - * @return The namespace of the lexical QName or a zero-length string if - * the QName is in no namespace or no namespace declaration for the - * prefix of the QName was found - */ - public static String lookupStylesheetQNameNamespace(String lexicalQName, - int stylesheetNodeID, - int[] ancestorNodeIDs, - int[] prefixURIsIndex, - String[] prefixURIPairs, - boolean ignoreDefault) { - String prefix = getPrefix(lexicalQName); - String uri = ""; - - if (prefix == null && !ignoreDefault) { - prefix = ""; - } - - if (prefix != null) { - // Loop from current node in the stylesheet to its ancestors - nodeLoop: - for (int currentNodeID = stylesheetNodeID; - currentNodeID >= 0; - currentNodeID = ancestorNodeIDs[currentNodeID]) { - // Look at all declarations on the current stylesheet node - // The prefixURIsIndex is an array of indices into the - // prefixURIPairs array that are stored in ascending order. - // The declarations for a node I are in elements - // prefixURIsIndex[I] to prefixURIsIndex[I+1]-1 (or - // prefixURIPairs.length-1 if I is the last node) - int prefixStartIdx = prefixURIsIndex[currentNodeID]; - int prefixLimitIdx = (currentNodeID+1 < prefixURIsIndex.length) - ? prefixURIsIndex[currentNodeID + 1] - : prefixURIPairs.length; - - for (int prefixIdx = prefixStartIdx; - prefixIdx < prefixLimitIdx; - prefixIdx = prefixIdx + 2) { - // Did we find the declaration of our prefix - if (prefix.equals(prefixURIPairs[prefixIdx])) { - uri = prefixURIPairs[prefixIdx+1]; - break nodeLoop; - } - } - } - } - - return uri; - } - - /** - * <p>Look up the namespace for a lexical QName using the namespace - * declarations available at a particular location in the stylesheet and - * return the expanded QName</p> - * <p>See {@link org.apache.xalan.xsltc.compiler.Stylesheet#compileStaticInitializer(org.apache.xalan.xsltc.compiler.util.ClassGenerator)} - * for more information about the <code>ancestorNodeIDs</code>, - * <code>prefixURIsIndex</code> and <code>prefixURIPairs</code arrays.</p> - * - * @param lexicalQName The QName as a <code>java.lang.String</code> - * @param stylesheetNodeID An <code>int</code> representing the element in - * the stylesheet relative to which the namespace of - * the lexical QName is to be determined - * @param ancestorNodeIDs An <code>int</code> array, indexed by stylesheet - * node IDs, containing the ID of the nearest ancestor - * node in the stylesheet that has namespace - * declarations, or <code>-1</code> if there is no - * such ancestor - * @param prefixURIsIndex An <code>int</code> array, indexed by stylesheet - * node IDs, containing the index into the - * <code>prefixURIPairs</code> array of the first - * prefix declared on that stylesheet node - * @param prefixURIPairs A <code>java.lang.String</code> array that contains - * pairs of - * @param ignoreDefault A <code>boolean</code> indicating whether any - * default namespace decarlation should be considered - * @return The expanded QName in the form "uri:localName" or just - * "localName" if the QName is in no namespace or no namespace - * declaration for the prefix of the QName was found - */ - public static String expandStylesheetQNameRef(String lexicalQName, - int stylesheetNodeID, - int[] ancestorNodeIDs, - int[] prefixURIsIndex, - String[] prefixURIPairs, - boolean ignoreDefault) { - String expandedQName; - String prefix = getPrefix(lexicalQName); - String localName = (prefix != null) - ? lexicalQName.substring(prefix.length()+1) - : lexicalQName; - String uri = lookupStylesheetQNameNamespace(lexicalQName, - stylesheetNodeID, - ancestorNodeIDs, - prefixURIsIndex, - prefixURIPairs, - ignoreDefault); - - // Handle case when prefix is not resolved - if (prefix != null && prefix.length() != 0 - && (uri == null || uri.length() == 0)) { - runTimeError(NAMESPACE_PREFIX_ERR, prefix); - } - - if (uri.length() == 0) { - expandedQName = localName; - } else { - expandedQName = uri + ':' + localName; - } - - return expandedQName; - } - - /** * This function is used in the execution of xsl:element */ public static String getPrefix(String qname) {
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java Thu Feb 02 13:30:54 2012 -0800 @@ -294,7 +294,7 @@ for (i = 0; i <= max; i++) { String s1 = k.nextElement().toString(); String s2 = e.nextElement().toString(); - buf.append(s1 + "=" + s2); + buf.append(s1).append('=').append(s2); if (i < max) buf.append(", "); } buf.append("}");
--- a/src/com/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/runtime/StringValueHandler.java Thu Feb 02 13:30:54 2012 -0800 @@ -94,6 +94,7 @@ // Override the setEscaping method just to indicate that this class is // aware that that method might be called. public boolean setEscaping(boolean bool) { + boolean oldEscaping = m_escaping; m_escaping = bool; return bool;
--- a/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Thu Feb 02 13:30:54 2012 -0800 @@ -1268,7 +1268,7 @@ try { // Argument to document function was: document(''); if (href.length() == 0) { - href = new String(baseURI); + href = baseURI; } /*
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Thu Feb 02 13:30:54 2012 -0800 @@ -365,11 +365,6 @@ // shared context - /** Shared declared entities. - * XXX understand it more deeply, why are we doing this ?? Is it really required ? - */ - protected Hashtable fDeclaredEntities; - protected XMLEntityStorage fEntityStorage ; protected final Object [] defaultEncoding = new Object[]{"UTF-8", null}; @@ -409,24 +404,6 @@ } // <init>() /** - * Constructs an entity manager that shares the specified entity - * declarations during each parse. - * <p> - * <strong>REVISIT:</strong> We might want to think about the "right" - * way to expose the list of declared entities. For now, the knowledge - * how to access the entity declarations is implicit. - */ - public XMLEntityManager(XMLEntityManager entityManager) { - - - // save shared entity declarations - fDeclaredEntities = entityManager != null - ? entityManager.getEntityStore().getDeclaredEntities() : null; - - setScannerVersion(Constants.XML_VERSION_1_0); - } // <init>(XMLEntityManager) - - /** * Adds an internal entity declaration. * <p> * <strong>Note:</strong> This method ignores subsequent entity @@ -1111,7 +1088,7 @@ throws IOException, XNIException { // was entity declared? - Entity entity = (Entity)fEntityStorage.getDeclaredEntities().get(entityName); + Entity entity = (Entity)fEntityStorage.getEntity(entityName); if (entity == null) { if (fEntityHandler != null) { String encoding = null; @@ -1533,15 +1510,6 @@ } } - // copy declared entities - if (fDeclaredEntities != null) { - java.util.Enumeration keys = fDeclaredEntities.keys(); - while (keys.hasMoreElements()) { - Object key = keys.nextElement(); - Object value = fDeclaredEntities.get(key); - fEntities.put(key, value); - } - } fEntityHandler = null; // reset scanner
--- a/src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xerces/internal/impl/XMLStreamReaderImpl.java Thu Feb 02 13:30:54 2012 -0800 @@ -1051,11 +1051,10 @@ return fScanner.getCharacterData().toString(); XMLEntityStorage entityStore = fEntityManager.getEntityStore(); - Hashtable ht = entityStore.getDeclaredEntities(); - Entity en = (Entity)ht.get(name); - if(en == null) - return null; - if(en.isExternal()) + Entity en = entityStore.getEntity(name); + if(en == null) + return null; + if(en.isExternal()) return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId(); else return ((Entity.InternalEntity)en).text; @@ -1182,8 +1181,7 @@ return true; XMLEntityStorage entityStore = fEntityManager.getEntityStore(); - Hashtable ht = entityStore.getDeclaredEntities(); - Entity en =(Entity)ht.get(name); + Entity en = entityStore.getEntity(name); if(en == null) return false; if(en.isExternal()){ @@ -1324,15 +1322,14 @@ protected List getEntityDecls(){ if(fEventType == XMLStreamConstants.DTD){ XMLEntityStorage entityStore = fEntityManager.getEntityStore(); - Hashtable ht = entityStore.getDeclaredEntities(); ArrayList list = null; - if(ht != null){ + if(entityStore.hasEntities()){ EntityDeclarationImpl decl = null; - list = new ArrayList(ht.size()); - Enumeration enu = ht.keys(); + list = new ArrayList(entityStore.getEntitySize()); + Enumeration enu = entityStore.getEntityKeys(); while(enu.hasMoreElements()){ String key = (String)enu.nextElement(); - Entity en = (Entity)ht.get(key); + Entity en = (Entity)entityStore.getEntity(key); decl = new EntityDeclarationImpl(); decl.setEntityName(key); if(en.isExternal()){
--- a/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java Thu Feb 02 13:30:54 2012 -0800 @@ -112,8 +112,16 @@ * to be recognized. */ public void addRecognizedFeatures(String[] featureIds) { - if (featureIds == null) return; - fRecognizedFeatures.addAll(Arrays.asList(featureIds)); + + // add recognized features + int featureIdsCount = featureIds != null ? featureIds.length : 0; + for (int i = 0; i < featureIdsCount; i++) { + String featureId = featureIds[i]; + if (!fRecognizedFeatures.contains(featureId)) { + fRecognizedFeatures.add(featureId); + } + } + } // addRecognizedFeatures(String[]) /**
--- a/src/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBase.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBase.java Thu Feb 02 13:30:54 2012 -0800 @@ -844,12 +844,10 @@ break; } - StringBuffer sb=new StringBuffer(); - sb.append("["+nodeHandle+": "+typestring+ - "(0x"+Integer.toHexString(getExpandedTypeID(nodeHandle))+") "+ - getNodeNameX(nodeHandle)+" {"+getNamespaceURI(nodeHandle)+"}"+ - "=\""+ getNodeValue(nodeHandle)+"\"]"); - return sb.toString(); + return "[" + nodeHandle + ": " + typestring + + "(0x" + Integer.toHexString(getExpandedTypeID(nodeHandle)) + ") " + + getNodeNameX(nodeHandle) + " {" + getNamespaceURI(nodeHandle) + "}" + + "=\"" + getNodeValue(nodeHandle) + "\"]"; } // ========= DTM Implementation Control Functions. ==============
--- a/src/com/sun/org/apache/xml/internal/dtm/ref/dom2dtm/DOM2DTM.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/dtm/ref/dom2dtm/DOM2DTM.java Thu Feb 02 13:30:54 2012 -0800 @@ -1725,7 +1725,7 @@ try { Node node = getNode(nodeHandle); - treeWalker.traverse(node); + treeWalker.traverseFragment(node); } finally {
--- a/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java Thu Feb 02 13:30:54 2012 -0800 @@ -55,7 +55,7 @@ final class CharInfo { /** Given a character, lookup a String to output (e.g. a decorated entity reference). */ - private HashMap m_charToString = new HashMap(); + private HashMap m_charToString; /** * The name of the HTML entities file. @@ -72,42 +72,50 @@ "com.sun.org.apache.xml.internal.serializer.XMLEntities"; /** The horizontal tab character, which the parser should always normalize. */ - public static final char S_HORIZONAL_TAB = 0x09; + static final char S_HORIZONAL_TAB = 0x09; /** The linefeed character, which the parser should always normalize. */ - public static final char S_LINEFEED = 0x0A; + static final char S_LINEFEED = 0x0A; /** The carriage return character, which the parser should always normalize. */ - public static final char S_CARRIAGERETURN = 0x0D; + static final char S_CARRIAGERETURN = 0x0D; + static final char S_SPACE = 0x20; + static final char S_QUOTE = 0x22; + static final char S_LT = 0x3C; + static final char S_GT = 0x3E; + static final char S_NEL = 0x85; + static final char S_LINE_SEPARATOR = 0x2028; /** This flag is an optimization for HTML entities. It false if entities * other than quot (34), amp (38), lt (60) and gt (62) are defined * in the range 0 to 127. * @xsl.usage internal */ - final boolean onlyQuotAmpLtGt; + boolean onlyQuotAmpLtGt; /** Copy the first 0,1 ... ASCII_MAX values into an array */ - private static final int ASCII_MAX = 128; + static final int ASCII_MAX = 128; /** Array of values is faster access than a set of bits - * to quickly check ASCII characters in attribute values. + * to quickly check ASCII characters in attribute values, + * the value is true if the character in an attribute value + * should be mapped to a String. */ - private boolean[] isSpecialAttrASCII = new boolean[ASCII_MAX]; + private final boolean[] shouldMapAttrChar_ASCII; /** Array of values is faster access than a set of bits - * to quickly check ASCII characters in text nodes. + * to quickly check ASCII characters in text nodes, + * the value is true if the character in a text node + * should be mapped to a String. */ - private boolean[] isSpecialTextASCII = new boolean[ASCII_MAX]; - - private boolean[] isCleanTextASCII = new boolean[ASCII_MAX]; + private final boolean[] shouldMapTextChar_ASCII; /** An array of bits to record if the character is in the set. * Although information in this array is complete, the * isSpecialAttrASCII array is used first because access to its values * is common and faster. */ - private int array_of_bits[] = createEmptySetOfIntegers(65535); + private final int array_of_bits[]; // 5 for 32 bit words, 6 for 64 bit words ... @@ -138,33 +146,38 @@ /** - * Constructor that reads in a resource file that describes the mapping of - * characters to entity references. - * This constructor is private, just to force the use - * of the getCharInfo(entitiesResource) factory - * - * Resource files must be encoded in UTF-8 and can either be properties - * files with a .properties extension assumed. Alternatively, they can - * have the following form, with no particular extension assumed: + * A base constructor just to explicitly create the fields, + * with the exception of m_charToString which is handled + * by the constructor that delegates base construction to this one. + * <p> + * m_charToString is not created here only for performance reasons, + * to avoid creating a Hashtable that will be replaced when + * making a mutable copy, {@link #mutableCopyOf(CharInfo)}. * - * <pre> - * # First char # is a comment - * Entity numericValue - * quot 34 - * amp 38 - * </pre> - * - * @param entitiesResource Name of properties or resource file that should - * be loaded, which describes that mapping of characters to entity - * references. */ - private CharInfo(String entitiesResource, String method) + private CharInfo() { - this(entitiesResource, method, false); + this.array_of_bits = createEmptySetOfIntegers(65535); + this.firstWordNotUsed = 0; + this.shouldMapAttrChar_ASCII = new boolean[ASCII_MAX]; + this.shouldMapTextChar_ASCII = new boolean[ASCII_MAX]; + this.m_charKey = new CharKey(); + + // Not set here, but in a constructor that uses this one + // this.m_charToString = new Hashtable(); + + this.onlyQuotAmpLtGt = true; + + + return; } private CharInfo(String entitiesResource, String method, boolean internal) { + // call the default constructor to create the fields + this(); + m_charToString = new HashMap(); + ResourceBundle entities = null; boolean noExtraEntities = true; @@ -190,12 +203,10 @@ String name = (String) keys.nextElement(); String value = entities.getString(name); int code = Integer.parseInt(value); - defineEntity(name, (char) code); - if (extraEntity(code)) + boolean extra = defineEntity(name, (char) code); + if (extra) noExtraEntities = false; } - set(S_LINEFEED); - set(S_CARRIAGERETURN); } else { InputStream is = null; @@ -279,8 +290,8 @@ int code = Integer.parseInt(value); - defineEntity(name, (char) code); - if (extraEntity(code)) + boolean extra = defineEntity(name, (char) code); + if (extra) noExtraEntities = false; } } @@ -289,8 +300,6 @@ } is.close(); - set(S_LINEFEED); - set(S_CARRIAGERETURN); } catch (Exception e) { throw new RuntimeException( Utils.messages.createMessage( @@ -308,31 +317,8 @@ } } - /* initialize the array isCleanTextASCII[] with a cache of values - * for use by ToStream.character(char[], int , int) - * and the array isSpecialTextASCII[] with the opposite values - * (all in the name of performance!) - */ - for (int ch = 0; ch <ASCII_MAX; ch++) - if((((0x20 <= ch || (0x0A == ch || 0x0D == ch || 0x09 == ch))) - && (!get(ch))) || ('"' == ch)) - { - isCleanTextASCII[ch] = true; - isSpecialTextASCII[ch] = false; - } - else { - isCleanTextASCII[ch] = false; - isSpecialTextASCII[ch] = true; - } - - - onlyQuotAmpLtGt = noExtraEntities; - // initialize the array with a cache of the BitSet values - for (int i=0; i<ASCII_MAX; i++) - isSpecialAttrASCII[i] = get(i); - /* Now that we've used get(ch) just above to initialize the * two arrays we will change by adding a tab to the set of * special chars for XML (but not HTML!). @@ -344,8 +330,19 @@ */ if (Method.XML.equals(method)) { - isSpecialAttrASCII[S_HORIZONAL_TAB] = true; + // We choose not to escape the quotation mark as " in text nodes + shouldMapTextChar_ASCII[S_QUOTE] = false; } + + if (Method.HTML.equals(method)) { + // The XSLT 1.0 recommendation says + // "The html output method should not escape < characters occurring in attribute values." + // So we don't escape '<' in an attribute for HTML + shouldMapAttrChar_ASCII['<'] = false; + + // We choose not to escape the quotation mark as " in text nodes. + shouldMapTextChar_ASCII[S_QUOTE] = false; + } } /** @@ -353,23 +350,39 @@ * supplied. Nothing happens if the character reference is already defined. * <p>Unlike internal entities, character references are a string to single * character mapping. They are used to map non-ASCII characters both on - * parsing and printing, primarily for HTML documents. '<amp;' is an + * parsing and printing, primarily for HTML documents. '&lt;' is an * example of a character reference.</p> * * @param name The entity's name * @param value The entity's value + * @return true if the mapping is not one of: + * <ul> + * <li> '<' to "<" + * <li> '>' to ">" + * <li> '&' to "&" + * <li> '"' to """ + * </ul> */ - private void defineEntity(String name, char value) + private boolean defineEntity(String name, char value) { StringBuilder sb = new StringBuilder("&"); sb.append(name); sb.append(';'); String entityString = sb.toString(); - defineChar2StringMapping(entityString, value); + boolean extra = defineChar2StringMapping(entityString, value); + return extra; } /** + * A utility object, just used to map characters to output Strings, + * needed because a HashMap needs to map an object as a key, not a + * Java primitive type, like a char, so this object gets around that + * and it is reusable. + */ + private final CharKey m_charKey; + + /** * Map a character to a String. For example given * the character '>' this method would return the fully decorated * entity name "<". @@ -400,21 +413,21 @@ /** * Tell if the character argument that is from - * an attribute value should have special treatment. + * an attribute value has a mapping to a String. * * @param value the value of a character that is in an attribute value * @return true if the character should have any special treatment, * such as when writing out attribute values, - * or entity references. + * such as when writing out entity references. * @xsl.usage internal */ - final boolean isSpecialAttrChar(int value) + final boolean shouldMapAttrChar(int value) { // for performance try the values in the boolean array first, // this is faster access than the BitSet for common ASCII values if (value < ASCII_MAX) - return isSpecialAttrASCII[value]; + return shouldMapAttrChar_ASCII[value]; // rather than java.util.BitSet, our private // implementation is faster (and less general). @@ -423,48 +436,27 @@ /** * Tell if the character argument that is from a - * text node should have special treatment. + * text node has a mapping to a String, for example + * to map '<' to "<". * * @param value the value of a character that is in a text node - * @return true if the character should have any special treatment, - * such as when writing out attribute values, - * or entity references. + * @return true if the character has a mapping to a String, + * such as when writing out entity references. * @xsl.usage internal */ - final boolean isSpecialTextChar(int value) + final boolean shouldMapTextChar(int value) { // for performance try the values in the boolean array first, // this is faster access than the BitSet for common ASCII values if (value < ASCII_MAX) - return isSpecialTextASCII[value]; + return shouldMapTextChar_ASCII[value]; // rather than java.util.BitSet, our private // implementation is faster (and less general). return get(value); } - /** - * This method is used to determine if an ASCII character in - * a text node (not an attribute value) is "clean". - * @param value the character to check (0 to 127). - * @return true if the character can go to the writer as-is - * @xsl.usage internal - */ - final boolean isTextASCIIClean(int value) - { - return isCleanTextASCII[value]; - } - -// In the future one might want to use the array directly and avoid -// the method call, but I think the JIT alreay inlines this well enough -// so don't do it (for now) - bjm -// public final boolean[] getASCIIClean() -// { -// return isCleanTextASCII; -// } - - private static CharInfo getCharInfoBasedOnPrivilege( final String entitiesFileName, final String method, final boolean internal){ @@ -499,15 +491,17 @@ { CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName); if (charInfo != null) { - return charInfo; + return mutableCopyOf(charInfo); } // try to load it internally - cache try { charInfo = getCharInfoBasedOnPrivilege(entitiesFileName, method, true); + // Put the common copy of charInfo in the cache, but return + // a copy of it. m_getCharInfoCache.put(entitiesFileName, charInfo); - return charInfo; + return mutableCopyOf(charInfo); } catch (Exception e) {} // try to load it externally - do not cache @@ -534,7 +528,41 @@ method, false); } - /** Table of user-specified char infos. */ + /** + * Create a mutable copy of the cached one. + * @param charInfo The cached one. + * @return + */ + private static CharInfo mutableCopyOf(CharInfo charInfo) { + CharInfo copy = new CharInfo(); + + int max = charInfo.array_of_bits.length; + System.arraycopy(charInfo.array_of_bits,0,copy.array_of_bits,0,max); + + copy.firstWordNotUsed = charInfo.firstWordNotUsed; + + max = charInfo.shouldMapAttrChar_ASCII.length; + System.arraycopy(charInfo.shouldMapAttrChar_ASCII,0,copy.shouldMapAttrChar_ASCII,0,max); + + max = charInfo.shouldMapTextChar_ASCII.length; + System.arraycopy(charInfo.shouldMapTextChar_ASCII,0,copy.shouldMapTextChar_ASCII,0,max); + + // utility field copy.m_charKey is already created in the default constructor + + copy.m_charToString = (HashMap) charInfo.m_charToString.clone(); + + copy.onlyQuotAmpLtGt = charInfo.onlyQuotAmpLtGt; + + return copy; + } + + /** + * Table of user-specified char infos. + * The table maps entify file names (the name of the + * property file without the .properties extension) + * to CharInfo objects populated with entities defined in + * corresponding property file. + */ private static HashMap m_getCharInfoCache = new HashMap(); /** @@ -576,7 +604,8 @@ * the creation of the set. */ private final void set(int i) { - setASCIIdirty(i); + setASCIItextDirty(i); + setASCIIattrDirty(i); int j = (i >> SHIFT_PER_WORD); // this word is used int k = j + 1; @@ -611,24 +640,43 @@ return in_the_set; } - // record if there are any entities other than - // quot, amp, lt, gt (probably user defined) /** - * @return true if the entity - * @param code The value of the character that has an entity defined - * for it. + * This method returns true if there are some non-standard mappings to + * entities other than quot, amp, lt, gt, and its only purpose is for + * performance. + * @param charToMap The value of the character that is mapped to a String + * @param outputString The String to which the character is mapped, usually + * an entity reference such as "<". + * @return true if the mapping is not one of: + * <ul> + * <li> '<' to "<" + * <li> '>' to ">" + * <li> '&' to "&" + * <li> '"' to """ + * </ul> */ - private boolean extraEntity(int entityValue) + private boolean extraEntity(String outputString, int charToMap) { boolean extra = false; - if (entityValue < 128) + if (charToMap < ASCII_MAX) { - switch (entityValue) + switch (charToMap) { - case 34 : // quot - case 38 : // amp - case 60 : // lt - case 62 : // gt + case '"' : // quot + if (!outputString.equals(""")) + extra = true; + break; + case '&' : // amp + if (!outputString.equals("&")) + extra = true; + break; + case '<' : // lt + if (!outputString.equals("<")) + extra = true; + break; + case '>' : // gt + if (!outputString.equals(">")) + extra = true; break; default : // other entity in range 0 to 127 extra = true; @@ -638,49 +686,61 @@ } /** - * If the character is a printable ASCII character then - * mark it as not clean and needing replacement with - * a String on output. + * If the character is in the ASCII range then + * mark it as needing replacement with + * a String on output if it occurs in a text node. * @param ch */ - private void setASCIIdirty(int j) + private void setASCIItextDirty(int j) { if (0 <= j && j < ASCII_MAX) { - isCleanTextASCII[j] = false; - isSpecialTextASCII[j] = true; + shouldMapTextChar_ASCII[j] = true; } } /** - * If the character is a printable ASCII character then - * mark it as and not needing replacement with - * a String on output. + * If the character is in the ASCII range then + * mark it as needing replacement with + * a String on output if it occurs in a attribute value. * @param ch */ - private void setASCIIclean(int j) + private void setASCIIattrDirty(int j) { if (0 <= j && j < ASCII_MAX) { - isCleanTextASCII[j] = true; - isSpecialTextASCII[j] = false; + shouldMapAttrChar_ASCII[j] = true; } } - private void defineChar2StringMapping(String outputString, char inputChar) + /** + * Call this method to register a char to String mapping, for example + * to map '<' to "<". + * @param outputString The String to map to. + * @param inputChar The char to map from. + * @return true if the mapping is not one of: + * <ul> + * <li> '<' to "<" + * <li> '>' to ">" + * <li> '&' to "&" + * <li> '"' to """ + * </ul> + */ + boolean defineChar2StringMapping(String outputString, char inputChar) { CharKey character = new CharKey(inputChar); m_charToString.put(character, outputString); - set(inputChar); + set(inputChar); // mark the character has having a mapping to a String + + boolean extraMapping = extraEntity(outputString, inputChar); + return extraMapping; + } /** * Simple class for fast lookup of char values, when used with * hashtables. You can set the char, then use it as a key. * - * This class is a copy of the one in com.sun.org.apache.xml.internal.utils. - * It exists to cut the serializers dependancy on that package. - * * @xsl.usage internal */ private static class CharKey extends Object
--- a/src/com/sun/org/apache/xml/internal/serializer/ToHTMLSAXHandler.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToHTMLSAXHandler.java Thu Feb 02 13:30:54 2012 -0800 @@ -56,7 +56,7 @@ /** * Keeps track of whether output escaping is currently enabled */ - protected boolean m_escapeSetting = false; + protected boolean m_escapeSetting = true; /** * Returns null. @@ -742,6 +742,6 @@ */ private void resetToHTMLSAXHandler() { - this.m_escapeSetting = false; + this.m_escapeSetting = true; } }
--- a/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java Thu Feb 02 13:30:54 2012 -0800 @@ -58,7 +58,7 @@ * Map that tells which XML characters should have special treatment, and it * provides character to entity name lookup. */ - private static final CharInfo m_htmlcharInfo = + private final CharInfo m_htmlcharInfo = // new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE); CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML); @@ -1369,7 +1369,7 @@ // System.out.println("ch: "+(int)ch); // System.out.println("m_maxCharacter: "+(int)m_maxCharacter); // System.out.println("m_attrCharsMap[ch]: "+(int)m_attrCharsMap[ch]); - if (escapingNotNeeded(ch) && (!m_charInfo.isSpecialAttrChar(ch))) + if (escapingNotNeeded(ch) && (!m_charInfo.shouldMapAttrChar(ch))) { cleanLength++; }
--- a/src/com/sun/org/apache/xml/internal/serializer/ToStream.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToStream.java Thu Feb 02 13:30:54 2012 -0800 @@ -919,7 +919,8 @@ { // This is the old/fast code here, but is this // correct for all encodings? - if (ch >= 0x20 || (0x0A == ch || 0x0D == ch || 0x09 == ch)) + if (ch >= CharInfo.S_SPACE || (CharInfo.S_LINEFEED == ch || + CharInfo.S_CARRIAGERETURN == ch || CharInfo.S_HORIZONAL_TAB == ch)) ret= true; else ret = false; @@ -1028,7 +1029,7 @@ * * @throws java.io.IOException */ - protected int accumDefaultEntity( + int accumDefaultEntity( java.io.Writer writer, char ch, int i, @@ -1047,7 +1048,7 @@ { // if this is text node character and a special one of those, // or if this is a character from attribute value and a special one of those - if ((fromTextNode && m_charInfo.isSpecialTextChar(ch)) || (!fromTextNode && m_charInfo.isSpecialAttrChar(ch))) + if ((fromTextNode && m_charInfo.shouldMapTextChar(ch)) || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch))) { String outputStringForChar = m_charInfo.getOutputStringForChar(ch); @@ -1398,7 +1399,6 @@ if (m_cdataTagOpen) closeCDATA(); - // the check with _escaping is a bit of a hack for XLSTC if (m_disableOutputEscapingStates.peekOrFalse() || (!m_escaping)) { @@ -1421,82 +1421,173 @@ try { int i; - char ch1; int startClean; // skip any leading whitspace // don't go off the end and use a hand inlined version // of isWhitespace(ch) final int end = start + length; - int lastDirty = start - 1; // last character that needed processing - for (i = start; - ((i < end) - && ((ch1 = chars[i]) == 0x20 - || (ch1 == 0xA && m_lineSepUse) - || ch1 == 0xD - || ch1 == 0x09)); - i++) - { - /* - * We are processing leading whitespace, but are doing the same - * processing for dirty characters here as for non-whitespace. - * - */ - if (!m_charInfo.isTextASCIIClean(ch1)) - { - lastDirty = processDirty(chars,end, i,ch1, lastDirty, true); - i = lastDirty; + int lastDirtyCharProcessed = start - 1; // last non-clean character that was processed + // that was processed + final Writer writer = m_writer; + boolean isAllWhitespace = true; + + // process any leading whitspace + i = start; + while (i < end && isAllWhitespace) { + char ch1 = chars[i]; + + if (m_charInfo.shouldMapTextChar(ch1)) { + // The character is supposed to be replaced by a String + // so write out the clean whitespace characters accumulated + // so far + // then the String. + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + String outputStringForChar = m_charInfo + .getOutputStringForChar(ch1); + writer.write(outputStringForChar); + // We can't say that everything we are writing out is + // all whitespace, we just wrote out a String. + isAllWhitespace = false; + lastDirtyCharProcessed = i; // mark the last non-clean + // character processed + i++; + } else { + // The character is clean, but is it a whitespace ? + switch (ch1) { + // TODO: Any other whitespace to consider? + case CharInfo.S_SPACE: + // Just accumulate the clean whitespace + i++; + break; + case CharInfo.S_LINEFEED: + lastDirtyCharProcessed = processLineFeed(chars, i, + lastDirtyCharProcessed, writer); + i++; + break; + case CharInfo.S_CARRIAGERETURN: + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + writer.write(" "); + lastDirtyCharProcessed = i; + i++; + break; + case CharInfo.S_HORIZONAL_TAB: + // Just accumulate the clean whitespace + i++; + break; + default: + // The character was clean, but not a whitespace + // so break the loop to continue with this character + // (we don't increment index i !!) + isAllWhitespace = false; + break; } } + } /* If there is some non-whitespace, mark that we may need * to preserve this. This is only important if we have indentation on. */ - if (i < end) + if (i < end || !isAllWhitespace) m_ispreserve = true; - -// int lengthClean; // number of clean characters in a row -// final boolean[] isAsciiClean = m_charInfo.getASCIIClean(); - - final boolean isXML10 = XMLVERSION10.equals(getVersion()); - // we've skipped the leading whitespace, now deal with the rest for (; i < end; i++) { - { - // A tight loop to skip over common clean chars - // This tight loop makes it easier for the JIT - // to optimize. - char ch2; - while (i<end - && ((ch2 = chars[i])<127) - && m_charInfo.isTextASCIIClean(ch2)) - i++; - if (i == end) - break; + char ch = chars[i]; + + if (m_charInfo.shouldMapTextChar(ch)) { + // The character is supposed to be replaced by a String + // e.g. '&' --> "&" + // e.g. '<' --> "<" + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + String outputStringForChar = m_charInfo.getOutputStringForChar(ch); + writer.write(outputStringForChar); + lastDirtyCharProcessed = i; } - - final char ch = chars[i]; - /* The check for isCharacterInC0orC1Ranger and - * isNELorLSEPCharacter has been added - * to support Control Characters in XML 1.1 - */ - if (!isCharacterInC0orC1Range(ch) && - (isXML10 || !isNELorLSEPCharacter(ch)) && - (escapingNotNeeded(ch) && (!m_charInfo.isSpecialTextChar(ch))) - || ('"' == ch)) - { - ; // a character needing no special processing + else { + if (ch <= 0x1F) { + // Range 0x00 through 0x1F inclusive + // + // This covers the non-whitespace control characters + // in the range 0x1 to 0x1F inclusive. + // It also covers the whitespace control characters in the same way: + // 0x9 TAB + // 0xA NEW LINE + // 0xD CARRIAGE RETURN + // + // We also cover 0x0 ... It isn't valid + // but we will output "�" + + // The default will handle this just fine, but this + // is a little performance boost to handle the more + // common TAB, NEW-LINE, CARRIAGE-RETURN + switch (ch) { + + case CharInfo.S_HORIZONAL_TAB: + // Leave whitespace TAB as a real character + break; + case CharInfo.S_LINEFEED: + lastDirtyCharProcessed = processLineFeed(chars, i, lastDirtyCharProcessed, writer); + break; + case CharInfo.S_CARRIAGERETURN: + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + writer.write(" "); + lastDirtyCharProcessed = i; + // Leave whitespace carriage return as a real character + break; + default: + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + writer.write("&#"); + writer.write(Integer.toString(ch)); + writer.write(';'); + lastDirtyCharProcessed = i; + break; + } - else - { - lastDirty = processDirty(chars,end, i, ch, lastDirty, true); - i = lastDirty; + } + else if (ch < 0x7F) { + // Range 0x20 through 0x7E inclusive + // Normal ASCII chars, do nothing, just add it to + // the clean characters + + } + else if (ch <= 0x9F){ + // Range 0x7F through 0x9F inclusive + // More control characters, including NEL (0x85) + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + writer.write("&#"); + writer.write(Integer.toString(ch)); + writer.write(';'); + lastDirtyCharProcessed = i; + } + else if (ch == CharInfo.S_LINE_SEPARATOR) { + // LINE SEPARATOR + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + writer.write("
"); + lastDirtyCharProcessed = i; + } + else if (m_encodingInfo.isInEncoding(ch)) { + // If the character is in the encoding, and + // not in the normal ASCII range, we also + // just leave it get added on to the clean characters + + } + else { + // This is a fallback plan, we should never get here + // but if the character wasn't previously handled + // (i.e. isn't in the encoding, etc.) then what + // should we do? We choose to write out an entity + writeOutCleanChars(chars, i, lastDirtyCharProcessed); + writer.write("&#"); + writer.write(Integer.toString(ch)); + writer.write(';'); + lastDirtyCharProcessed = i; + } } } // we've reached the end. Any clean characters at the // end of the array than need to be written out? - startClean = lastDirty + 1; + startClean = lastDirtyCharProcessed + 1; if (i > startClean) { int lengthClean = i - startClean; @@ -1515,6 +1606,32 @@ if (m_tracer != null) super.fireCharEvent(chars, start, length); } + + private int processLineFeed(final char[] chars, int i, int lastProcessed, final Writer writer) throws IOException { + if (!m_lineSepUse + || (m_lineSepLen ==1 && m_lineSep[0] == CharInfo.S_LINEFEED)){ + // We are leaving the new-line alone, and it is just + // being added to the 'clean' characters, + // so the last dirty character processed remains unchanged + } + else { + writeOutCleanChars(chars, i, lastProcessed); + writer.write(m_lineSep, 0, m_lineSepLen); + lastProcessed = i; + } + return lastProcessed; + } + + private void writeOutCleanChars(final char[] chars, int i, int lastProcessed) throws IOException { + int startClean; + startClean = lastProcessed + 1; + if (startClean < i) + { + int lengthClean = i - startClean; + m_writer.write(chars, startClean, lengthClean); + } + } + /** * This method checks if a given character is between C0 or C1 range * of Control characters. @@ -1634,7 +1751,7 @@ * * @throws org.xml.sax.SAXException */ - protected int accumDefaultEscape( + private int accumDefaultEscape( Writer writer, char ch, int i, @@ -1698,16 +1815,15 @@ * to write it out as Numeric Character Reference(NCR) regardless of XML Version * being used for output document. */ - if (isCharacterInC0orC1Range(ch) || - (XMLVERSION11.equals(getVersion()) && isNELorLSEPCharacter(ch))) + if (isCharacterInC0orC1Range(ch) || isNELorLSEPCharacter(ch)) { writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); } else if ((!escapingNotNeeded(ch) || - ( (fromTextNode && m_charInfo.isSpecialTextChar(ch)) - || (!fromTextNode && m_charInfo.isSpecialAttrChar(ch)))) + ( (fromTextNode && m_charInfo.shouldMapTextChar(ch)) + || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch)))) && m_elemContext.m_currentElemDepth > 0) { writer.write("&#"); @@ -1971,28 +2087,86 @@ string.getChars(0,len, m_attrBuff, 0); final char[] stringChars = m_attrBuff; - for (int i = 0; i < len; ) + for (int i = 0; i < len;) { char ch = stringChars[i]; - if (escapingNotNeeded(ch) && (!m_charInfo.isSpecialAttrChar(ch))) - { - writer.write(ch); - i++; - } - else - { // I guess the parser doesn't normalize cr/lf in attributes. -sb -// if ((CharInfo.S_CARRIAGERETURN == ch) -// && ((i + 1) < len) -// && (CharInfo.S_LINEFEED == stringChars[i + 1])) -// { -// i++; -// ch = CharInfo.S_LINEFEED; -// } - + + if (m_charInfo.shouldMapAttrChar(ch) || !(escapingNotNeeded(ch))) { + // The character is supposed to be replaced by a String + // e.g. '&' --> "&" + // e.g. '<' --> "<" i = accumDefaultEscape(writer, ch, i, stringChars, len, false, true); } + else { + i++; + if (0x0 <= ch && ch <= 0x1F) { + // Range 0x00 through 0x1F inclusive + // This covers the non-whitespace control characters + // in the range 0x1 to 0x1F inclusive. + // It also covers the whitespace control characters in the same way: + // 0x9 TAB + // 0xA NEW LINE + // 0xD CARRIAGE RETURN + // + // We also cover 0x0 ... It isn't valid + // but we will output "�" + + // The default will handle this just fine, but this + // is a little performance boost to handle the more + // common TAB, NEW-LINE, CARRIAGE-RETURN + switch (ch) { + + case CharInfo.S_HORIZONAL_TAB: + writer.write("	"); + break; + case CharInfo.S_LINEFEED: + writer.write(" "); + break; + case CharInfo.S_CARRIAGERETURN: + writer.write(" "); + break; + default: + writer.write("&#"); + writer.write(Integer.toString(ch)); + writer.write(';'); + break; + } - + } + else if (ch < 0x7F) { + // Range 0x20 through 0x7E inclusive + // Normal ASCII chars + writer.write(ch); + } + else if (ch <= 0x9F){ + // Range 0x7F through 0x9F inclusive + // More control characters + writer.write("&#"); + writer.write(Integer.toString(ch)); + writer.write(';'); + } + else if (ch == CharInfo.S_LINE_SEPARATOR) { + // LINE SEPARATOR + writer.write("
"); + } + else if (m_encodingInfo.isInEncoding(ch)) { + // If the character is in the encoding, and + // not in the normal ASCII range, we also + // just write it out + writer.write(ch); + } + else { + // This is a fallback plan, we should never get here + // but if the character wasn't previously handled + // (i.e. isn't in the encoding, etc.) then what + // should we do? We choose to write out a character ref + writer.write("&#"); + writer.write(Integer.toString(ch)); + writer.write(';'); + } + + } + } } /** @@ -2219,13 +2393,14 @@ try { - if (shouldIndent()) - indent(); - final int limit = start + length; boolean wasDash = false; if (m_cdataTagOpen) closeCDATA(); + + if (shouldIndent()) + indent(); + final java.io.Writer writer = m_writer; writer.write(COMMENT_BEGIN); // Detect occurrences of two consecutive dashes, handle as necessary. @@ -2258,6 +2433,15 @@ throw new SAXException(e); } + /* + * Don't write out any indentation whitespace now, + * because there may be non-whitespace text after this. + * + * Simply mark that at this point if we do decide + * to indent that we should + * add a newline on the end of the current line before + * the indentation at the start of the next line. + */ m_startNewLine = true; // time to generate comment event if (m_tracer != null) @@ -2506,7 +2690,7 @@ */ protected boolean shouldIndent() { - return m_doIndent && (!m_ispreserve && !m_isprevtext); + return m_doIndent && (!m_ispreserve && !m_isprevtext) && m_elemContext.m_currentElemDepth > 0; } /** @@ -2749,6 +2933,14 @@ closeCDATA(); m_cdataTagOpen = false; } + if (m_writer != null) { + try { + m_writer.flush(); + } + catch(IOException e) { + // what? me worry? + } + } } public void setContentHandler(ContentHandler ch)
--- a/src/com/sun/org/apache/xml/internal/serializer/ToXMLSAXHandler.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToXMLSAXHandler.java Thu Feb 02 13:30:54 2012 -0800 @@ -50,7 +50,7 @@ /** * Keeps track of whether output escaping is currently enabled */ - protected boolean m_escapeSetting = false; + protected boolean m_escapeSetting = true; public ToXMLSAXHandler() { @@ -772,7 +772,7 @@ */ private void resetToXMLSAXHandler() { - this.m_escapeSetting = false; + this.m_escapeSetting = true; } }
--- a/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Thu Feb 02 13:30:54 2012 -0800 @@ -56,7 +56,7 @@ * Map that tells which XML characters should have special treatment, and it * provides character to entity name lookup. */ - private static CharInfo m_xmlcharInfo = + private CharInfo m_xmlcharInfo = // new CharInfo(CharInfo.XML_ENTITIES_RESOURCE); CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XML); @@ -160,8 +160,22 @@ writer.write('\"'); writer.write(standalone); writer.write("?>"); - if (m_doIndent) - writer.write(m_lineSep, 0, m_lineSepLen); + if (m_doIndent) { + if (m_standaloneWasSpecified + || getDoctypePublic() != null + || getDoctypeSystem() != null) { + // We almost never put a newline after the XML + // header because this XML could be used as + // an extenal general parsed entity + // and we don't know the context into which it + // will be used in the future. Only when + // standalone, or a doctype system or public is + // specified are we free to insert a new line + // after the header. Is it even worth bothering + // in these rare cases? + writer.write(m_lineSep, 0, m_lineSepLen); + } + } } catch(IOException e) { @@ -312,12 +326,15 @@ writer.write('?'); writer.write('>'); - // Always output a newline char if not inside of an - // element. The whitespace is not significant in that - // case. - if (m_elemContext.m_currentElemDepth <= 0) - writer.write(m_lineSep, 0, m_lineSepLen); - + /* + * Don't write out any indentation whitespace now, + * because there may be non-whitespace text after this. + * + * Simply mark that at this point if we do decide + * to indent that we should + * add a newline on the end of the current line before + * the indentation at the start of the next line. + */ m_startNewLine = true; } catch(IOException e)
--- a/src/com/sun/org/apache/xml/internal/serializer/WriterToUTF8Buffered.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/WriterToUTF8Buffered.java Thu Feb 02 13:30:54 2012 -0800 @@ -204,10 +204,10 @@ */ int split = length/CHARS_MAX; final int chunks; - if (split > 1) + if (length % CHARS_MAX > 0) + chunks = split + 1; + else chunks = split; - else - chunks = 2; int end_chunk = start; for (int chunk = 1; chunk <= chunks; chunk++) { @@ -339,10 +339,10 @@ final int start = 0; int split = length/CHARS_MAX; final int chunks; - if (split > 1) + if (length % CHARS_MAX > 0) + chunks = split + 1; + else chunks = split; - else - chunks = 2; int end_chunk = 0; for (int chunk = 1; chunk <= chunks; chunk++) {
--- a/src/com/sun/org/apache/xml/internal/serializer/utils/URI.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/serializer/utils/URI.java Thu Feb 02 13:30:54 2012 -0800 @@ -502,7 +502,7 @@ // if we get to this point, we need to resolve relative path // RFC 2396 5.2 #6 - String path = new String(); + String path = ""; String basePath = p_base.getPath(); // 6a - get all but the last segment of the base URI path
--- a/src/com/sun/org/apache/xml/internal/utils/FastStringBuffer.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/utils/FastStringBuffer.java Thu Feb 02 13:30:54 2012 -0800 @@ -422,6 +422,7 @@ // We may have preallocated chunks. If so, all but last should // be at full size. + boolean lastchunk = (m_lastChunk + 1 == m_array.length); if (m_firstFree < m_chunkSize) // Simplified test single-character-fits chunk = m_array[m_lastChunk]; @@ -1135,7 +1136,8 @@ boolean processingLeadingWhitespace = ((edgeTreatmentFlags & SUPPRESS_LEADING_WS) != 0); boolean seenWhitespace = ((edgeTreatmentFlags & CARRY_WS) != 0); - + boolean suppressTrailingWhitespace = + ((edgeTreatmentFlags & SUPPRESS_TRAILING_WS) != 0); int currPos = start; int limit = start+length;
--- a/src/com/sun/org/apache/xml/internal/utils/ObjectPool.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/utils/ObjectPool.java Thu Feb 02 13:30:54 2012 -0800 @@ -22,7 +22,7 @@ */ package com.sun.org.apache.xml.internal.utils; -import java.util.Vector; +import java.util.ArrayList; import com.sun.org.apache.xml.internal.res.XMLErrorResources; import com.sun.org.apache.xml.internal.res.XMLMessages; @@ -41,9 +41,9 @@ * @serial */ private final Class objectType; - /** Vector of given objects this points to. + /** Stack of given objects this points to. * @serial */ - private final Vector freeStack; + private final ArrayList freeStack; /** * Constructor ObjectPool @@ -53,7 +53,7 @@ public ObjectPool(Class type) { objectType = type; - freeStack = new Vector(); + freeStack = new ArrayList(); } /** @@ -71,7 +71,7 @@ { throw new WrappedRuntimeException(cnfe); } - freeStack = new Vector(); + freeStack = new ArrayList(); } @@ -85,7 +85,7 @@ public ObjectPool(Class type, int size) { objectType = type; - freeStack = new Vector(size); + freeStack = new ArrayList(size); } /** @@ -95,7 +95,7 @@ public ObjectPool() { objectType = null; - freeStack = new Vector(); + freeStack = new ArrayList(); } /** @@ -112,10 +112,7 @@ { // Remove object from end of free pool. - Object result = freeStack.lastElement(); - - freeStack.setSize(freeStack.size() - 1); - + Object result = freeStack.remove(freeStack.size() - 1); return result; } @@ -150,10 +147,7 @@ { // Remove object from end of free pool. - Object result = freeStack.lastElement(); - - freeStack.setSize(freeStack.size() - 1); - + Object result = freeStack.remove(freeStack.size() - 1); return result; } } @@ -171,7 +165,7 @@ // Remove safety. -sb // if (objectType.isInstance(obj)) // { - freeStack.addElement(obj); + freeStack.add(obj); // } // else // {
--- a/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/utils/TreeWalker.java Thu Feb 02 13:30:54 2012 -0800 @@ -153,9 +153,25 @@ */ public void traverse(Node pos) throws org.xml.sax.SAXException { - this.m_contentHandler.startDocument(); + traverseFragment(pos); + + this.m_contentHandler.endDocument(); + } + + /** + * Perform a pre-order traversal non-recursive style. + * + * In contrast to the traverse() method this method will not issue + * startDocument() and endDocument() events to the SAX listener. + * + * @param pos Node in the tree where to start traversal + * + * @throws TransformerException + */ + public void traverseFragment(Node pos) throws org.xml.sax.SAXException + { Node top = pos; while (null != pos) @@ -191,7 +207,6 @@ pos = nextNode; } - this.m_contentHandler.endDocument(); } /**
--- a/src/com/sun/org/apache/xml/internal/utils/URI.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/utils/URI.java Thu Feb 02 13:30:54 2012 -0800 @@ -522,7 +522,7 @@ // if we get to this point, we need to resolve relative path // RFC 2396 5.2 #6 - String path = new String(); + String path = ""; String basePath = p_base.getPath(); // 6a - get all but the last segment of the base URI path
--- a/src/com/sun/org/apache/xml/internal/utils/XMLString.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/utils/XMLString.java Thu Feb 02 13:30:54 2012 -0800 @@ -127,7 +127,7 @@ /** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not - * <code>null</code> and is a <code>String</code> object that represents + * <code>null</code> and is an <code>XMLString</code> object that represents * the same sequence of characters as this object. * * @param anObject the object to compare this <code>String</code> @@ -139,6 +139,20 @@ */ public abstract boolean equals(XMLString anObject); + /** + * Compares this string to the specified <code>String</code>. + * The result is <code>true</code> if and only if the argument is not + * <code>null</code> and is a <code>String</code> object that represents + * the same sequence of characters as this object. + * + * @param anotherString the object to compare this <code>String</code> + * against. + * @return <code>true</code> if the <code>String</code>s are equal; + * <code>false</code> otherwise. + * @see java.lang.String#compareTo(java.lang.String) + * @see java.lang.String#equalsIgnoreCase(java.lang.String) + */ + public abstract boolean equals(String anotherString); /** * Compares this string to the specified object.
--- a/src/com/sun/org/apache/xml/internal/utils/XMLStringDefault.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xml/internal/utils/XMLStringDefault.java Thu Feb 02 13:30:54 2012 -0800 @@ -152,6 +152,22 @@ } } + /** + * Compares this string to the specified <code>String</code>. + * The result is <code>true</code> if and only if the argument is not + * <code>null</code> and is a <code>String</code> object that represents + * the same sequence of characters as this object. + * + * @param obj2 the object to compare this <code>String</code> against. + * @return <code>true</code> if the <code>String</code>s are equal; + * <code>false</code> otherwise. + * @see java.lang.String#compareTo(java.lang.String) + * @see java.lang.String#equalsIgnoreCase(java.lang.String) + */ + public boolean equals(String obj2) { + return m_str.equals(obj2); + } + /** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not
--- a/src/com/sun/org/apache/xpath/internal/axes/AxesWalker.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/AxesWalker.java Thu Feb 02 13:30:54 2012 -0800 @@ -427,7 +427,7 @@ return -1; } - walker.setPredicateCount(walker.getPredicateCount() - 1); + walker.setPredicateCount(m_predicateIndex); walker.setNextWalker(null); walker.setPrevWalker(null);
--- a/src/com/sun/org/apache/xpath/internal/axes/BasicTestIterator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/BasicTestIterator.java Thu Feb 02 13:30:54 2012 -0800 @@ -27,6 +27,7 @@ import com.sun.org.apache.xml.internal.dtm.DTMIterator; import com.sun.org.apache.xml.internal.utils.PrefixResolver; import com.sun.org.apache.xpath.internal.compiler.Compiler; +import com.sun.org.apache.xpath.internal.compiler.OpMap; /** * Base for iterators that handle predicates. Does the basic next @@ -76,7 +77,7 @@ { super(compiler, opPos, analysis, false); - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); int whatToShow = compiler.getWhatToShow(firstStepPos); if ((0 == (whatToShow
--- a/src/com/sun/org/apache/xpath/internal/axes/DescendantIterator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/DescendantIterator.java Thu Feb 02 13:30:54 2012 -0800 @@ -31,7 +31,9 @@ import com.sun.org.apache.xpath.internal.XPathContext; import com.sun.org.apache.xpath.internal.compiler.Compiler; import com.sun.org.apache.xpath.internal.compiler.OpCodes; +import com.sun.org.apache.xpath.internal.compiler.OpMap; import com.sun.org.apache.xpath.internal.patterns.NodeTest; +import org.w3c.dom.DOMException; /** * This class implements an optimized iterator for @@ -57,7 +59,7 @@ super(compiler, opPos, analysis, false); - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); int stepType = compiler.getOp(firstStepPos); boolean orSelf = (OpCodes.FROM_DESCENDANTS_OR_SELF == stepType);
--- a/src/com/sun/org/apache/xpath/internal/axes/IteratorPool.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/IteratorPool.java Thu Feb 02 13:30:54 2012 -0800 @@ -22,7 +22,7 @@ */ package com.sun.org.apache.xpath.internal.axes; -import java.util.Vector; +import java.util.ArrayList; import com.sun.org.apache.xml.internal.dtm.DTMIterator; import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException; @@ -31,17 +31,19 @@ * Pool of object of a given type to pick from to help memory usage * @xsl.usage internal */ -public class IteratorPool implements java.io.Serializable +public final class IteratorPool implements java.io.Serializable { static final long serialVersionUID = -460927331149566998L; - /** Type of objects in this pool. - * @serial */ + /** + * Type of objects in this pool. + */ private final DTMIterator m_orig; - /** Vector of given objects this points to. - * @serial */ - private final Vector m_freeStack; + /** + * Stack of given objects this points to. + */ + private final ArrayList m_freeStack; /** * Constructor IteratorPool @@ -51,7 +53,7 @@ public IteratorPool(DTMIterator original) { m_orig = original; - m_freeStack = new Vector(); + m_freeStack = new ArrayList(); } /** @@ -72,10 +74,7 @@ else { // Remove object from end of free pool. - DTMIterator result = (DTMIterator)m_freeStack.lastElement(); - - m_freeStack.setSize(m_freeStack.size() - 1); - + DTMIterator result = (DTMIterator)m_freeStack.remove(m_freeStack.size() - 1); return result; } } @@ -104,10 +103,7 @@ else { // Remove object from end of free pool. - DTMIterator result = (DTMIterator)m_freeStack.lastElement(); - - m_freeStack.setSize(m_freeStack.size() - 1); - + DTMIterator result = (DTMIterator)m_freeStack.remove(m_freeStack.size() - 1); return result; } } @@ -120,6 +116,6 @@ */ public synchronized void freeInstance(DTMIterator obj) { - m_freeStack.addElement(obj); + m_freeStack.add(obj); } }
--- a/src/com/sun/org/apache/xpath/internal/axes/MatchPatternIterator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/MatchPatternIterator.java Thu Feb 02 13:30:54 2012 -0800 @@ -28,6 +28,7 @@ import com.sun.org.apache.xml.internal.dtm.DTMIterator; import com.sun.org.apache.xpath.internal.XPathContext; import com.sun.org.apache.xpath.internal.compiler.Compiler; +import com.sun.org.apache.xpath.internal.compiler.OpMap; import com.sun.org.apache.xpath.internal.objects.XObject; import com.sun.org.apache.xpath.internal.patterns.NodeTest; import com.sun.org.apache.xpath.internal.patterns.StepPattern; @@ -78,7 +79,7 @@ super(compiler, opPos, analysis, false); - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);
--- a/src/com/sun/org/apache/xpath/internal/axes/OneStepIterator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/OneStepIterator.java Thu Feb 02 13:30:54 2012 -0800 @@ -29,6 +29,7 @@ import com.sun.org.apache.xpath.internal.Expression; import com.sun.org.apache.xpath.internal.XPathContext; import com.sun.org.apache.xpath.internal.compiler.Compiler; +import com.sun.org.apache.xpath.internal.compiler.OpMap; /** * This class implements a general iterator for @@ -58,7 +59,7 @@ throws javax.xml.transform.TransformerException { super(compiler, opPos, analysis); - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);
--- a/src/com/sun/org/apache/xpath/internal/axes/OneStepIteratorForward.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/OneStepIteratorForward.java Thu Feb 02 13:30:54 2012 -0800 @@ -26,6 +26,7 @@ import com.sun.org.apache.xml.internal.dtm.DTMFilter; import com.sun.org.apache.xpath.internal.Expression; import com.sun.org.apache.xpath.internal.compiler.Compiler; +import com.sun.org.apache.xpath.internal.compiler.OpMap; /** * This class implements a general iterator for @@ -54,7 +55,7 @@ throws javax.xml.transform.TransformerException { super(compiler, opPos, analysis); - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);
--- a/src/com/sun/org/apache/xpath/internal/axes/SelfIteratorNoPredicate.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/SelfIteratorNoPredicate.java Thu Feb 02 13:30:54 2012 -0800 @@ -78,6 +78,7 @@ return DTM.NULL; int next; + DTM dtm = m_cdtm; m_lastFetched = next = (DTM.NULL == m_lastFetched) ? m_context
--- a/src/com/sun/org/apache/xpath/internal/axes/UnionPathIterator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/UnionPathIterator.java Thu Feb 02 13:30:54 2012 -0800 @@ -30,6 +30,7 @@ import com.sun.org.apache.xpath.internal.XPathVisitor; import com.sun.org.apache.xpath.internal.compiler.Compiler; import com.sun.org.apache.xpath.internal.compiler.OpCodes; +import com.sun.org.apache.xpath.internal.compiler.OpMap; /** * This class extends NodeSetDTM, which implements DTMIterator, @@ -160,7 +161,7 @@ super(); - opPos = compiler.getFirstChildPos(opPos); + opPos = OpMap.getFirstChildPos(opPos); loadLocationPaths(compiler, opPos, 0); }
--- a/src/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/WalkerFactory.java Thu Feb 02 13:30:54 2012 -0800 @@ -30,6 +30,7 @@ import com.sun.org.apache.xpath.internal.compiler.Compiler; import com.sun.org.apache.xpath.internal.compiler.FunctionTable; import com.sun.org.apache.xpath.internal.compiler.OpCodes; +import com.sun.org.apache.xpath.internal.compiler.OpMap; import com.sun.org.apache.xpath.internal.objects.XNumber; import com.sun.org.apache.xpath.internal.patterns.ContextMatchStepPattern; import com.sun.org.apache.xpath.internal.patterns.FunctionPattern; @@ -162,7 +163,7 @@ throws javax.xml.transform.TransformerException { - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); int analysis = analyze(compiler, firstStepPos, 0); boolean isOneStep = isOneStep(analysis); DTMIterator iter; @@ -402,7 +403,7 @@ int opPos) { int endFunc = opPos + compiler.getOp(opPos + 1) - 1; - opPos = compiler.getFirstChildPos(opPos); + opPos = OpMap.getFirstChildPos(opPos); int funcID = compiler.getOp(opPos); // System.out.println("funcID: "+funcID); // System.out.println("opPos: "+opPos); @@ -453,7 +454,7 @@ case OpCodes.OP_LT: case OpCodes.OP_LTE: case OpCodes.OP_EQUALS: - int leftPos = compiler.getFirstChildPos(op); + int leftPos = OpMap.getFirstChildPos(op); int rightPos = compiler.getNextOpPos(leftPos); isProx = isProximateInnerExpr(compiler, leftPos); if(isProx) @@ -521,7 +522,7 @@ case OpCodes.OP_LT: case OpCodes.OP_LTE: case OpCodes.OP_EQUALS: - int leftPos = compiler.getFirstChildPos(innerExprOpPos); + int leftPos = OpMap.getFirstChildPos(innerExprOpPos); int rightPos = compiler.getNextOpPos(leftPos); isProx = isProximateInnerExpr(compiler, leftPos); if(isProx) @@ -984,9 +985,7 @@ int stepType = compiler.getOp(opPos); boolean simpleInit = false; - int totalNumberWalkers = (analysis & BITS_COUNT); boolean prevIsOneStepDown = true; - int firstStepPos = compiler.getFirstChildPos(opPos); int whatToShow = compiler.getWhatToShow(opPos); StepPattern ai = null; @@ -1286,7 +1285,7 @@ public static String getAnalysisString(int analysis) { StringBuffer buf = new StringBuffer(); - buf.append("count: "+getStepCount(analysis)+" "); + buf.append("count: ").append(getStepCount(analysis)).append(' '); if((analysis & BIT_NODETEST_ANY) != 0) { buf.append("NTANY|");
--- a/src/com/sun/org/apache/xpath/internal/axes/WalkingIterator.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/axes/WalkingIterator.java Thu Feb 02 13:30:54 2012 -0800 @@ -29,6 +29,7 @@ import com.sun.org.apache.xpath.internal.VariableStack; import com.sun.org.apache.xpath.internal.XPathVisitor; import com.sun.org.apache.xpath.internal.compiler.Compiler; +import com.sun.org.apache.xpath.internal.compiler.OpMap; /** * Location path iterator that uses Walkers. @@ -58,7 +59,7 @@ { super(compiler, opPos, analysis, shouldLoadWalkers); - int firstStepPos = compiler.getFirstChildPos(opPos); + int firstStepPos = OpMap.getFirstChildPos(opPos); if (shouldLoadWalkers) {
--- a/src/com/sun/org/apache/xpath/internal/compiler/OpMap.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/compiler/OpMap.java Thu Feb 02 13:30:54 2012 -0800 @@ -242,7 +242,7 @@ else { throw new RuntimeException( - XSLMessages.createXPATHMessage(XPATHErrorResources.ER_UNKNOWN_STEP, new Object[]{new Integer(stepType).toString()})); + XSLMessages.createXPATHMessage(XPATHErrorResources.ER_UNKNOWN_STEP, new Object[]{String.valueOf(stepType)})); //"Programmer's assertion in getNextStepPos: unknown stepType: " + stepType); } }
--- a/src/com/sun/org/apache/xpath/internal/objects/XString.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/objects/XString.java Thu Feb 02 13:30:54 2012 -0800 @@ -321,6 +321,22 @@ return xstr().equals(obj2.xstr()); } + /** + * Compares this string to the specified <code>String</code>. + * The result is <code>true</code> if and only if the argument is not + * <code>null</code> and is a <code>String</code> object that represents + * the same sequence of characters as this object. + * + * @param obj2 the object to compare this <code>String</code> against. + * @return <code>true</code> if the <code>String</code>s are equal; + * <code>false</code> otherwise. + * @see java.lang.String#compareTo(java.lang.String) + * @see java.lang.String#equalsIgnoreCase(java.lang.String) + */ + public boolean equals(String obj2) { + return str().equals(obj2); + } + /** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not @@ -336,11 +352,14 @@ */ public boolean equals(XMLString obj2) { - - if (!obj2.hasString()) - return obj2.equals(this); - else - return str().equals(obj2.toString()); + if (obj2 != null) { + if (!obj2.hasString()) { + return obj2.equals(str()); + } else { + return str().equals(obj2.toString()); + } + } + return false; } /**
--- a/src/com/sun/org/apache/xpath/internal/objects/XStringForFSB.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/objects/XStringForFSB.java Thu Feb 02 13:30:54 2012 -0800 @@ -979,7 +979,7 @@ return Double.NaN; try { - return new Double(valueString).doubleValue(); + return Double.parseDouble(valueString); } catch (NumberFormatException nfe) { // This should catch double periods, empty strings. return Double.NaN;
--- a/src/com/sun/org/apache/xpath/internal/patterns/StepPattern.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/org/apache/xpath/internal/patterns/StepPattern.java Thu Feb 02 13:30:54 2012 -0800 @@ -857,7 +857,7 @@ } else { - buf.append("?" + Integer.toHexString(pat.m_whatToShow)); + buf.append('?').append(Integer.toHexString(pat.m_whatToShow)); } if (null != pat.m_predicates)
--- a/src/com/sun/xml/internal/stream/XMLEntityStorage.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/xml/internal/stream/XMLEntityStorage.java Thu Feb 02 13:30:54 2012 -0800 @@ -36,6 +36,7 @@ import com.sun.org.apache.xerces.internal.impl.PropertyManager; import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; import com.sun.org.apache.xerces.internal.impl.Constants; +import java.util.Enumeration; /** * @@ -129,19 +130,27 @@ } // reset(XMLComponentManager) /** - * Returns the hashtable of declared entities. - * <p> - * <strong>REVISIT:</strong> - * This should be done the "right" way by designing a better way to - * enumerate the declared entities. For now, this method is needed - * by the constructor that takes an XMLEntityManager parameter. - * XXX Making this method public, return all the declared entities. - * @return Hashtable hastable containing all the declared entities. + * Returns entity declaration. + * + * @param name The name of the entity. + * + * @see SymbolTable */ - public Hashtable getDeclaredEntities() { - return fEntities; - } // getDeclaredEntities():Hashtable + public Entity getEntity(String name) { + return (Entity)fEntities.get(name); + } // getEntity(String) + + public boolean hasEntities() { + return (fEntities!=null); + } // getEntity(String) + public int getEntitySize() { + return fEntities.size(); + } // getEntity(String) + + public Enumeration getEntityKeys() { + return fEntities.keys(); + } /** * Adds an internal entity declaration. * <p>
--- a/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/com/sun/xml/internal/stream/writers/XMLStreamWriterImpl.java Thu Feb 02 13:30:54 2012 -0800 @@ -384,6 +384,8 @@ fElementStack.clear(); fInternalNamespaceContext.reset(); fReuse = true; + fStartTagOpened = false; + fNamespaceContext.userContext = null; } /**
--- a/src/javax/xml/parsers/FactoryFinder.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/javax/xml/parsers/FactoryFinder.java Thu Feb 02 13:30:54 2012 -0800 @@ -25,15 +25,12 @@ package javax.xml.parsers; +import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.net.URL; +import java.util.Properties; /** * <p>Implements pluggable Datatypes.</p> @@ -42,6 +39,7 @@ * sync. It is package private for secure class loading.</p> * * @author Santiago.PericasGeertsen@sun.com + * @author Huizhe.Wang@oracle.com */ class FactoryFinder { @@ -95,18 +93,24 @@ * If the class loader supplied is <code>null</code>, first try using the * context class loader followed by the current (i.e. bootstrap) class * loader. + * + * Use bootstrap classLoader if cl = null and useBSClsLoader is true */ static private Class getProviderClass(String className, ClassLoader cl, - boolean doFallback) throws ClassNotFoundException + boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException { try { if (cl == null) { - cl = ss.getContextClassLoader(); - if (cl == null) { - throw new ClassNotFoundException(); - } - else { - return cl.loadClass(className); + if (useBSClsLoader) { + return Class.forName(className, true, FactoryFinder.class.getClassLoader()); + } else { + cl = ss.getContextClassLoader(); + if (cl == null) { + throw new ClassNotFoundException(); + } + else { + return cl.loadClass(className); + } } } else { @@ -131,8 +135,8 @@ * @param className Name of the concrete class corresponding to the * service provider * - * @param cl ClassLoader to use to load the class, null means to use - * the bootstrap ClassLoader + * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code> + * current <code>Thread</code>'s context classLoader is used to load the factory class. * * @param doFallback True if the current ClassLoader should be tried as * a fallback if the class is not found using cl @@ -140,8 +144,30 @@ static Object newInstance(String className, ClassLoader cl, boolean doFallback) throws ConfigurationError { + return newInstance(className, cl, doFallback, false); + } + + /** + * Create an instance of a class. Delegates to method + * <code>getProviderClass()</code> in order to load the class. + * + * @param className Name of the concrete class corresponding to the + * service provider + * + * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code> + * current <code>Thread</code>'s context classLoader is used to load the factory class. + * + * @param doFallback True if the current ClassLoader should be tried as + * a fallback if the class is not found using cl + * + * @param useBSClsLoader True if cl=null actually meant bootstrap classLoader. This parameter + * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader. + */ + static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) + throws ConfigurationError + { try { - Class providerClass = getProviderClass(className, cl, doFallback); + Class providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader); Object instance = providerClass.newInstance(); if (debug) { // Extra check to avoid computing cl strings dPrint("created new instance of " + providerClass + @@ -244,6 +270,7 @@ // First try the Context ClassLoader ClassLoader cl = ss.getContextClassLoader(); + boolean useBSClsLoader = false; if (cl != null) { is = ss.getResourceAsStream(cl, serviceId); @@ -251,11 +278,13 @@ if (is == null) { cl = FactoryFinder.class.getClassLoader(); is = ss.getResourceAsStream(cl, serviceId); + useBSClsLoader = true; } } else { // No Context ClassLoader, try the current ClassLoader cl = FactoryFinder.class.getClassLoader(); is = ss.getResourceAsStream(cl, serviceId); + useBSClsLoader = true; } if (is == null) { @@ -293,7 +322,7 @@ // ClassLoader because we want to avoid the case where the // resource file was found using one ClassLoader and the // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false); + return newInstance(factoryClassName, cl, false, useBSClsLoader); } // No provider found
--- a/src/javax/xml/transform/FactoryFinder.java Fri Jan 27 08:49:27 2012 -0800 +++ b/src/javax/xml/transform/FactoryFinder.java Thu Feb 02 13:30:54 2012 -0800 @@ -25,16 +25,13 @@ package javax.xml.transform; +import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; - -import java.util.Properties; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Method; -import java.net.URL; +import java.util.Properties; /** * <p>Implements pluggable Datatypes.</p> @@ -43,6 +40,7 @@ * sync. It is package private for secure class loading.</p> * * @author Santiago.PericasGeertsen@sun.com + * @author Huizhe.Wang@oracle.com */ class FactoryFinder { @@ -96,18 +94,24 @@ * If the class loader supplied is <code>null</code>, first try using the * context class loader followed by the current (i.e. bootstrap) class * loader. + * + * Use bootstrap classLoader if cl = null and useBSClsLoader is true */ static private Class getProviderClass(String className, ClassLoader cl, - boolean doFallback) throws ClassNotFoundException + boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException { try { if (cl == null) { - cl = ss.getContextClassLoader(); - if (cl == null) { - throw new ClassNotFoundException(); - } - else { - return cl.loadClass(className); + if (useBSClsLoader) { + return Class.forName(className, true, FactoryFinder.class.getClassLoader()); + } else { + cl = ss.getContextClassLoader(); + if (cl == null) { + throw new ClassNotFoundException(); + } + else { + return cl.loadClass(className); + } } } else { @@ -132,8 +136,8 @@ * @param className Name of the concrete class corresponding to the * service provider * - * @param cl ClassLoader to use to load the class, null means to use - * the bootstrap ClassLoader + * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code> + * current <code>Thread</code>'s context classLoader is used to load the factory class. * * @param doFallback True if the current ClassLoader should be tried as * a fallback if the class is not found using cl @@ -141,13 +145,32 @@ static Object newInstance(String className, ClassLoader cl, boolean doFallback) throws ConfigurationError { - return newInstance(className, cl, doFallback, false); + return newInstance(className, cl, doFallback, false, false); } - static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useServicesMechanism) + + /** + * Create an instance of a class. Delegates to method + * <code>getProviderClass()</code> in order to load the class. + * + * @param className Name of the concrete class corresponding to the + * service provider + * + * @param cl <code>ClassLoader</code> used to load the factory class. If <code>null</code> + * current <code>Thread</code>'s context classLoader is used to load the factory class. + * + * @param doFallback True if the current ClassLoader should be tried as + * a fallback if the class is not found using cl + * + * @param useBSClsLoader True if cl=null actually meant bootstrap classLoader. This parameter + * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader. + * + * @param useServicesMechanism True use services mechanism + */ + static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader, boolean useServicesMechanism) throws ConfigurationError { try { - Class providerClass = getProviderClass(className, cl, doFallback); + Class providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader); Object instance = null; if (!useServicesMechanism) { instance = newInstanceNoServiceLoader(providerClass); @@ -215,7 +238,7 @@ String systemProp = ss.getSystemProperty(factoryId); if (systemProp != null) { dPrint("found system property, value=" + systemProp); - return newInstance(systemProp, null, true, true); + return newInstance(systemProp, null, true, false, true); } } catch (SecurityException se) { @@ -243,7 +266,7 @@ if (factoryClassName != null) { dPrint("found in $java.home/jaxp.properties, value=" + factoryClassName); - return newInstance(factoryClassName, null, true, true); + return newInstance(factoryClassName, null, true, false, true); } } catch (Exception ex) { @@ -261,7 +284,7 @@ } dPrint("loaded from fallback value: " + fallbackClassName); - return newInstance(fallbackClassName, null, true, true); + return newInstance(fallbackClassName, null, true, false, true); } /* @@ -277,6 +300,7 @@ // First try the Context ClassLoader ClassLoader cl = ss.getContextClassLoader(); + boolean useBSClsLoader = false; if (cl != null) { is = ss.getResourceAsStream(cl, serviceId); @@ -284,11 +308,13 @@ if (is == null) { cl = FactoryFinder.class.getClassLoader(); is = ss.getResourceAsStream(cl, serviceId); - } + useBSClsLoader = true; + } } else { // No Context ClassLoader, try the current ClassLoader cl = FactoryFinder.class.getClassLoader(); is = ss.getResourceAsStream(cl, serviceId); + useBSClsLoader = true; } if (is == null) { @@ -326,7 +352,7 @@ // ClassLoader because we want to avoid the case where the // resource file was found using one ClassLoader and the // provider class was instantiated using a different one. - return newInstance(factoryClassName, cl, false, true); + return newInstance(factoryClassName, cl, false, useBSClsLoader, true); } // No provider found