@Test
public void testNamespaceInScope() throws Exception {

    String xml = "<?xml version=\"1.0\"?><root " +
        "xmlns:a=\"http://aaa\" " +
        "xmlns:b=\"http://bbb\" " +
        "xmlns:c=\"http://ccc\" " +
        "xmlns:d=\"http://ddd\">" +
        "<a:a/></root>";
    Element xmle = Xml.loadString(xml, false);
    List<Namespace> inScope = NamespaceUtils.getNamespacesInScope(xmle);
    assertContains("Expected inscope namespace " + Namespace.NO_NAMESPACE, Namespace.NO_NAMESPACE, inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("a", "http://aaa"), Namespace.getNamespace("a", "http://aaa"), inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("b", "http://bbb"), Namespace.getNamespace("b", "http://bbb"), inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("c", "http://ccc"), Namespace.getNamespace("c", "http://ccc"), inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("d", "http://ddd"), Namespace.getNamespace("d", "http://ddd"), inScope);
    Element a = xmle.getChild("a", Namespace.getNamespace("a", "http://aaa"));
    inScope = NamespaceUtils.getNamespacesInScope(a);
    assertContains("Expected inscope namespace " + Namespace.NO_NAMESPACE, Namespace.NO_NAMESPACE, inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("a", "http://aaa"), Namespace.getNamespace("a", "http://aaa"), inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("b", "http://bbb"), Namespace.getNamespace("b", "http://bbb"), inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("c", "http://ccc"), Namespace.getNamespace("c", "http://ccc"), inScope);
    assertContains("Expected inscope namespace " + Namespace.getNamespace("d", "http://ddd"), Namespace.getNamespace("d", "http://ddd"), inScope);
}