@Override
  public final Object getDocumentNode(Object contextNode) {
    if (contextNode instanceof Document) {
      return contextNode;
    }
    if (contextNode instanceof NamespaceContainer) {
      return ((NamespaceContainer)contextNode).getParentElement().getDocument();
    }
    if (contextNode instanceof Attribute) {
      return ((Attribute)contextNode).getDocument();
    }
    return ((Content)contextNode).getDocument();
  }
@Override
  public final Object getDocumentNode(Object contextNode)