Node parent = ctx.getParentNode(); if (parent != null) { return parent.getChildNodes().getLength(); } return 1;
int count = 1; Node sib = ctx.getPreviousSibling(); for (; sib != null; sib = sib.getPreviousSibling()) count++; sib = ctx.getNextSibling(); for (; sib != null; sib = sib.getNextSibling()) count++; return count;
  private int getContextSize(Node ctx)  {    if (ctx.getNodeType() == Node.ATTRIBUTE_NODE)      {        Node parent = ((Attr) ctx).getOwnerElement();        return parent.getAttributes().getLength();      }    Node parent = ctx.getParentNode();    if (parent != null)      {        return parent.getChildNodes().getLength();      }    return 1;  }