You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Christian Schröder <cs...@deriva.de> on 2008/11/29 13:24:07 UTC
getTextContent in Java extension function
Hi list,
I have written a java extension function that is used during this xslt
transformation:
<xsl:value-of select="src:myFunction(foo)"/>
"foo" is a node in my xml document:
<foo>Some Text</foo>
This is the function:
public static String myFunction(org.w3c.dom.Node n) {
String s = n.getTextContent();
// Some more stuff ...
}
According to the java 1.5 documentation, the "getTextContent" method
should return the "concatenation of the textContent attribute value of
every child node", i.e. in this case: "Some Text". However, the function
returns null.
The Node n is of type org.apache.xml.dtm.ref.DTMNodeProxy. This is the
code from the svn repository:
public String getTextContent() throws DOMException {
return getNodeValue(); // overriden in some subclasses
}
Of course, "getNodeValue" returns null for the "foo" node, but I think
this is not the way "getTextContent" should be implemented. Is this a
bug or do I miss anything?
Regards,
Christian
--
Deriva GmbH Tel.: +49 551 489500-42
Financial IT and Consulting Fax: +49 551 489500-91
Hans-Böckler-Straße 2 http://www.deriva.de
D-37079 Göttingen
Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer
Re: getTextContent in Java extension function
Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Christian.
Christian Schröder <cs...@deriva.de> wrote on 2008-11-29 07:24:07 AM:
> Of course, "getNodeValue" returns null for the "foo" node, but I think
> this is not the way "getTextContent" should be implemented. Is this a
> bug or do I miss anything?
It looks like a bug in the implementation of getTextContent. May I ask
you to open a bug report?
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro
XML Transformation & Query Development
IBM Canada Lab T/L 313-6044; Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com