XML for Java Compatibility API 2.0.15

com.ibm.xml.parser
Class TXElement

java.lang.Object
  |
  +--com.ibm.xml.parser.Child
        |
        +--com.ibm.xml.parser.Parent
              |
              +--com.ibm.xml.parser.TXElement
Direct Known Subclasses:
TreeFactory.TreeElement

public class TXElement
extends Parent
implements org.w3c.dom.Element, Namespace

The TXElement class implements the Element interface as defined by the Document Object Model (DOM), and implements the namespace interface as defined by the W3C.

By far the vast majority (apart from text) of Node types that authors will generally encounter when traversing a document will be Element Nodes. An Element consists of its start tag, any attributes, any children, and its end tag.

Version:
Revision: 04 1.6 src/com/ibm/xml/parser/TXElement.java, parser, xml4j2, xml4j2_0_15
See Also:
Element, Namespace, Parent, Child, Serialized Form

Field Summary
static java.lang.String S_XMLNAMESPACEURI
           
static java.lang.String S_XMLNS
           
 
Fields inherited from class com.ibm.xml.parser.Child
ATTDEF, ATTLIST, ELEMENT_DECL, NAME_ATTDEF, NAME_ATTLIST, NAME_CDATA, NAME_COMMENT, NAME_DOCFRAGMENT, NAME_DOCUMENT, NAME_ELEMENT_DECL, NAME_PSEUDONODE, NAME_TEXT, PSEUDONODE
 
Constructor Summary
TXElement(java.lang.String tagName)
          Constructor.
 
Method Summary
 void acceptPost(Visitor visitor)
          Implements the accept operation of the visitor design pattern when the end of a TXElement Node is recognized when traversing the document object tree.
 void acceptPre(Visitor visitor)
          Implements the accept operation of the visitor design pattern when the start of a TXElement Node is recognized when traversing the document object tree.
 void addTextElement(TXText text)
          Adds the specified text Node to the end of this Element.
 java.util.Enumeration attributeElements()
          Returns an enumeration of TXAttribute of the attributes of this Element.
