Skip navigation links

Oracle Fusion Middleware XML Security Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10680-03


oracle.security.xmlsec.util
Class XMLElement

java.lang.Object
  extended by oracle.security.xmlsec.util.XMLNode
      extended by oracle.security.xmlsec.util.XMLElement

Direct Known Subclasses:
AgreementMethod, DHKeyValue, DSAKeyValue, ECDSAKeyValue, ECKeyValue, GenericXMLElement, KeyName, KeyValue, MgmtData, ObjectReference, PGPData, ReferenceList, RSAKeyValue, SOAPEnvelope, SOAPEnvelope, SOAPFault, SOAPFault, SOAPFaultCode, SOAPFaultSubcode, SPKIData, X509Data, XECipherData, XEEncryptedObject, XEEncryptionProperties, XEEncryptionProperty, XEReferenceList, XSAlgorithmIdentifier, XSKeyInfo, XSObject, XSSignature, XSSignatureValue, XSSigProperties, XSSigProperty

public abstract class XMLElement
extends XMLNode

Abstract superclass for XML element objects.

XMLElement serves as a wrapper class for an instance of org.w3c.dom.Element. Every public method of that interface is implemented here, and is forwarded to the enclosed Element. Additionally, XMLElement extends XMLNode in much the same way that Element extends Node. This allows instances of XMLElement to be manipulated in the same manner as instances of Element. The one exception is that a XMLElement cannot be directly appended to a Node using the Node.appendChild() method; instead use the XMLNode.getNode() method to obtain the XMLElement's enclosed Element node, and pass the result to the Node.appendChild() method.


Field Summary

 

Fields inherited from class oracle.security.xmlsec.util.XMLNode
node, systemId

 

Constructor Summary
protected XMLElement(org.w3c.dom.Document owner, java.lang.String nsURI, java.lang.String localName)
          Creates a new XMLElement instance in the given Document with the given namespace and tag name.
protected XMLElement(org.w3c.dom.Document owner, java.lang.String nsURI, java.lang.String localName, java.lang.String systemId)
          Creates a new XMLElement instance in the given Document with the given namespace and tag name.
protected XMLElement(org.w3c.dom.Element element)
          Creates a new XMLElement instance for the given org.w3c.dom.Element.
protected XMLElement(org.w3c.dom.Element element, java.lang.String systemId)
          Creates a new XMLElement instance for the given org.w3c.dom.Element.

 

Method Summary
static void addNSPrefixAttr(org.w3c.dom.Element element, java.lang.String prefix, java.lang.String nsURI)
          Adds a "xmlns" attribute to the given Element that maps the given prefix to the given namespace URI.
 void addNSPrefixAttr(java.lang.String prefix, java.lang.String nsURI)
          Adds a "xmlns" attribute to this XMLElement that maps the given prefix to the given namespace URI.
static void addNSPrefixAttrDefault(org.w3c.dom.Element element, java.lang.String nsURI)
          Adds a "xmlns" attribute to the given Element that maps the default prefix to the given namespace URI.
 void addNSPrefixAttrDefault(java.lang.String nsURI)
          Adds a "xmlns" attribute to this XMLElement that maps the default prefix to the given namespace URI.
 java.lang.String getAttribute(java.lang.String name)
          Retrieves an attribute value by name.
 org.w3c.dom.Attr getAttributeNode(java.lang.String name)
          Retrieves an attribute node by name.
 org.w3c.dom.Attr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves an Attr node by local name and namespace URI.
 java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves an attribute value by local name and namespace URI.
static org.w3c.dom.NodeList getChildElementsByTagName(org.w3c.dom.Element parent, java.lang.String name)
          Returns a NodeList of all child Elements of the given parent Element with a given tag name, in the order in which they are encountered in a preorder traversal of the child Elements of this given Element.
 org.w3c.dom.NodeList getChildElementsByTagName(java.lang.String name)
          Returns a NodeList of all child Elements of this Element with a given tag name, in the order in which they are encountered in a preorder traversal of the child Elements of this Element.
