Search in sources :

Example 1 with NamespaceNodeImpl

use of net.sf.saxon.tree.iter.NamespaceIterator.NamespaceNodeImpl in project sirix by sirixdb.

the class TestNodeWrapper method testGetStringValueCS.

@Test
public void testGetStringValueCS() {
    // Test on document node.
    assertEquals("oops1foooops2baroops3", node.getStringValueCS());
    // Test on element node.
    AxisIterator iterator = node.iterateAxis(Axis.DESCENDANT);
    node = (NodeWrapper) iterator.next();
    assertEquals("oops1foooops2baroops3", node.getStringValueCS());
    // Test on namespace node.
    iterator = node.iterateAxis(Axis.NAMESPACE);
    NamespaceNodeImpl namespace = (NamespaceNodeImpl) iterator.next();
    /*
		 * Elements have always the default xml:NamespaceConstant.XML namespace, so
		 * we have to search if "ns" is found somewhere in the iterator (order
		 * unpredictable because it's implemented with a HashMap internally).
		 */
    while (!"ns".equals(namespace.getStringValueCS()) && namespace != null) {
        namespace = (NamespaceNodeImpl) iterator.next();
    }
    if (namespace == null) {
        fail("namespace is null!");
    } else {
        assertEquals("ns", namespace.getStringValueCS());
    }
    // Test on attribute node.
    final NodeWrapper attrib = (NodeWrapper) node.iterateAxis(Axis.ATTRIBUTE).next();
    assertEquals("j", attrib.getStringValueCS());
    // Test on text node.
    final NodeWrapper text = (NodeWrapper) node.iterateAxis(Axis.CHILD).next();
    assertEquals("oops1", text.getStringValueCS());
}
Also used : NamespaceNodeImpl(net.sf.saxon.tree.iter.NamespaceIterator.NamespaceNodeImpl) AxisIterator(net.sf.saxon.tree.iter.AxisIterator) NameTest(net.sf.saxon.pattern.NameTest) Test(org.junit.Test)

Aggregations

NameTest (net.sf.saxon.pattern.NameTest)1 AxisIterator (net.sf.saxon.tree.iter.AxisIterator)1 NamespaceNodeImpl (net.sf.saxon.tree.iter.NamespaceIterator.NamespaceNodeImpl)1 Test (org.junit.Test)1