protected  void checkChildType(org.w3c.dom.Node child)
          Check whether child is allowed to be insered in this node or not.
 java.lang.Object clone()
          Clone this Element Node and its children using the appropriate factories.
 org.w3c.dom.Node cloneNode(boolean deep)
           
 TXElement cloneWithoutChildren()
          Clone this Element Node using the appropriate factory.
 void collectNamespaceAttributes()
          Collect all xmlns: attributes in anchestors and set to this elemnent.
 void collectNamespaceAttributes(org.w3c.dom.Node parent)
          Collect all xmlns: attributes in anchestors and set to this elemnent.
 java.lang.String createExpandedName()
          Returns an expanded name of this Element.
 boolean equals(org.w3c.dom.Node arg, boolean deep)
           
 java.lang.String getAttribute(java.lang.String name)
          Returns an attribute's value from this Element that matches the specified attribute name.
 TXAttribute[] getAttributeArray()
          Returns a TXAttribute array of the attributes of this Element.
 org.w3c.dom.Attr getAttributeNode(java.lang.String name)
          Returns an attribute's value from this Element that matches the specified attribute name.
 org.w3c.dom.NamedNodeMap getAttributes()
          Returns a NamedNodeMap of the attributes of this Element.
 TXElement getElementNamed(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
          Returns the first TXElement match through the immediate child Elemen Nodes.
 TXElement getElementNamed(java.lang.String qName)
          Returns the first TXElement match through the immediate Child Element Nodes.
 TXElement getElementNamed(java.lang.String uri, java.lang.String localName)
          Returns the first TXElement match through the immediate child Element Nodes.
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String qName)
          Returns a NodeList of matches through all child Element Nodes.
 org.w3c.dom.NodeList getElementsNamed(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
          Returns a NodeList of all matches through the immediate child Element Nodes.
 org.w3c.dom.NodeList getElementsNamed(java.lang.String qName)
          Returns a NodeList of all matches through the immediate child Element Nodes.
 org.w3c.dom.NodeList getElementsNamed(java.lang.String uri, java.lang.String localName)
          Returns a NodeList of matches through the immediate child Element Nodes.
 java.lang.String getLanguage()
          Returns the XML language ID (the value of the xml:lang Attribute) in use for this Element Node.
static java.lang.String getLocalNameForQName(java.lang.String qname)
          Returns localPart(a name after a colon) of specified qualified name.
 java.lang.String getName()
          Deprecated. Use getNodeName() or getTagName()
 java.lang.String getNamespaceForPrefix(java.lang.String prefix)
          Returns a namespace URI for specified prefix.
 java.lang.String getNamespaceForQName(java.lang.String qname)
          Returns a namespace URI for specified qualified name.
 java.lang.String getNodeName()
           
 short getNodeType()
          Returns that this object is an Element Node.
 java.lang.String getNSLocalName()
          Returns the local name of the Namespace.
 java.lang.String getNSName()
          Returns the Namespace URI.
 TXElement getNthElementNamed(int nth, int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
          Returns the Nth TXElement match through the immediate child Element Nodes.
 TXElement getNthElementNamed(int nth, java.lang.String qName)
          Returns the Nth TXElement match through the immediate child Element Nodes.
 TXElement getNthElementNamed(int nth, java.lang.String uri, java.lang.String localName)
          Returns the Nth TXElement match through the immediate child Element Nodes.
 java.lang.String getTagName()
          Returns this Element's name.
 java.lang.String getUniversalName()
          Deprecated. Use createExpandedName().
 boolean isEmpty()
          Deprecated. Use hasChildNodes().
 boolean isPreserveSpace()
          Returns, at the Element level, whether space is to be preserved.
 void normalize()
          Puts all Text Nodes in the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, PIs, CDATASections, and entity references) separates Text Nodes.
 void removeAttribute(java.lang.String name)
          Removes the attribute that matches the specified name from this Element.
 org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr attribute)
          Removes the specified attribute from this Element.
 void removeOverlappedNamespaceAttributes()
          Remove overlapped xmlns: attributes.
