From: Owen, S. S. U. <sam...@sp...> - 2018-02-01 13:16:58
|
??Hi, I've come across what I believe is a bug when processing instructions are included. Here's a test case. Thanks, Sam import com.ximpleware.*; import org.junit.Assert; import org.junit.Test; public class PIBugTest { @Test public void getElementFragmentTooLongWhenPIAndCarrageReturn() throws XPathParseException, NavException, XPathEvalException, ParseException { String exampleXml = "<a>\n" + " <b>value</b>\n" + " hello\n" + " <?pi inst $pi#?>\n" + " <b>another value</b>\n" + "</a>\n"; VTDGen vg = new VTDGen(); vg.setDoc(exampleXml.getBytes()); vg.parse(false); VTDNav nav = vg.getNav(); AutoPilot autoPilot = new AutoPilot(nav); autoPilot.selectXPath("/a//b"); autoPilot.evalXPath(); long fragment = nav.getElementFragment(); IByteBuffer xml = nav.getXML(); int offset = (int) fragment; int len = (int) (fragment >>> 32); //Fix for weird bug with pi Assert.assertEquals(new String(xml.getBytes(), offset, len), "<b>value</b>"); } } ? DISCLAIMER: This e-mail is confidential and should not be used by anyone who is not the original intended recipient. If you have received this e-mail in error please inform the sender and delete it from your mailbox or any other storage mechanism. Springer-Verlag London Limited does not accept liability for any statements made which are clearly the sender's own and not expressly made on behalf of Springer-Verlag London Limited or one of their agents. Please note that Springer-Verlag London Limited and their agents and affiliates do not accept any responsibility for viruses or malware that may be contained in this e-mail or its attachments and it is your responsibility to scan the e-mail and attachments (if any). Springer-Verlag London Limited. Registered office: The Campus, 4 Crinan Street, London, N1 9XW. Registered Number: 01738860 England. |