All,

We have recently stumbled upon two (possibly related) issues involving
comments and processing instructions that appear to be bugs in XMLBeans.

The first involves the XmlCursor.getTextValue() method.  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 does not appear to be 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


This apparent bug becomes more critical when evaluating XPath expressions. 
It appears that the same value returned by getTextValue is that which is
passed on to the Saxon XPath engine for evaluating element values, as the
following test shows:

String xml = "<element><!--A Comment-->999<?PI A Processing
Instruction?></element>";
XmlObject xo = XmlObject.Factory.parse(xml);
xo.selectPath("/element = 3");

This code snippet causes a Saxon ValidationException, with the message:
Cannot convert string " A Comment 999A Processing Ins..." to a double


If these results are a side-effect of misunderstanding, then we would
greatly appreciate some insight.  Otherwise, we're not sure how to enter
them as bugs, other than to post on this forum.

Thanks,
Coram

-- 
View this message in context: 
http://www.nabble.com/XmlBeans-bugs-involving-comments-and-processing-instructions-tf3118340.html#a8638741
Sent from the Xml Beans - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to