Code example for NamespaceContext

Methods: getPrefixes

0
    @SuppressWarnings("unchecked") 
    public void findsPrefixesByNamespace() throws Exception {
        final String namespace = "simple-short-namespace";
        final NamespaceContext ctx = new XPathContext(namespace, namespace);
        MatcherAssert.assertThat( 
            Lists.newArrayList(ctx.getPrefixes(namespace)),
            Matchers.allOf( 
                (Matcher) Matchers.iterableWithSize(2),
                Matchers.hasItem("ns1"), 
                Matchers.hasItem("ns2") 
            ) 
        ); 
    } 
 
    /** 
     * XPathContext can find default namespaces. 
     * @throws Exception If something goes wrong inside 
     */ 
    @Test
    public void findsDefaultNamespaces() throws Exception {