@Test public void shouldFindCorrectChildIndex() { ChildNodeXPathContextProvider p = new ChildNodeXPathContextProvider(ctx, elements); XPathContext provided = p.apply(elements.get(1)); assertEquals("/foo[2]", provided.getXPath()); }
@Override public XPathContext apply(Node n) { XPathContext ctx = xpathContext.clone(); Integer idx = childIndex.get(n); if (idx == null) { throw new NoSuchElementException(n + " is not a known child node"); } ctx.navigateToChild(idx.intValue()); return ctx; }
ChildNodeXPathContextProvider implements Mapper<Node, XPathContext> { @Override public XPathContext apply(Node n) { XPathContext ctx = xpathContext.clone(); Integer idx = childIndex.get(n); if (idx == null) { throw new NoSuchElementException(n + " is not a known child node"); } ctx.navigateToChild(idx.intValue()); return ctx; } }
ChildNodeXPathContextProvider implements Mapper<Node, XPathContext> { @Override public XPathContext apply(Node n) { XPathContext ctx = xpathContext.clone(); Integer idx = childIndex.get(n); if (idx == null) { throw new NoSuchElementException(n + " is not a known child node"); } ctx.navigateToChild(idx.intValue()); return ctx; } ChildNodeXPathContextProvider(XPathContext parentContext, Iterable<Node> children); }
ChildNodeXPathContextProvider implements Mapper<Node, XPathContext> { @Override public XPathContext apply(Node n) { XPathContext ctx = xpathContext.clone(); Integer idx = childIndex.get(n); if (idx == null) { throw new NoSuchElementException(n + " is not a known child node"); } ctx.navigateToChild(idx.intValue()); return ctx; } ChildNodeXPathContextProvider(XPathContext parentContext, Iterable<Node> children); @Override XPathContext apply(Node n); }
ChildNodeXPathContextProvider implements Mapper<Node, XPathContext> { @Override public XPathContext apply(Node n) { XPathContext ctx = xpathContext.clone(); Integer idx = childIndex.get(n); if (idx == null) { throw new NoSuchElementException(n + " is not a known child node"); } ctx.navigateToChild(idx.intValue()); return ctx; } ChildNodeXPathContextProvider(XPathContext parentContext, Iterable<Node> children); @Override XPathContext apply(Node n);  }