protected  void resetDefaultAttribute(java.lang.String name)
          Sets a default attribute if name has default value.
 TXElement[] searchChildrenAll(java.lang.String qName)
          Returns an array of TXElement of matches through the immediate child Element Nodes.
 TXElement searchDescendants(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
          Returns the first TXElement match through all child Element Nodes.
 TXElement searchDescendants(java.lang.String qName)
          Returns the first TXElement match through all child Element Nodes.
 TXElement[] searchDescendantsAll(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
          Returns an array of TXElement matches through all child Element Nodes.
 TXElement[] searchDescendantsAll(java.lang.String qName)
          Returns an array of TXElement matches through all child Element Nodes.
 void setAttribute(java.lang.String name, java.lang.String value)
          Adds a new attribute name/value pair to this Element using the appropriate factory.
 void setAttribute(TXAttribute attribute)
          Deprecated. Use setAttributeNode()
 org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr attribute)
          Adds a new attribute to this Element using the appropriate factory.
 void setPreserveSpace(boolean isPreserveSpace)
          Sets, at the Element level, whether space is to be preserved.
 void setTagName(java.lang.String tagName)
          Sets this Element's name.
 
Methods inherited from class com.ibm.xml.parser.Parent
addElement, appendChild, elements, expandEntityReferences, getChildNodes, getChildrenArray, getFirstChild, getFirstWithoutReference, getLastChild, getLastWithoutReference, getText, hasChildNodes, insert, insertAfter, insertBefore, insertFirst, insertLast, processAfterRemove, realInsert, removeChild, replaceChild
 
Methods inherited from class com.ibm.xml.parser.Child
clearDigest, getDigest, getFactory, getNextSibling, getNextWithoutReference, getNodeValue, getOwnerDocument, getParentNode, getParentWithoutReference, getPreviousSibling, getPreviousWithoutReference, getUserData, makeXPointer, print, print, searchAncestors, searchAncestors, setFactory, setNodeValue, setUserData, toXMLString, toXMLString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_XMLNS

public static final java.lang.String S_XMLNS

S_XMLNAMESPACEURI

public static final java.lang.String S_XMLNAMESPACEURI
Constructor Detail

TXElement

public TXElement(java.lang.String tagName)
Constructor.
Parameters:
tagName - this Element's tag name (qualified name). In the example <elementExample id="demo"> ... </elementExample>, the tag name is elementExample.
Method Detail

clone

public java.lang.Object clone()
Clone this Element Node and its children using the appropriate factories.

This method is defined by Child.

Returns:
Cloned Element Node.
Overrides:
clone in class Child
See Also:
Child.clone()

cloneWithoutChildren

public TXElement cloneWithoutChildren()
Clone this Element Node using the appropriate factory.
Returns:
Cloned Element Node.

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Overrides:
cloneNode in class Child

equals

public boolean equals(org.w3c.dom.Node arg,
                      boolean deep)
Overrides:
equals in class Child

getNodeType

public short getNodeType()
Returns that this object is an Element Node.

This method is defined by DOM.

Returns:
Element Node indicator.

getNodeName

public java.lang.String getNodeName()
See Also:
getTagName(), getName()

getTagName

public java.lang.String getTagName()
Returns this Element's name. In the example <elementExample id="demo"> ... </elementExample>, the tag name is elementExample. If the Element's name has a namespace prefix, the prefix will still be attached.

This method is defined by DOM.

Specified by:
getTagName in interface org.w3c.dom.Element
Returns:
The string that is this Element's name, or null if no name.
See Also:
setTagName(java.lang.String), getName(), getNodeName()

getName

public java.lang.String getName()
Deprecated. Use getNodeName() or getTagName()
Returns this Element's name. This method is equivalent to getTagName().
Specified by:
getName in interface Namespace
Returns:
The string that is this Element's name, or null if no name.
See Also:
getTagName(), setTagName(java.lang.String)

setTagName

public void setTagName(java.lang.String tagName)
Sets this Element's name. In the example <elementExample id="demo"> ... </elementExample>, the tag name is elementExample.
Parameters:
tagName - The string that is this Element's name.
See Also:
getTagName()

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns an attribute's value from this Element that matches the specified attribute name. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Specified by:
getAttribute in interface org.w3c.dom.Element
Parameters:
name - The name to match in this Element's list of attributes.
Returns:
The string value of the matching attribute; otherwise, empty string.
See Also:
getAttributeNode(java.lang.String), setAttribute(java.lang.String, java.lang.String), setAttributeNode(org.w3c.dom.Attr), getLanguage()

getAttributeNode

public org.w3c.dom.Attr getAttributeNode(java.lang.String name)
Returns an attribute's value from this Element that matches the specified attribute name. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Specified by:
getAttributeNode in interface org.w3c.dom.Element
Parameters:
name - The name to match in this Element's list of attributes.
Returns:
The matching Attribute Node; otherwise, null.
See Also:
getAttribute(java.lang.String), setAttribute(java.lang.String, java.lang.String), setAttributeNode(org.w3c.dom.Attr)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws org.w3c.dom.DOMException
Adds a new attribute name/value pair to this Element using the appropriate factory. If an attribute by that name is already present in this Element, it's value is changed to be that of value. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Specified by:
setAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to create or update.
value - The value of the created or updated attribute.
See Also:
getAttribute(java.lang.String), getAttributeNode(java.lang.String), setAttributeNode(org.w3c.dom.Attr)

setAttribute

public void setAttribute(TXAttribute attribute)
Deprecated. Use setAttributeNode()
Adds a new attribute to this Element using the appropriate factory. If an attribute by that name is already present in this Element, it's value is changed to be that of the specified attribute's value. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
Parameters:
attribute - The attribute to create or update.
See Also:
getAttribute(java.lang.String), getAttributeNode(java.lang.String), setAttributeNode(org.w3c.dom.Attr)

setAttributeNode

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr attribute)
Adds a new attribute to this Element using the appropriate factory. If an attribute by that name is already present in this Element, it's value is changed to be that of the specified attribute's value. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Specified by:
setAttributeNode in interface org.w3c.dom.Element
Parameters:
attribute - The attribute to create or update.
Returns:
The attribute that was created or updated.
See Also:
getAttribute(java.lang.String), getAttributeNode(java.lang.String), setAttribute(java.lang.String, java.lang.String)