static org.w3c.dom.NodeList getChildElementsByTagNameNS(org.w3c.dom.Element parent, java.lang.String namespaceURI, java.lang.String name)
          Returns a NodeList of all child Elements of this with the given parent Element and a given local name and namespace URI, in the order in which they are encountered in a preorder traversal of the child Elements of this parent Element.
 org.w3c.dom.NodeList getChildElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String name)
          Returns a NodeList of all child Elements of this Elementwith a given local name and namespace URI, in the order in which they are encountered in a preorder traversal of the child Elements of this Element.
static java.lang.String getDefaultNSPrefix(java.lang.String nsURI)
          Returns the default prefix for the given namespace URI.
 org.w3c.dom.Element getElement()
          Return the Element contained inside this XMLElement.
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
          Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
 java.lang.String getTagName()
          Returns the name of the element.
 boolean hasAttribute(java.lang.String name)
          Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.
 boolean hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.
 void removeAttribute(java.lang.String name)
          Removes an attribute by name.
 org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
          Removes the specified attribute node.
 void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
          Removes an attribute by local name and namespace URI.
 void setAttribute(java.lang.String name, java.lang.String value)
          Adds a new attribute.
 org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
          Adds a new attribute node.
 org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
          Adds a new attribute.
 void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)
          Adds a new attribute.
static void setDefaultNSPrefix(java.lang.String nsURI, java.lang.String prefix)
          Maps a namespace URI to a prefix.

 

Methods inherited from class oracle.security.xmlsec.util.XMLNode
appendChild, appendChild, appendTo, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNode, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getSystemId, hasAttributes, hasChildNodes, insertBefore, insertBefore, isSupported, normalize, removeChild, removeChild, replaceChild, replaceChild, setNodeValue, setPrefix, setSystemId, toBytesXML, toStringXML

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

XMLElement

protected XMLElement(org.w3c.dom.Element element)
              throws org.w3c.dom.DOMException
Creates a new XMLElement instance for the given org.w3c.dom.Element. This constructor should be invoked by the constructors of all subclasses to set the XMLNode.node field.
Parameters:
element - The org.w3c.dom.Element that will be contained in this XMLElement.
Throws:
org.w3c.dom.DOMException - If the local name of element is invalid for an instance of this XMLNode's type.

XMLElement

protected XMLElement(org.w3c.dom.Element element,
                     java.lang.String systemId)
              throws org.w3c.dom.DOMException
Creates a new XMLElement instance for the given org.w3c.dom.Element. This constructor should be invoked by the constructors of all subclasses to set the XMLNode.node field.
Parameters:
element - The org.w3c.dom.Element that will be contained in this XMLElement.
systemId - The URI string system ID for the XMLElement.
Throws:
org.w3c.dom.DOMException - If the local name of element is invalid for an instance of this XMLNode's type.
Since:
2.0
See Also:
XMLNode.setSystemId(java.lang.String)

XMLElement

protected XMLElement(org.w3c.dom.Document owner,
                     java.lang.String nsURI,
                     java.lang.String localName)
              throws org.w3c.dom.DOMException
Creates a new XMLElement instance in the given Document with the given namespace and tag name. Additionally, if a default namespace prefix is mapped for the given URI, it will be prepended to the tag name. This constructor should be invoked by the constructors of all subclasses that want a new Node to be created.
Parameters:
owner - The owner document of the new Element.
nsURI - The namespace URI in which the new Element is to be created.
localName - The local name of the new Element. If a default namespace has been mapped to nsURI, is will be prepended to tagName.
Throws:
org.w3c.dom.DOMException

XMLElement

protected XMLElement(org.w3c.dom.Document owner,
                     java.lang.String nsURI,
                     java.lang.String localName,
                     java.lang.String systemId)
              throws org.w3c.dom.DOMException
Creates a new XMLElement instance in the given Document with the given namespace and tag name. Additionally, if a default namespace prefix is mapped for the given URI, it will be prepended to the tag name. This constructor should be invoked by the constructors of all subclasses that want a new Node to be created.
Parameters:
owner - The owner document of the new Element.
nsURI - The namespace URI in which the new Element is to be created.
localName - The local name of the new Element. If a default namespace has been mapped to nsURI, is will be prepended to tagName.
systemId - The URI string system ID for the XMLElement.
Throws:
org.w3c.dom.DOMException
Since:
2.0
See Also:
XMLNode.setSystemId(java.lang.String)

Method Detail

getChildElementsByTagName

