⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpathtestbase.java

📁 XML的解析、编译、查询等技术的JAVA源代码。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(3, context, "//processing-instruction()");            assertCountXPath(2, context, "//processing-instruction('cheese')");                Object result = assertCountXPath2(1, context, "//processing-instruction('toast')");                assertValueOfXPath("is tasty", result, "string()");            }            }    /* test evaluate() extension function    */    public void testid54032() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/evaluate.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(3, context, "evaluate('//jumps/*')");            assertCountXPath(1, context, "evaluate('//jumps/object/dog')");            assertCountXPath(0, context, "evaluate('//jumps/object')/evaluate");            assertCountXPath(1, context, "evaluate('//jumps/object')/dog");            assertCountXPath(1, context, "evaluate('//jumps/*')/dog");            assertCountXPath(1, context, "//metatest[ evaluate(@select) = . ]");        }    }    public void testid54082() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/numbers.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/numbers/set[1]", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(1, context, "*[-3 = .]");            assertValueOfXPath("true", context, "54 < *");            assertValueOfXPath("true", context, "55 <= *");            assertValueOfXPath("false", context, "69 < *");            assertValueOfXPath("true", context, "-2 > *");            assertValueOfXPath("true", context, "-3 >= *");            assertValueOfXPath("false", context, "-4 >= *");        }    }    /* TODO    This context should work, but needs a fixed version of saxpath to parse the right-hand side    of the greater-than expression.    <context select="/numbers/set[2]">      <valueOf select="1 &gt; nr/@value">false</valueOf>      <valueOf select="55 &gt; nr/@value">false</valueOf>      <valueOf select="55 &gt;= nr/@value">true</valueOf>      <valueOf select="1000000 &gt; nr/@value">true</valueOf>    </context>        */    /* test sibling axes     */    public void testid54145() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/axis.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/root", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(0, context, "preceding-sibling::*");        }    }    public void testid54156() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/axis.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/root/a/a.3", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(2, context, "preceding::*");        }    }    public void testid54168() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/axis.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/root/a/a.3", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(2, context, "preceding-sibling::*");        }    }    public void testid54180() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/axis.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertValueOfXPath("a.2", context, "name(/root/a/a.3/preceding-sibling::*[1])");            assertValueOfXPath("a.1", context, "name(/root/a/a.3/preceding-sibling::*[2])");        }    }    public void testid54197() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/axis.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertValueOfXPath("a.4", context, "name(/root/a/a.3/following-sibling::*[1])");            assertValueOfXPath("a.5", context, "name(/root/a/a.3/following-sibling::*[2])");        }    }    public void testid54219() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/web.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertValueOfXPath("snoop", context, "/web-app/servlet[1]/servlet-name");            assertValueOfXPath("snoop", context, "/web-app/servlet[1]/servlet-name/text()");            assertValueOfXPath("file", context, "/web-app/servlet[2]/servlet-name");            assertValueOfXPath("file", context, "/web-app/servlet[2]/servlet-name/text()");        }    }    public void testid54249() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/web.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/web-app/servlet[1]", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertValueOfXPath("snoop", context, "servlet-name");            assertValueOfXPath("snoop", context, "servlet-name/text()");        }    }    public void testid54266() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/web.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/web-app/servlet[2]/servlet-name", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(3, context, "preceding::*");        }    }    public void testid54278() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/web.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/web-app/servlet[2]/servlet-name", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            assertCountXPath(13, context, "following::*");        }    }    /* test name    */    public void testid54298() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/web.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();                Object result = assertCountXPath2(1, context, "*");                assertValueOfXPath("web-app", result, "name()");            /* NOTE that the child::node() tests only work if the              XML document does not comments or PIs            */            result = assertCountXPath2(1, context, "./*");                assertValueOfXPath("web-app", result, "name()");            result = assertCountXPath2(1, context, "child::*");                assertValueOfXPath("web-app", result, "name()");            result = assertCountXPath2(1, context, "/*");                assertValueOfXPath("web-app", result, "name()");            result = assertCountXPath2(1, context, "/child::node()");                assertValueOfXPath("web-app", result, "name(.)");            result = assertCountXPath2(1, context, "child::node()");                assertValueOfXPath("web-app", result, "name(.)");            /* empty names            */            assertValueOfXPath("", context, "name()");            assertValueOfXPath("", context, "name(.)");            assertValueOfXPath("", context, "name(parent::*)");            assertValueOfXPath("", context, "name(/)");            assertValueOfXPath("", context, "name(/.)");            assertValueOfXPath("", context, "name(/self::node())");            /* name of root elemet            */            assertValueOfXPath("web-app", context, "name(node())");            assertValueOfXPath("web-app", context, "name(/node())");            assertValueOfXPath("web-app", context, "name(/*)");            assertValueOfXPath("web-app", context, "name(/child::*)");            assertValueOfXPath("web-app", context, "name(/child::node())");            assertValueOfXPath("web-app", context, "name(/child::node())");            assertValueOfXPath("web-app", context, "name(child::node())");            assertValueOfXPath("web-app", context, "name(./*)");            assertValueOfXPath("web-app", context, "name(*)");        }    }    public void testid54467() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/web.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/*", nav);        log("Initial Context :: " + contextpath);        List list = contextpath.selectNodes(document);        Iterator iter = list.iterator();        while (iter.hasNext())        {            Object context = iter.next();            /* empty names            */            assertValueOfXPath("", context, "name(..)");            assertValueOfXPath("", context, "name(parent::node())");            assertValueOfXPath("", context, "name(parent::*)");            /* name of root elemet            */            assertValueOfXPath("web-app", context, "name()");            assertValueOfXPath("web-app", context, "name(.)");            assertValueOfXPath("web-app", context, "name(../*)");            assertValueOfXPath("web-app", context, "name(../child::node())");        }    }    /* test predicates    */    public void testid54522() throws JaxenException    {        Navigator nav = getNavigator();        String url = "xml/nitf.xml";        log("Document [" + url + "]");        Object document = nav.getDocument(url);        XPath contextpath = new BaseXPath("/nitf/head/docdata", nav);        log("Initial Context :: " + contextpath);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -