[ 
https://issues.apache.org/jira/browse/XALANJ-2473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12782744#action_12782744
 ] 

Henry Zongaro commented on XALANJ-2473:
---------------------------------------

Hi, Martin.  Your patch for this bug report looks correct.  However, I would 
recommend trying to delegate the implementation of getTextContent to the 
underlying DTM implementation instead of doing a recursive walk that ultimately 
gets the string value of each text or CData section node and concatenates them 
all together.  If the DTMNodeProxy wraps a node from a SAX2DTM instance, in 
particular, the implementation can take advantage of the FastStringBuffer that 
stores the character content of the SAX2DTM implementation.  (Take a look at 
SAX2DTM.getStringValue(int) to understand how that might be much faster.)

> DTMNodeProxy.getTextContent() does not return text content of child nodes
> -------------------------------------------------------------------------
>
>                 Key: XALANJ-2473
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2473
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in 
> Xalan projects.  Anybody can view the issue.) 
>          Components: DTM
>    Affects Versions: 2.7.1
>         Environment: Java 1.5
>            Reporter: Christian Schröder
>         Attachments: XALANJ-2473-getTextContent.patch, XALANJ_2473_Test1.java
>
>
> 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.
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org
For additional commands, e-mail: xalan-dev-h...@xml.apache.org

Reply via email to