提交 4cffa7cc 编写于 作者: A aefimov

8081392: getNodeValue should return 'null' value for Element nodes

Reviewed-by: joehw
上级 78d5bf60
...@@ -26,8 +26,9 @@ import org.w3c.dom.Node; ...@@ -26,8 +26,9 @@ import org.w3c.dom.Node;
public class TestFunc { public class TestFunc {
public static String test(Node node) { public static String test(Node node) {
String s = node.getTextContent(); String textContent = node.getTextContent();
return s; String nodeValue = node.getNodeValue();
return textContent + ":" + nodeValue;
} }
} }
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
/** /**
* @test * @test
* @bug 8032908 * @bug 8032908 8081392
* @summary Test if Node.getTextContent() function correctly returns children * @summary Test if Node.getTextContent() function correctly returns children
* content * content and also check that Node.getNodeValue() returns null value for
* Element nodes
* @compile TestFunc.java XSLT.java * @compile TestFunc.java XSLT.java
* @run main/othervm XSLT * @run main/othervm XSLT
*/ */
...@@ -40,7 +41,7 @@ public class XSLT { ...@@ -40,7 +41,7 @@ public class XSLT {
static final String XMLTOTRANSFORM = "/in.xml"; static final String XMLTOTRANSFORM = "/in.xml";
static final String XSLTRANSFORMER = "/test.xsl"; static final String XSLTRANSFORMER = "/test.xsl";
static final String EXPECTEDRESULT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>ABCDEFG"; static final String EXPECTEDRESULT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>ABCDEFG:null";
public static void main(String[] args) throws TransformerException { public static void main(String[] args) throws TransformerException {
ByteArrayOutputStream resStream = new ByteArrayOutputStream(); ByteArrayOutputStream resStream = new ByteArrayOutputStream();
......
...@@ -27,6 +27,6 @@ public class DocumentExtFunc { ...@@ -27,6 +27,6 @@ public class DocumentExtFunc {
public static String test(NodeList list) { public static String test(NodeList list) {
Node node = list.item(0); Node node = list.item(0);
return "["+node.getNodeName() + ":" + node.getNodeValue()+"]"; return "[" + node.getNodeName() + ":" + node.getTextContent() + "]";
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册