XmlCursor.getTextValue returns concatenation of child text, comment, and 
processing instruction nodes
-----------------------------------------------------------------------------------------------------

                 Key: XMLBEANS-311
                 URL: https://issues.apache.org/jira/browse/XMLBEANS-311
             Project: XMLBeans
          Issue Type: Bug
          Components: Cursor
    Affects Versions: Version 2.2.1
         Environment: Microsoft Windows XP Professional Version 2002 (Service 
Pack 2)
Intel Pentium 4 CPU 3.00GHZ
            Reporter: Coram Bryant
            Priority: Minor


According to the XmlBeans javadocs, if the XmlCursor corresponds to an element 
then non-text content such as comments and processing instructions are ignored. 
 However, as the following test shows, this is not the case:

String xml = "<element><!--A Comment-->999<?PI A Processing 
Instruction?></element>";
XmlObject xo = XmlObject.Factory.parse(xml);
XmlCursor xc = xo.newCursor();
xc.toFirstChild();
System.out.println(xc.currentTokenType());  // Verify that we are positioned at 
the start of an element
System.out.println(xc.getTextValue());

This prints out:
START
A Comment 999A Processing Instruction

Analysis:
In this case, the call stack is as follows:
org.apache.xmlbeans.impl.store.Cursor.getTextValue 
org.apache.xmlbeans.impl.store.Cursor._getTextValue
org.apache.xmlbeans.impl.store.Locale.getTextValue

In this method, the text value is built up with the text of instances of Cur 
for which the isText method returns true.  I believe the 
org.apache.xmlbeans.impl.store.Cur.isText method should be as follows:

boolean isText ( ) { assert isPositioned(); return _pos > 0 && 
kindIsContainer(_xobj.kind()); }

This would exclude comments and processing instructions.

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to