1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.jxpath.issues;
19
20 import static org.junit.jupiter.api.Assertions.assertNotNull;
21 import static org.junit.jupiter.api.Assertions.assertTrue;
22
23 import java.io.StringReader;
24 import java.util.List;
25
26 import javax.xml.parsers.DocumentBuilder;
27 import javax.xml.parsers.DocumentBuilderFactory;
28 import javax.xml.parsers.ParserConfigurationException;
29
30 import org.apache.commons.jxpath.AbstractJXPathTest;
31 import org.apache.commons.jxpath.JXPathContext;
32 import org.junit.jupiter.api.Test;
33 import org.w3c.dom.Document;
34 import org.xml.sax.InputSource;
35
36 public class JXPath113Test extends AbstractJXPathTest {
37
38 static class JAXP {
39
40 public static Document getDocument(final InputSource is) throws Exception {
41 final DocumentBuilder builder = getDocumentBuilder();
42 return builder.parse(is);
43 }
44
45 public static Document getDocument(final String xml) throws Exception {
46 return getDocument(new InputSource(new StringReader(xml)));
47 }
48
49 private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
50 final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
51 factory.setValidating(false);
52 factory.setNamespaceAware(true);
53 factory.setExpandEntityReferences(false);
54 return factory.newDocumentBuilder();
55 }
56 }
57
58 @Test
59 public void testIssue113() throws Exception {
60 final Document doc = JAXP.getDocument("<xml/>");
61 final JXPathContext context = JXPathContext.newContext(doc);
62 final List result = context.selectNodes("//following-sibling::node()");
63 assertNotNull(result);
64 assertTrue(result.isEmpty());
65 }
66 }