removeAttribute

public void removeAttribute(java.lang.String name)
Removes the attribute that matches the specified name from this Element. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Specified by:
removeAttribute in interface org.w3c.dom.Element
Parameters:
name - Attribute name to match against.
See Also:
removeAttributeNode(org.w3c.dom.Attr)

removeAttributeNode

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr attribute)
Removes the specified attribute from this Element. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Specified by:
removeAttributeNode in interface org.w3c.dom.Element
Parameters:
attribute - Attribute to remove.
Returns:
Removed attribute node.
See Also:
removeAttribute(java.lang.String)

resetDefaultAttribute

protected void resetDefaultAttribute(java.lang.String name)
Sets a default attribute if name has default value. This method is called by removeAttribute(), removeAttributeNode().
Parameters:
name - An attribute name
See Also:
removeAttribute(java.lang.String), removeAttributeNode(org.w3c.dom.Attr), TXDocument.isAddFixedAttributes()

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Returns a NamedNodeMap of the attributes of this Element. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.

This method is defined by DOM.

Returns:
A NamedNodeMap of attributes, or an empty NamedNodeMap is returned if no attributes.
Overrides:
getAttributes in class Child
See Also:
getAttributeArray(), attributeElements(), Parent.getChildNodes()

getAttributeArray

public TXAttribute[] getAttributeArray()
Returns a TXAttribute array of the attributes of this Element. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
Returns:
A TXAttribute array of attributes, or a 0-length array if no Attributes.
See Also:
getAttributes(), attributeElements()

attributeElements

public java.util.Enumeration attributeElements()
Returns an enumeration of TXAttribute of the attributes of this Element. Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
Returns:
An enumeration of TXAttribute Attributes, or null if no Attributes.
See Also:
getAttributes(), attributeElements()

getNSLocalName

public java.lang.String getNSLocalName()
Returns the local name of the Namespace.

This method is defined by Namespace.

Specified by:
getNSLocalName in interface Namespace
Returns:
The Namespace local name, or null if no local name.
See Also:
Namespace

getNSName

public java.lang.String getNSName()
Returns the Namespace URI.

This method is defined by Namespace.

Specified by:
getNSName in interface Namespace
Returns:
The Namespace URI, or null if the tag name does not belong to any namespace or XML4J parser namespace processing is disabled.
See Also:
getNamespaceForPrefix(java.lang.String), Parser.setProcessNamespace(boolean)

getUniversalName

public java.lang.String getUniversalName()
Deprecated. Use createExpandedName().
If namespace support is enabled and the Element's name contains a prefix name, return a string of getNSName()+":"+getNSLocalName(); otherwise, return getNSLocalName() .
Specified by:
getUniversalName in interface Namespace
Returns:
The universal name, or null if this Element's name does not contain a prefix name or XML4J parser namespace processing is disabled.
See Also:
getNSName(), getNSLocalName(), Parser.setProcessNamespace(boolean)

createExpandedName

public java.lang.String createExpandedName()
Returns an expanded name of this Element. The expanded name is a set of [a namespace URI, localPart] connected by TXDocument#expandedNameSeparator or localPart if this Element has no namespace.

This method is defined by Namespace.

Specified by:
createExpandedName in interface Namespace
See Also:
TXDocument.expandedNameSeparator, Parser.setProcessNamespace(boolean)

isEmpty

