Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.7.1
-
Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
-
None
-
Java 1.5
-
PatchAvailable
Description
If a java extension functions takes an org.w3c.dom.Node as an argument then it gets an org.apache.xml.dtm.ref.DTMNodeProxy object.
The "getTextContent" method of this object returns null if the node is an element node, although according to the java 1.5 documentation, the "getTextContent" method should return the "concatenation of the textContent attribute value of every child node".
This is the implementation:
public String getTextContent() throws DOMException {
return getNodeValue(); // overriden in some subclasses
}
Of course, "getNodeValue" returns null if the node is an element node, but I think this is not the way "getTextContent" should be implemented.
The following code can be used to reproduce this error:
XSLT:
<xsl:value-of select="src:myFunction(foo)"/>
XML:
<foo>Some Text</foo>
Java:
public static String myFunction(org.w3c.dom.Node n) {
String s = n.getTextContent();
// s should be "Some Text", but is actually null.
}