query = "let $doc := <doc><a b='c' d='e'/></doc> " + "return $doc/a[$doc/a/@b or $doc/a/@d]"; result = queryResource(service, "numbers.xml", query, 1); assertXMLEqual("<a b=\"c\" d=\"e\"/>", result.getResource(0) .getContent().toString());
    public void testPredicates2() throws Exception {        String numbers =            "<test>"                + "<item id='1' type='alphanum'><price>5.6</price><stock>22</stock></item>"                + "<item id='2'><price>7.4</price><stock>43</stock></item>"                + "<item id='3'><price>18.4</price><stock>5</stock></item>"                + "<item id='4'><price>65.54</price><stock>16</stock></item>"                + "</test>";        try {            XQueryService service =                 storeXMLStringAndGetQueryService("numbers.xml", numbers);            service.setProperty(OutputKeys.INDENT, "no");                        String query = "let $t := <test>" + "<a> <s>A</s> 1 </a>"                    + "<a> <s>Z</s> 2 </a>" + "<a> <s>B</s> 3 </a>"                    + "<a> <s>Z</s> 4 </a>" + "<a> <s>C</s> 5 </a>"                    + "<a> <s>Z</s> 6 </a>" + "</test>"                    + "return $t//a[s='Z' and preceding-sibling::*[1]/s='B']";            ResourceSet result = queryResource(service, "numbers.xml", query, 1);            assertXMLEqual("<a><s>Z</s> 4 </a>", result.getResource(0)                    .getContent().toString());            query = "let $t := <test>" + "<a> <s>A</s> 1 </a>"                    + "<a> <s>Z</s> 2 </a>" + "<a> <s>B</s> 3 </a>"                    + "<a> <s>Z</s> 4 </a>" + "<a> <s>C</s> 5 </a>"                    + "<a> <s>Z</s> 6 </a>" + "</test>"                    + "return $t//a[s='Z' and ./preceding-sibling::*[1]/s='B']";            result = queryResource(service, "numbers.xml", query, 1);            assertXMLEqual("<a><s>Z</s> 4 </a>", result.getResource(0)                    .getContent().toString());                             query = "let $doc := <doc><rec n='1'><a>first</a><b>second</b></rec>" +            	"<rec n='2'><a>first</a><b>third</b></rec></doc> " +            	"return $doc//rec[fn:not(b = 'second') and (./a = 'first')]";            result = queryResource(service, "numbers.xml", query, 1);            assertXMLEqual("<rec n=\"2\"><a>first</a><b>third</b></rec>", result.getResource(0)                    .getContent().toString());                                     } catch (XMLDBException e) {            fail(e.getMessage());        }    }    