public boolean isEmpty()
Deprecated. Use hasChildNodes().
Returns whether this Element has any children.
Returns:
=true if this Element has no children; otherwise, =false.

isPreserveSpace

public boolean isPreserveSpace()
Returns, at the Element level, whether space is to be preserved. This value is used, for example, to determine if space is to be preserved in Text Nodes during printWithFormat() operations.
Returns:
=true space is to be preserved; =false space is to be ignored.
See Also:
setPreserveSpace(boolean), Parser.setPreserveSpace(boolean), TXText.setIsIgnorableWhitespace(boolean), TXDocument.printWithFormat(java.io.Writer)

setPreserveSpace

public void setPreserveSpace(boolean isPreserveSpace)
Sets, at the Element level, whether space is to be preserved. This value is used, for example, to determine if space is to be preserved in children of this Node during printWithFormat() operations.

By default, space is not preserved. The XML4J parser will override this value if it detects an attribute of xml:namespace="preserve".

Parameters:
isPreserveSpace - =true space is to be preserved; =false space is to be ignored.
See Also:
isPreserveSpace(), Parser.setPreserveSpace(boolean), TXText.setIsIgnorableWhitespace(boolean), TXDocument.printWithFormat(java.io.Writer)

getLanguage

public java.lang.String getLanguage()
Returns the XML language ID (the value of the xml:lang Attribute) in use for this Element Node. If this Element Node has no explicitly defined language Attribute, Parent Nodes will be recursively checked.
Returns:
The XML language ID, or null if all Parents have no language ID.
See Also:
getAttribute(java.lang.String)

normalize

public void normalize()
Puts all Text Nodes in the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, PIs, CDATASections, and entity references) separates Text Nodes. This has the effect of combining Text Nodes that have been separated due to document manipulation.

This method is defined by DOM.

Specified by:
normalize in interface org.w3c.dom.Element

addTextElement

public void addTextElement(TXText text)
Adds the specified text Node to the end of this Element. If the last child of this Element is a Text Node and not a CDATA section, text is appended to the last child. Otherwise, a new TXText Node is inserted at the end of this Element.
Parameters:
text - Text Node to add to this Element.
See Also:
Parent.addElement(com.ibm.xml.parser.Child)

searchDescendants

public TXElement searchDescendants(java.lang.String qName)
Returns the first TXElement match through all child Element Nodes. Searching is done recursively, not just for immediate Child Nodes. The specified qualified name refers to the Element tag name (see Namespace for details).
Parameters:
qName - Qualified name to match against in all subordinate Elements.
Returns:
The first matching TXElement Node, or null if no matches.
See Also:
getElementNamed(java.lang.String), getNthElementNamed(int, java.lang.String), Namespace

searchDescendants

public TXElement searchDescendants(int matchType,
                                   java.lang.String uri,
                                   java.lang.String qNameOrLocalName)
Returns the first TXElement match through all child Element Nodes. All specified input parameters must match for an element to be judged as matched (see Namespace for details). Various namespace matching algorithms are supported: qualified name, local name & URI, or URI. Searching is done recursively, not just for immediate Child Nodes.
Parameters:
matchType - Namespace match type: Match.QNAME, Match.NSLOCAL, Match.NS
uri - When matching a URI, specify the value to match; otherwise, specify null.
qNameOrLocalName - When matching a qualified name or local name, specify the value to match; otherwise, specify null.
Returns:
An array of matched TXElement Nodes, or null if no matches.
See Also:
getElementNamed(java.lang.String), getNthElementNamed(int, java.lang.String), Namespace

getElementNamed

public TXElement getElementNamed(java.lang.String qName)
Returns the first TXElement match through the immediate Child Element Nodes. Only immediate children are searched (i.e. no grandchildren). The specified qualified name refers to the Element tag name (see Namespace for details).
Parameters:
qName - Qualified name to match against in immediate children.
Returns:
The first matching TXElement Node, or null if no matches.
See Also:
searchDescendants(java.lang.String), getNthElementNamed(int, java.lang.String), Namespace