public org.w3c.dom.NodeList getChildElementsByTagName(java.lang.String name)
Returns a NodeList of all child Elements of this Element with a given tag name, in the order in which they are encountered in a preorder traversal of the child Elements of this Element.
Parameters:
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching child elements

getChildElementsByTagNameNS

public org.w3c.dom.NodeList getChildElementsByTagNameNS(java.lang.String namespaceURI,
                                                        java.lang.String name)
Returns a NodeList of all child Elements of this Elementwith a given local name and namespace URI, in the order in which they are encountered in a preorder traversal of the child Elements of this Element.
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching child elements of this element.

getChildElementsByTagName

public static org.w3c.dom.NodeList getChildElementsByTagName(org.w3c.dom.Element parent,
                                                             java.lang.String name)
Returns a NodeList of all child Elements of the given parent Element with a given tag name, in the order in which they are encountered in a preorder traversal of the child Elements of this given Element.
Parameters:
parent - The parent element.
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching child elements

getChildElementsByTagNameNS

public static org.w3c.dom.NodeList getChildElementsByTagNameNS(org.w3c.dom.Element parent,
                                                               java.lang.String namespaceURI,
                                                               java.lang.String name)
Returns a NodeList of all child Elements of this with the given parent Element and a given local name and namespace URI, in the order in which they are encountered in a preorder traversal of the child Elements of this parent Element.
Parameters:
parent - The parent element.
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching child elements of this element.

setDefaultNSPrefix

public static void setDefaultNSPrefix(java.lang.String nsURI,
                                      java.lang.String prefix)
Maps a namespace URI to a prefix. This mapping will be used by default for XMLElements created with the given namespace URI.
Parameters:
nsURI - The namespace URI to be mapped.
prefix - The default prefix corresponding to the given namespace. If this is null, any existing mapping for the given namespace URI will be removed.

getDefaultNSPrefix

public static java.lang.String getDefaultNSPrefix(java.lang.String nsURI)
Returns the default prefix for the given namespace URI.
Parameters:
nsURI - The namespace URI to look up.
Returns:
The default prefix for the given URI, or null if none is mapped.

addNSPrefixAttr

public static void addNSPrefixAttr(org.w3c.dom.Element element,
                                   java.lang.String prefix,
                                   java.lang.String nsURI)
                            throws org.w3c.dom.DOMException
Adds a "xmlns" attribute to the given Element that maps the given prefix to the given namespace URI.
Parameters:
element - The org.w3c.dom.Element to which the attribute will be added.
prefix - The namespace prefix to be defined in the "xmlns" attribute.
nsURI - The namespace URI to be mapped to the given prefix.
Throws:
org.w3c.dom.DOMException

addNSPrefixAttrDefault

public static void addNSPrefixAttrDefault(org.w3c.dom.Element element,
                                          java.lang.String nsURI)
                                   throws org.w3c.dom.DOMException
Adds a "xmlns" attribute to the given Element that maps the default prefix to the given namespace URI.
Parameters:
element - The org.w3c.dom.Element to which the attribute will be added.
nsURI - The namespace URI to be mapped to the default prefix.
Throws:
org.w3c.dom.DOMException

addNSPrefixAttr

public void addNSPrefixAttr(java.lang.String prefix,
                            java.lang.String nsURI)
                     throws org.w3c.dom.DOMException
Adds a "xmlns" attribute to this XMLElement that maps the given prefix to the given namespace URI.
Parameters:
prefix - The namespace prefix to be defined in the "xmlns" attribute.
nsURI - The namespace URI to be mapped to the given prefix.
Throws:
org.w3c.dom.DOMException

addNSPrefixAttrDefault

public void addNSPrefixAttrDefault(java.lang.String nsURI)
                            throws org.w3c.dom.DOMException
Adds a "xmlns" attribute to this XMLElement that maps the default prefix to the given namespace URI.
Parameters:
nsURI - The namespace URI to be mapped to the default prefix.
Throws:
org.w3c.dom.DOMException
See Also:
addNSPrefixAttr(String prefix, String nsURI), getDefaultNSPrefix(java.lang.String)

getTagName

public java.lang.String getTagName()
Returns the name of the element.

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Retrieves an attribute value by name.
Parameters:
name - The name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws org.w3c.dom.DOMException
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode(org.w3c.dom.Attr) to assign it as the value of an attribute.

