/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XPathNamespaceImpl.java 1225426 2011-12-29 04:13:08Z mrglavas $
*/
package org.apache.xpath.domapi;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.xpath.XPathNamespace;
import org.w3c.dom.UserDataHandler;
The XPathNamespace
interface is returned by
XPathResult
interfaces to represent the XPath namespace node
type that DOM lacks. There is no public constructor for this node type.
Attempts to place it into a hierarchy or a NamedNodeMap result in a
DOMException
with the code HIERARCHY_REQUEST_ERR
. This node is read only, so methods or setting of attributes that would
mutate the node result in a DOMException with the code
NO_MODIFICATION_ALLOWED_ERR
.
The core specification describes attributes of the Node
interface that are different for different node node types but does not
describe XPATH_NAMESPACE_NODE
, so here is a description of
those attributes for this node type. All attributes of Node
not described in this section have a null
or
false
value.
ownerDocument
matches the ownerDocument
of the
ownerElement
even if the element is later adopted.
prefix
is the prefix of the namespace represented by the
node.
nodeName
is the same as prefix
.
nodeType
is equal to XPATH_NAMESPACE_NODE
.
namespaceURI
is the namespace URI of the namespace
represented by the node.
adoptNode
, cloneNode
, and
importNode
fail on this node type by raising a
DOMException
with the code NOT_SUPPORTED_ERR
.In
future versions of the XPath specification, the definition of a namespace
node may be changed incomatibly, in which case incompatible changes to
field values may be required to implement versions beyond XPath 1.0.
See also the Document Object Model (DOM) Level 3 XPath Specification.
This implementation wraps the DOM attribute node that contained the
namespace declaration.
@xsl.usage internal
/**
*
*
* The <code>XPathNamespace</code> interface is returned by
* <code>XPathResult</code> interfaces to represent the XPath namespace node
* type that DOM lacks. There is no public constructor for this node type.
* Attempts to place it into a hierarchy or a NamedNodeMap result in a
* <code>DOMException</code> with the code <code>HIERARCHY_REQUEST_ERR</code>
* . This node is read only, so methods or setting of attributes that would
* mutate the node result in a DOMException with the code
* <code>NO_MODIFICATION_ALLOWED_ERR</code>.
* <p>The core specification describes attributes of the <code>Node</code>
* interface that are different for different node node types but does not
* describe <code>XPATH_NAMESPACE_NODE</code>, so here is a description of
* those attributes for this node type. All attributes of <code>Node</code>
* not described in this section have a <code>null</code> or
* <code>false</code> value.
* <p><code>ownerDocument</code> matches the <code>ownerDocument</code> of the
* <code>ownerElement</code> even if the element is later adopted.
* <p><code>prefix</code> is the prefix of the namespace represented by the
* node.
* <p><code>nodeName</code> is the same as <code>prefix</code>.
* <p><code>nodeType</code> is equal to <code>XPATH_NAMESPACE_NODE</code>.
* <p><code>namespaceURI</code> is the namespace URI of the namespace
* represented by the node.
* <p><code>adoptNode</code>, <code>cloneNode</code>, and
* <code>importNode</code> fail on this node type by raising a
* <code>DOMException</code> with the code <code>NOT_SUPPORTED_ERR</code>.In
* future versions of the XPath specification, the definition of a namespace
* node may be changed incomatibly, in which case incompatible changes to
* field values may be required to implement versions beyond XPath 1.0.
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.
*
* This implementation wraps the DOM attribute node that contained the
* namespace declaration.
* @xsl.usage internal
*/
class XPathNamespaceImpl implements XPathNamespace {
// Node that XPathNamespaceImpl wraps
final private Node m_attributeNode;
Constructor for XPathNamespaceImpl.
/**
* Constructor for XPathNamespaceImpl.
*/
XPathNamespaceImpl(Node node) {
m_attributeNode = node;
}
See Also: - getOwnerElement.getOwnerElement()
/**
* @see org.apache.xalan.dom3.xpath.XPathNamespace#getOwnerElement()
*/
public Element getOwnerElement() {
return ((Attr)m_attributeNode).getOwnerElement();
}
See Also: - getNodeName.getNodeName()
/**
* @see org.w3c.dom.Node#getNodeName()
*/
public String getNodeName() {
return "#namespace";
}
See Also: - getNodeValue.getNodeValue()
/**
* @see org.w3c.dom.Node#getNodeValue()
*/
public String getNodeValue() throws DOMException {
return m_attributeNode.getNodeValue();
}
See Also: - setNodeValue.setNodeValue(String)
/**
* @see org.w3c.dom.Node#setNodeValue(String)
*/
public void setNodeValue(String arg0) throws DOMException {
}
See Also: - getNodeType.getNodeType()
/**
* @see org.w3c.dom.Node#getNodeType()
*/
public short getNodeType() {
return XPathNamespace.XPATH_NAMESPACE_NODE;
}
See Also: - getParentNode.getParentNode()
/**
* @see org.w3c.dom.Node#getParentNode()
*/
public Node getParentNode() {
return m_attributeNode.getParentNode();
}
See Also: - getChildNodes.getChildNodes()
/**
* @see org.w3c.dom.Node#getChildNodes()
*/
public NodeList getChildNodes() {
return m_attributeNode.getChildNodes();
}
See Also: - getFirstChild.getFirstChild()
/**
* @see org.w3c.dom.Node#getFirstChild()
*/
public Node getFirstChild() {
return m_attributeNode.getFirstChild();
}
See Also: - getLastChild.getLastChild()
/**
* @see org.w3c.dom.Node#getLastChild()
*/
public Node getLastChild() {
return m_attributeNode.getLastChild();
}
See Also: - getPreviousSibling.getPreviousSibling()
/**
* @see org.w3c.dom.Node#getPreviousSibling()
*/
public Node getPreviousSibling() {
return m_attributeNode.getPreviousSibling();
}
See Also: - getNextSibling.getNextSibling()
/**
* @see org.w3c.dom.Node#getNextSibling()
*/
public Node getNextSibling() {
return m_attributeNode.getNextSibling();
}
See Also: - getAttributes.getAttributes()
/**
* @see org.w3c.dom.Node#getAttributes()
*/
public NamedNodeMap getAttributes() {
return m_attributeNode.getAttributes();
}
See Also: - getOwnerDocument.getOwnerDocument()
/**
* @see org.w3c.dom.Node#getOwnerDocument()
*/
public Document getOwnerDocument() {
return m_attributeNode.getOwnerDocument();
}
See Also: - insertBefore.insertBefore(Node, Node)
/**
* @see org.w3c.dom.Node#insertBefore(Node, Node)
*/
public Node insertBefore(Node arg0, Node arg1) throws DOMException {
return null;
}
See Also: - replaceChild.replaceChild(Node, Node)
/**
* @see org.w3c.dom.Node#replaceChild(Node, Node)
*/
public Node replaceChild(Node arg0, Node arg1) throws DOMException {
return null;
}
See Also: - removeChild.removeChild(Node)
/**
* @see org.w3c.dom.Node#removeChild(Node)
*/
public Node removeChild(Node arg0) throws DOMException {
return null;
}
See Also: - appendChild.appendChild(Node)
/**
* @see org.w3c.dom.Node#appendChild(Node)
*/
public Node appendChild(Node arg0) throws DOMException {
return null;
}
See Also: - hasChildNodes.hasChildNodes()
/**
* @see org.w3c.dom.Node#hasChildNodes()
*/
public boolean hasChildNodes() {
return false;
}
See Also: - cloneNode.cloneNode(boolean)
/**
* @see org.w3c.dom.Node#cloneNode(boolean)
*/
public Node cloneNode(boolean arg0) {
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,null);
}
See Also: - normalize.normalize()
/**
* @see org.w3c.dom.Node#normalize()
*/
public void normalize() {
m_attributeNode.normalize();
}
See Also: - isSupported.isSupported(String, String)
/**
* @see org.w3c.dom.Node#isSupported(String, String)
*/
public boolean isSupported(String arg0, String arg1) {
return m_attributeNode.isSupported(arg0, arg1);
}
See Also: - getNamespaceURI.getNamespaceURI()
/**
* @see org.w3c.dom.Node#getNamespaceURI()
*/
public String getNamespaceURI() {
// For namespace node, the namespaceURI is the namespace URI
// of the namespace represented by the node.
return m_attributeNode.getNodeValue();
}
See Also: - getPrefix.getPrefix()
/**
* @see org.w3c.dom.Node#getPrefix()
*/
public String getPrefix() {
return m_attributeNode.getPrefix();
}
See Also: - setPrefix.setPrefix(String)
/**
* @see org.w3c.dom.Node#setPrefix(String)
*/
public void setPrefix(String arg0) throws DOMException {
}
See Also: - getLocalName.getLocalName()
/**
* @see org.w3c.dom.Node#getLocalName()
*/
public String getLocalName() {
// For namespace node, the local name is the same as the prefix
return m_attributeNode.getPrefix();
}
See Also: - hasAttributes.hasAttributes()
/**
* @see org.w3c.dom.Node#hasAttributes()
*/
public boolean hasAttributes() {
return m_attributeNode.hasAttributes();
}
public String getBaseURI ( ) {
return null;
}
public short compareDocumentPosition(Node other) throws DOMException {
return 0;
}
private String textContent;
public String getTextContent() throws DOMException {
return textContent;
}
public void setTextContent(String textContent) throws DOMException {
this.textContent = textContent;
}
public boolean isSameNode(Node other) {
return false;
}
public String lookupPrefix(String namespaceURI) {
return ""; //PENDING
}
public boolean isDefaultNamespace(String namespaceURI) {
return false;
}
public String lookupNamespaceURI(String prefix) {
return null;
}
public boolean isEqualNode(Node arg) {
return false;
}
public Object getFeature(String feature, String version) {
return null; //PENDING
}
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return null; //PENDING
}
public Object getUserData(String key) {
return null;
}
}