getElementNamed

public TXElement getElementNamed(java.lang.String uri,
                                 java.lang.String localName)
Returns the first TXElement match through the immediate child Element Nodes. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Only immediate children are searched (i.e. no grandchildren).
Parameters:
uri - The Namespace URI to match against in immediate children.
localName - The Namespace local name to match against in immediate children.
Returns:
The first matching TXElement Node, or null if no matches.
See Also:
searchDescendants(java.lang.String), getNthElementNamed(int, java.lang.String), Namespace

getElementNamed

public TXElement getElementNamed(int matchType,
                                 java.lang.String uri,
                                 java.lang.String qNameOrLocalName)
Returns the first TXElement match through the immediate child Elemen Nodes. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Various namespace matching algorithms are supported: qualified name, local name & URI, or URI. Only immediate children are searched (i.e. no grandchildren).
Parameters:
matchType - Namespace match type: Match.QNAME, Match.NSLOCAL, Match.NS
uri - When matching a URI, specify the value to match; otherwise, specify null.
qNameOrLocalName - When matching a qualified name or local name, specify the value to match; otherwise, specify null.
Returns:
An array of matched TXElement Nodes, or null if no matches.
See Also:
searchDescendants(java.lang.String), getNthElementNamed(int, java.lang.String), Namespace

getNthElementNamed

public TXElement getNthElementNamed(int nth,
                                    java.lang.String qName)
Returns the Nth TXElement match through the immediate child Element Nodes. Only immediate children are searched (i.e. no grandchildren). The specified qualified name refers to the Element tag name (see Namespace for details).
Example:
      <BODY>            --- this
        <H1>...</H1>    --- getNthElementNamed(0, "H1")
        <P>...</P>      --- getNthElementNamed(0, "P")
        <P>...</P>      --- getNthElementNamed(1, "P")
        <HR/>           --- getNthElementNamed(0, "HR");
        <P>...</P>      --- getNthElementNamed(2, "P")
        <HR/>           --- getNthElementNamed(1, "HR");
      </BODY>
    
Parameters:
nth - 0-based match occurrence.
qName - Qualified name to match against in immediate children.
Returns:
The Nth matching TXElement Node, or null if no matches.
See Also:
searchDescendants(java.lang.String), getElementNamed(java.lang.String), Namespace

getNthElementNamed

public TXElement getNthElementNamed(int nth,
                                    java.lang.String uri,
                                    java.lang.String localName)
Returns the Nth TXElement match through the immediate child Element Nodes. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Only immediate children are searched (i.e. no grandchildren).
Parameters:
nth - 0-based match occurrence.
uri - The Namespace URI to match against in immediate children.
localName - The Namespace local name to match against in immediate children.
Returns:
The Nth matching TXElement Node, or null if no matches.
See Also:
searchDescendants(java.lang.String), getElementNamed(java.lang.String), Namespace

getNthElementNamed

public TXElement getNthElementNamed(int nth,
                                    int matchType,
                                    java.lang.String uri,
                                    java.lang.String qNameOrLocalName)
Returns the Nth TXElement match through the immediate child Element Nodes. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Various namespace matching algorithms are supported: qualified name, local name & URI, or URI. Only immediate children are searched (i.e. no grandchildren).
Parameters:
matchType - Namespace match type: Match.QNAME, Match.NSLOCAL, Match.NS
uri - When matching a URI, specify the value to match; otherwise, specify null.
qNameOrLocalName - When matching a qualified name or local name, specify the value to match; otherwise, specify null.
Returns:
The Nth matching TXElement Node, or null if no matches.
See Also:
searchDescendants(java.lang.String), getElementNamed(java.lang.String), Namespace

searchChildrenAll