To set an attribute with a qualified name and namespace URI, use the setAttributeNS(java.lang.String, java.lang.String, java.lang.String) method.

Parameters:
name - The name of the attribute to create or alter.
value - Value to set in string form.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

removeAttribute

public void removeAttribute(java.lang.String name)
                     throws org.w3c.dom.DOMException
Removes an attribute by name. If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.

To remove an attribute by local name and namespace URI, use the {#link #removeAttributeNS} method.

Parameters:
name - The name of the attribute to remove.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

getAttributeNode

public org.w3c.dom.Attr getAttributeNode(java.lang.String name)
Retrieves an attribute node by name.

To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS(java.lang.String, java.lang.String) method.

Parameters:
name - The name of the attribute to retrieve.
Returns:
The Attr node with the specified name, or null if there is no such attribute.

setAttributeNode

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
                                  throws org.w3c.dom.DOMException
Adds a new attribute node. If an attribute with that name is already present in the element, it is replaced by the new one.

To add a new attribute node with a qualified name and namespace URI, use the setAttributeNodeNS(org.w3c.dom.Attr) method.

Parameters:
newAttr - The Attr node to add to the attribute list.
Returns:
If the newAttr attribute replaces an existing attribute, the replaced Attr node is returned, otherwise null is returned.
Throws:
org.w3c.dom.DOMException - WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.

removeAttributeNode

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
                                     throws org.w3c.dom.DOMException
Removes the specified attribute node. If the removed Attr has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.
Parameters:
oldAttr - The Attr node to remove from the attribute list.
Returns:
The Attr node that was removed.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldAttr is not an attribute of the element.

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
Parameters:
name - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A list of matching Element nodes.

getAttributeNS

public java.lang.String getAttributeNS(java.lang.String namespaceURI,
                                       java.lang.String localName)
Retrieves an attribute value by local name and namespace URI.
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.
Since:
DOM Level 2

setAttributeNS

public void setAttributeNS(java.lang.String namespaceURI,
                           java.lang.String qualifiedName,
                           java.lang.String value)
                    throws org.w3c.dom.DOMException
Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS(org.w3c.dom.Attr) or setAttributeNode(org.w3c.dom.Attr) to assign it as the value of an attribute.
Parameters:
namespaceURI - The namespace URI of the attribute to create or alter.
qualifiedName - The qualified name of the attribute to create or alter.
value - The value to set in string form.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", or if the qualifiedName is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".
Since:
DOM Level 2

removeAttributeNS

public void removeAttributeNS(java.lang.String namespaceURI,
                              java.lang.String localName)
                       throws org.w3c.dom.DOMException
Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.
Parameters:
namespaceURI - The namespace URI of the attribute to remove.
localName - The local name of the attribute to remove.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
Since:
DOM Level 2

getAttributeNodeNS

public org.w3c.dom.Attr getAttributeNodeNS(java.lang.String namespaceURI,
                                           java.lang.String localName)
Retrieves an Attr node by local name and namespace URI.
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.
Since:
DOM Level 2

setAttributeNodeNS

public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
                                    throws org.w3c.dom.DOMException
Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.
Parameters:
newAttr - The Attr node to add to the attribute list.
Returns:
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced Attr node is returned, otherwise null is returned.
Throws:
org.w3c.dom.DOMException - WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
Since:
DOM Level 2

getElementsByTagNameNS

public org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                                   java.lang.String localName)
Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
A new NodeList object containing all the matched Elements.
Since:
DOM Level 2

hasAttribute

public boolean hasAttribute(java.lang.String name)
Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.
Parameters:
name - The name of the attribute to look for.
Returns:
true if an attribute with the given name is specified on this element or has a default value, false otherwise.
Since:
DOM Level 2

hasAttributeNS

public boolean hasAttributeNS(java.lang.String namespaceURI,
                              java.lang.String localName)
Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.
Parameters:
namespaceURI - The namespace URI of the attribute to look for.
localName - The local name of the attribute to look for.
Returns:
true if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise.
Since:
DOM Level 2

getElement

public org.w3c.dom.Element getElement()
Return the Element contained inside this XMLElement. Just a shortcut for:
(Element)getNode()
Returns:

Skip navigation links

Oracle Fusion Middleware XML Security Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10680-03


Copyright © 2005, 2011 , Oracle. All rights reserved.