service.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); service.setProperty(OutputKeys.INDENT, "no"); ResourceSet rs = service.query("let $doc := <doc><div id='1'><div id='2'/></div><div id='3'/></doc> " + "return $doc/div[1]/following-sibling::div"); assertEquals(1, rs.getSize()); assertXMLEqual("<div id='3'/>", rs.getResource(0).getContent().toString());
    public void testFollowingSiblingAxis() {        try {            XQueryService service =                    storeXMLStringAndGetQueryService("siblings.xml", siblings);            service.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");            service.setProperty(OutputKeys.INDENT, "no");            ResourceSet result = queryResource(service, "siblings.xml", "//a[following-sibling::*[1]/s = 'B']", 1);            assertXMLEqual("<a><s>Z</s><n>2</n></a>", result.getResource(0).getContent().toString());            result = queryResource(service, "siblings.xml", "//a[following-sibling::a[1]/s = 'B']", 1);            assertXMLEqual("<a><s>Z</s><n>2</n></a>", result.getResource(0).getContent().toString());            result = queryResource(service, "siblings.xml", "//a[following-sibling::*[2]/s = 'B']", 1);            assertXMLEqual("<a><s>A</s><n>1</n></a>", result.getResource(0).getContent().toString());            result = queryResource(service, "siblings.xml", "//a[following-sibling::a[2]/s = 'B']", 1);            assertXMLEqual("<a><s>A</s><n>1</n></a>", result.getResource(0).getContent().toString());                        queryResource(service, "siblings.xml", "(<a/>, <b/>, <c/>)/following-sibling::*", 0);        } catch (Exception e) {            fail(e.getMessage());        }    }