public TXElement[] searchChildrenAll(java.lang.String qName)
Returns an array of TXElement of matches through the immediate child Element Nodes. Only immediate children are searched (i.e. no grandchildren). The specified qualified name refers to the Element tag name (see Namespace for details).
Parameters:
qName - Qualified name to match against in immediate children.
Returns:
An array of matched TXElement Nodes. The array will be of length 0 if there are no matches.
See Also:
getElementsByTagName(java.lang.String), searchDescendantsAll(java.lang.String), getElementsNamed(java.lang.String), Namespace

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String qName)
Returns a NodeList of matches through all child Element Nodes. Searching is done recursively, not just for immediate Child Nodes. The specified qualified name refers to the Element tag name (see Namespace for details).

This method is defined by DOM.

Specified by:
getElementsByTagName in interface org.w3c.dom.Element
Parameters:
qName - Qualified name to match against in all subordinate Elements. If it is "*", this method return all subordinate Elements.
Returns:
A NodeList of matched Element Nodes (TXElement). If no matches, an empty NodeList is returned.
See Also:
searchChildrenAll(java.lang.String), searchDescendantsAll(java.lang.String), getElementsNamed(java.lang.String), Parent.getChildNodes(), Namespace

searchDescendantsAll

public TXElement[] searchDescendantsAll(java.lang.String qName)
Returns an array of TXElement matches through all child Element Nodes. Searching is done recursively, not just for immediate Child Nodes. The specified qualified name refers to the Element tag name (see Namespace for details).
Parameters:
qName - Qualified name to match against in all subordinate Elements.
Returns:
An array of matched TXElement Nodes. The array will be of length 0 if there are no matches.
See Also:
searchChildrenAll(java.lang.String), getElementsByTagName(java.lang.String), getElementsNamed(java.lang.String), Namespace

searchDescendantsAll

public TXElement[] searchDescendantsAll(int matchType,
                                        java.lang.String uri,
                                        java.lang.String qNameOrLocalName)
Returns an array of TXElement matches through all child Element Nodes. All specified input parameters must match for an element to be judged as matched (see Namespace for details). Various namespace matching algorithms are supported: qualified name, local name & URI, or URI. Searching is done recursively, not just for immediate Child Nodes.
Parameters:
matchType - Namespace match type: Match.QNAME, Match.NSLOCAL, Match.NS
uri - When matching a URI, specify the value to match; otherwise, specify null.
qNameOrLocalName - When matching a qualified name or local name, specify the value to match; otherwise, specify null.
Returns:
An array of matched TXElement Nodes. The array will be of length 0 if there are no matches.
See Also:
searchChildrenAll(java.lang.String), getElementsByTagName(java.lang.String), getElementsNamed(java.lang.String), Namespace

getElementsNamed

public org.w3c.dom.NodeList getElementsNamed(java.lang.String qName)
Returns a NodeList of all matches through the immediate child Element Nodes. Only immediate children are searched (i.e. no grandchildren). The specified qualified name refers to the Element tag name (see Namespace for details).
Parameters:
qName - Qualified name to match against in immediate children.
Returns:
A NodeList of matches, or an empty NodeList if no matches.
See Also:
searchChildrenAll(java.lang.String), getElementsByTagName(java.lang.String), searchDescendantsAll(java.lang.String), Parent.getChildNodes(), Namespace

getElementsNamed

public org.w3c.dom.NodeList getElementsNamed(java.lang.String uri,
                                             java.lang.String localName)
Returns a NodeList of matches through the immediate child Element Nodes. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Only immediate children are searched (i.e. no grandchildren).
Parameters:
uri - The Namespace URI to match against in immediate children.
localName - The Namespace local name to match against in immediate children.
Returns:
A TXElement of matches, or an empty NodeList if no matches.
See Also:
searchChildrenAll(java.lang.String), getElementsByTagName(java.lang.String), searchDescendantsAll(java.lang.String), Parent.getChildNodes(), Namespace

getElementsNamed

public org.w3c.dom.NodeList getElementsNamed(int matchType,
                                             java.lang.String uri,
                                             java.lang.String qNameOrLocalName)
