if (prefix != null && !prefixes.contains(prefix)) { prefixes.add(prefix); nsList.add(new OMNamespaceEx(namespace, context)); new OMNamespaceEx( omContextNode.getOMFactory().createOMNamespace( "http://www.w3.org/XML/1998/namespace",
/** * Returns the parent of the given context node. * <p> * The parent of any node must either be a document node or an element node. * * @param contextNode the context node * @return Returns the parent of the context node, or null if this is a document node. * @throws UnsupportedAxisException if the parent axis is not supported by the model * @see #isDocument * @see #isElement */ public Object getParentNode(Object contextNode) throws UnsupportedAxisException { if (contextNode == null || contextNode instanceof OMDocument) { return null; } else if (contextNode instanceof OMAttribute) { return ((OMAttribute) contextNode).getOwner(); } else if (contextNode instanceof OMNamespaceEx) { return ((OMNamespaceEx) contextNode).getParent(); } return ((OMNode) contextNode).getParent(); }
/** * Retrieves an <code>Iterator</code> matching the <code>parent</code> XPath axis. * * @param contextNode the original context node * @return Returns an Iterator capable of traversing the axis, not null. * @throws UnsupportedAxisException if the semantics of the parent axis are not supported by * this object model */ public Iterator getParentAxisIterator(Object contextNode) throws UnsupportedAxisException { if (contextNode instanceof OMNode) { return new SingleObjectIterator(((OMNode) contextNode).getParent()); } else if (contextNode instanceof OMNamespaceEx) { return new SingleObjectIterator( ((OMNamespaceEx) contextNode).getParent()); } else if (contextNode instanceof OMAttribute) { return new SingleObjectIterator( ((OMAttribute) contextNode).getOwner()); } return JaxenConstants.EMPTY_ITERATOR; }