--- old/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBase.java 2015-01-19 14:58:11.282502687 +0300
+++ new/jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMDefaultBase.java 2015-01-19 14:58:11.222502688 +0300
@@ -937,17 +937,9 @@
// needs need extreme speed.
int whichDTMindex=nodeHandle>>>DTMManager.IDENT_DTM_NODE_BITS;
-
- // %REVIEW% Wish I didn't have to perform the pre-test, but
- // someone is apparently asking DTMs whether they contain nodes
- // which really don't belong to them. That's probably a bug
- // which should be fixed, but until it is:
- if(m_mgrDefault.m_dtms[whichDTMindex]!=this)
- return NULL;
- else
- return
- m_mgrDefault.m_dtm_offsets[whichDTMindex]
- | (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
+ return
+ m_mgrDefault.m_dtm_offsets[whichDTMindex]
+ | (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
}
int whichDTMid=m_dtmIdent.indexOf(nodeHandle & DTMManager.IDENT_DTM_DEFAULT);
--- /dev/null 2015-01-19 13:29:36.833508774 +0300
+++ new/jdk/test/javax/xml/jaxp/transform/8062518/ExtFunc.java 2015-01-19 14:58:11.550502682 +0300
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ExtFunc {
+
+ public static String test(NodeList list) {
+ Node node = list.item(0);
+ return node.getNodeName() + ":" + node.getNodeValue();
+ }
+}
--- /dev/null 2015-01-19 13:29:36.833508774 +0300
+++ new/jdk/test/javax/xml/jaxp/transform/8062518/TestExternalDocument.java 2015-01-19 14:58:11.890502676 +0300
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8062518
+ * @compile ExtFunc.java
+ * @run testng TestExternalDocument
+ * @summary Test that nodes from external documents can be accessed with xsl
+ * extension functions
+ */
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.testng.annotations.Test;
+
+public class TestExternalDocument {
+
+ final String xml = "Doc";
+ final String xsl = ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + ""
+ + "";
+
+ @Test
+ public void testAccessExternalDocument() throws Exception {
+
+ //Prepare sources for transormation
+ Source src = new StreamSource(new StringReader(xml));
+ Source xslsrc = new StreamSource(new StringReader(xsl));
+
+ //Create factory and transformer
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t = tf.newTransformer( xslsrc );
+ t.setErrorListener(tf.getErrorListener());
+
+ //Set URI Resolver to return the newly constructed xml
+ // stream source object from xml test string
+ t.setURIResolver(new URIResolver() {
+ @Override
+ public Source resolve(String href, String base)
+ throws TransformerException {
+ return new StreamSource(new StringReader(xml));
+ }
+ });
+
+ //Prepare output stream
+ StringWriter xmlResultString = new StringWriter();
+ StreamResult xmlResultStream = new StreamResult(xmlResultString);
+ //Transform the xml
+ t.transform(src, xmlResultStream);
+ //If the document can't be accessed and the bug is in place then
+ // reported exception will be thrown during transformation
+ System.out.println("Transformation result:"+xmlResultString.toString().trim());
+ }
+}