Returns a NodeList of all matches through the immediate child Element Nodes. All specified input parameters must match for an Element to be judged as matched (see Namespace for details). Various namespace matching algorithms are supported: qualified name, local name & URI, or URI. Only immediate children are searched (i.e. no grandchildren).
Parameters:
matchType - Namespace match type: Match.QNAME, Match.NSLOCAL, Match.NS
uri - When matching a URI, specify the value to match; otherwise, specify null.
qNameOrLocalName - When matching a qualified name or local name, specify the value to match; otherwise, specify null.
Returns:
A NodeList of matches, or an empty NodeList if no matches.
See Also:
searchChildrenAll(java.lang.String), getElementsByTagName(java.lang.String), searchDescendantsAll(java.lang.String), Parent.getChildNodes(), Namespace

acceptPre

public void acceptPre(Visitor visitor)
               throws java.lang.Exception
Implements the accept operation of the visitor design pattern when the start of a TXElement Node is recognized when traversing the document object tree.
Parameters:
visitor - The implemention of the Visitor operation (toXMLString, digest, ...)
Throws:
java.lang.Exception - Thrown if this Node can not be visitted, or traversal modification is requested.
See Also:
Visitor, TreeTraversal, NonRecursivePreorderTreeTraversal, TreeTraversalException

acceptPost

public void acceptPost(Visitor visitor)
                throws java.lang.Exception
Implements the accept operation of the visitor design pattern when the end of a TXElement Node is recognized when traversing the document object tree.
Parameters:
visitor - The implemention of the Visitor operation (toXMLString, digest, ...)
Throws:
java.lang.Exception - Thrown if this Node can not be visitted, or traversal modification is requested.
See Also:
Visitor, TreeTraversal, NonRecursivePreorderTreeTraversal, TreeTraversalException

checkChildType

protected void checkChildType(org.w3c.dom.Node child)
                       throws org.w3c.dom.DOMException
Check whether child is allowed to be insered in this node or not. When not allowed, a DOMException with HIERARCHY_REQUEST_ERR is thrown.
Overrides:
checkChildType in class Parent

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
Returns a namespace URI for specified prefix.
namespace URI Stringfor valid prefix or no prefix with default namespace
""for no prefix and no default namespace
nullfor undefined prefix
Parameters:
prefix - Namespace prefix; null isn't allowed.

getNamespaceForQName

public java.lang.String getNamespaceForQName(java.lang.String qname)
Returns a namespace URI for specified qualified name.
Returns:
The same as getNamespaceForPrefix().
See Also:
getNamespaceForPrefix(java.lang.String)

getLocalNameForQName

public static java.lang.String getLocalNameForQName(java.lang.String qname)
Returns localPart(a name after a colon) of specified qualified name. If qname has no prefix, this method returns qname itself.

collectNamespaceAttributes

public void collectNamespaceAttributes()
Collect all xmlns: attributes in anchestors and set to this elemnent.
   <parent xmlns:foo="http://foo/">
     <foo:child/>
   </parent>
 

collectNamespaceAttributes() of foo:child element adds xmlns:foo="http://foo/" attribute to foo:child element.

This method is automatically called in TXElement#clone() and Parent#repalceChild() and Parent#removeChild().

See Also:
TXDocument.isProcessNamespace()

collectNamespaceAttributes

public void collectNamespaceAttributes(org.w3c.dom.Node parent)
Collect all xmlns: attributes in anchestors and set to this elemnent.
See Also:
TXDocument.isProcessNamespace()

removeOverlappedNamespaceAttributes

public void removeOverlappedNamespaceAttributes()
Remove overlapped xmlns: attributes. For example,
   <parent xmlns:foo="http://foo/">
     <child xmlns:bar="http://bar/" xmlns:foo="http://foo/"/>
   </parent>
 

By calling removeOverlappedNamespaceAttributes() of child element, xmlns:foo attribute of child element is removed.

This method isn't automatically called by all XML4J classes.

See Also:
TXDocument.isProcessNamespace()

XML for Java Compatibility API 2.0.15