# HG changeset patch # User aefimov # Date 1477317749 -10800 # Node ID ebab8d7547ac62f27d7064ff26f2d7fe7e4f11eb # Parent 21131f0ad36ad9cdab79dc46fce7e046b9a77e6a 8167179: Make XSL generated namespace prefixes local to transformation process Reviewed-by: joehw diff -r 21131f0ad36a -r ebab8d7547ac drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java Sat Feb 04 01:21:19 2017 -0800 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java Mon Oct 24 17:02:29 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -34,6 +34,7 @@ import com.sun.org.apache.bcel.internal.generic.GETSTATIC; import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE; import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; +import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC; import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; import com.sun.org.apache.bcel.internal.generic.ISTORE; import com.sun.org.apache.bcel.internal.generic.InstructionHandle; @@ -1225,6 +1226,10 @@ classGen.getConstantPool()); transf.addException("com.sun.org.apache.xalan.internal.xsltc.TransletException"); + // call resetPrefixIndex at the beginning of transform + final int check = cpg.addMethodref(BASIS_LIBRARY_CLASS, "resetPrefixIndex", "()V"); + il.append(new INVOKESTATIC(check)); + // Define and initialize current with the root node final LocalVariableGen current = transf.addLocalVariable("current", diff -r 21131f0ad36a -r ebab8d7547ac drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java --- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Sat Feb 04 01:21:19 2017 -0800 +++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Mon Oct 24 17:02:29 2016 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -47,6 +47,7 @@ import java.text.NumberFormat; import java.util.Locale; import java.util.ResourceBundle; +import java.util.concurrent.atomic.AtomicInteger; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.DOMException; import org.w3c.dom.Document; @@ -1467,16 +1468,25 @@ } /** - * This function is used in the execution of xsl:element + * These functions are used in the execution of xsl:element to generate + * and reset namespace prefix index local to current transformation process */ - private static int prefixIndex = 0; - public static String generatePrefix() { - synchronized (BasisLibrary.class) { - return ("ns" + prefixIndex++); - } + return ("ns" + threadLocalPrefixIndex.get().getAndIncrement()); + } + + public static void resetPrefixIndex() { + threadLocalPrefixIndex.get().set(0); } + private static final ThreadLocal threadLocalPrefixIndex = + new ThreadLocal() { + @Override + protected AtomicInteger initialValue() { + return new AtomicInteger(); + } + }; + public static final String RUN_TIME_INTERNAL_ERR = "RUN_TIME_INTERNAL_ERR"; public static final String RUN_TIME_COPY_ERR =