|
XML Parser for Java 1.1.9 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.parser.Child | +--com.ibm.xml.parser.Parent | +--com.ibm.xml.parser.TXElement
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.
Element
,
Namespace
,
Parent
,
Child
, Serialized FormField 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(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. |
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(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(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 . |
Attr |
getAttributeNode(java.lang.String name)
Returns an attribute's value from this Element that matches the specified
attribute name. |
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. |
NodeList |
getElementsByTagName(java.lang.String qName)
Returns a NodeList of matches through all child Element Nodes. |
NodeList |
getElementsNamed(int matchType,
java.lang.String uri,
java.lang.String qNameOrLocalName)
Returns a NodeList of all matches through the immediate child Element Nodes. |
NodeList |
getElementsNamed(java.lang.String qName)
Returns a NodeList of all matches through the immediate child Element Nodes. |
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 . |
Attr |
removeAttributeNode(Attr attribute)
Removes the specified attribute from this Element . |
void |
removeOverlappedNamespaceAttributes()
Remove overlapped xmlns: attributes. |
protected void |
resetDefaultAttribute(java.lang.String name)
Called in removeAttribute()/removeAttributeNode(). |
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() |
Attr |
setAttributeNode(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,
makeXPointer,
print,
print,
searchAncestors,
searchAncestors,
setFactory,
setNodeValue,
toXMLString,
toXMLString |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String S_XMLNS
public static final java.lang.String S_XMLNAMESPACEURI
Constructor Detail |
public TXElement(java.lang.String tagName)
tagName
- this Element
's tag name (qualified name).
In the example <elementExample id="demo"> ... </elementExample>
,
the tag name is elementExample
.Method Detail |
public java.lang.Object clone()
Element
Node and its children using the appropriate factories.
This method is defined by Child.
Child.clone()
public TXElement cloneWithoutChildren()
Element
Node using the appropriate factory.public Node cloneNode(boolean deep)
public boolean equals(Node arg, boolean deep)
public short getNodeType()
This method is defined by DOM.
public java.lang.String getNodeName()
getTagName()
,
getName()
public java.lang.String getTagName()
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.
Element
's name, or null if no name.setTagName(java.lang.String)
,
getName()
,
getNodeName()
public java.lang.String getName()
Element
's name.
This method is equivalent to getTagName()
.Element
's name, or null if no name.getTagName()
,
setTagName(java.lang.String)
public void setTagName(java.lang.String tagName)
Element
's name.
In the example <elementExample id="demo"> ... </elementExample>
,
the tag name is elementExample
.tagName
- The string that is this Element
's name.getTagName()
public java.lang.String getAttribute(java.lang.String name)
Element
that matches the specified
attribute name.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
This method is defined by DOM.
name
- The name to match in this Element
's list of attributes.getAttributeNode(java.lang.String)
,
setAttribute(java.lang.String, java.lang.String)
,
setAttributeNode(org.w3c.dom.Attr)
,
getLanguage()
public Attr getAttributeNode(java.lang.String name)
Element
that matches the specified
attribute name.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
This method is defined by DOM.
name
- The name to match in this Element
's list of attributes.getAttribute(java.lang.String)
,
setAttribute(java.lang.String, java.lang.String)
,
setAttributeNode(org.w3c.dom.Attr)
public void setAttribute(java.lang.String name, java.lang.String value) throws DOMException
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.
name
- The name of the attribute to create or update.value
- The value of the created or updated attribute.getAttribute(java.lang.String)
,
getAttributeNode(java.lang.String)
,
setAttributeNode(org.w3c.dom.Attr)
public void setAttribute(TXAttribute attribute)
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.attribute
- The attribute to create or update.getAttribute(java.lang.String)
,
getAttributeNode(java.lang.String)
,
setAttributeNode(org.w3c.dom.Attr)
public Attr setAttributeNode(Attr attribute)
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.
attribute
- The attribute to create or update.getAttribute(java.lang.String)
,
getAttributeNode(java.lang.String)
,
setAttribute(java.lang.String, java.lang.String)
public void removeAttribute(java.lang.String name)
Element
.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
This method is defined by DOM.
name
- Attribute name to match against.removeAttributeNode(org.w3c.dom.Attr)
public Attr removeAttributeNode(Attr attribute)
Element
.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
This method is defined by DOM.
attribute
- Attribute to remove.removeAttribute(java.lang.String)
protected void resetDefaultAttribute(java.lang.String name)
name
- An attribute namepublic NamedNodeMap getAttributes()
Element
.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.
This method is defined by DOM.
getAttributeArray()
,
attributeElements()
,
Parent.getChildNodes()
public TXAttribute[] getAttributeArray()
TXAttribute
array of the attributes of this Element
.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.TXAttribute
array of attributes, or a 0-length array if no Attributes.getAttributes()
,
attributeElements()
public java.util.Enumeration attributeElements()
TXAttribute
of the attributes of this Element
.
Both implicitly-defined (DTD) and explicitly-defined attributes are considered.getAttributes()
,
attributeElements()
public java.lang.String getNSLocalName()
This method is defined by Namespace.
Namespace
public java.lang.String getNSName()
This method is defined by Namespace.
getNamespaceForPrefix(java.lang.String)
,
Parser.setProcessNamespace(boolean)
public java.lang.String getUniversalName()
getNSName()+":"+getNSLocalName()
; otherwise, return getNSLocalName()
.Element
's name does not
contain a prefix name or XML4J parser namespace processing is disabled.getNSName()
,
getNSLocalName()
,
Parser.setProcessNamespace(boolean)
public java.lang.String createExpandedName()
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.
TXDocument.expandedNameSeparator
,
Parser.setProcessNamespace(boolean)
public boolean isEmpty()
Element
has any children.Element
has no children; otherwise, =false.public boolean isPreserveSpace()
=true
space is to be preserved;
=false
space is to be ignored.setPreserveSpace(boolean)
,
Parser.setPreserveSpace(boolean)
,
TXText.setIsIgnorableWhitespace(boolean)
,
TXDocument.printWithFormat(java.io.Writer)
public void setPreserveSpace(boolean isPreserveSpace)
By default, space is not preserved. The XML4J parser will override this value
if it detects an attribute of xml:namespace="preserve"
.
isPreserveSpace
- =true
space is to be preserved;
=false
space is to be ignored.isPreserveSpace()
,
Parser.setPreserveSpace(boolean)
,
TXText.setIsIgnorableWhitespace(boolean)
,
TXDocument.printWithFormat(java.io.Writer)
public java.lang.String getLanguage()
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.getAttribute(java.lang.String)
public void normalize()
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.
public void addTextElement(TXText text)
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.text
- Text Node to add to this Element
.Parent.addElement(com.ibm.xml.parser.Child)
public TXElement searchDescendants(java.lang.String qName)
qName
- Qualified name to match against in all subordinate Elements.getElementNamed(java.lang.String)
,
getNthElementNamed(int, java.lang.String)
,
Namespace
public TXElement searchDescendants(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
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.getElementNamed(java.lang.String)
,
getNthElementNamed(int, java.lang.String)
,
Namespace
public TXElement getElementNamed(java.lang.String qName)
qName
- Qualified name to match against in immediate children.searchDescendants(java.lang.String)
,
getNthElementNamed(int, java.lang.String)
,
Namespace
public TXElement getElementNamed(java.lang.String uri, java.lang.String localName)
uri
- The Namespace URI to match against in immediate children.localName
- The Namespace local name to match against in immediate children.searchDescendants(java.lang.String)
,
getNthElementNamed(int, java.lang.String)
,
Namespace
public TXElement getElementNamed(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
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.searchDescendants(java.lang.String)
,
getNthElementNamed(int, java.lang.String)
,
Namespace
public TXElement getNthElementNamed(int nth, java.lang.String qName)
<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>
nth
- 0-based match occurrence.qName
- Qualified name to match against in immediate children.searchDescendants(java.lang.String)
,
getElementNamed(java.lang.String)
,
Namespace
public TXElement getNthElementNamed(int nth, java.lang.String uri, java.lang.String localName)
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.searchDescendants(java.lang.String)
,
getElementNamed(java.lang.String)
,
Namespace
public TXElement getNthElementNamed(int nth, int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
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.searchDescendants(java.lang.String)
,
getElementNamed(java.lang.String)
,
Namespace
public TXElement[] searchChildrenAll(java.lang.String qName)
qName
- Qualified name to match against in immediate children.getElementsByTagName(java.lang.String)
,
searchDescendantsAll(java.lang.String)
,
getElementsNamed(java.lang.String)
,
Namespace
public NodeList getElementsByTagName(java.lang.String qName)
This method is defined by DOM.
qName
- Qualified name to match against in all subordinate Elements. If it is "*", this method return all subordinate Elements.searchChildrenAll(java.lang.String)
,
searchDescendantsAll(java.lang.String)
,
getElementsNamed(java.lang.String)
,
Parent.getChildNodes()
,
Namespace
public TXElement[] searchDescendantsAll(java.lang.String qName)
qName
- Qualified name to match against in all subordinate Elements.searchChildrenAll(java.lang.String)
,
getElementsByTagName(java.lang.String)
,
getElementsNamed(java.lang.String)
,
Namespace
public TXElement[] searchDescendantsAll(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
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.searchChildrenAll(java.lang.String)
,
getElementsByTagName(java.lang.String)
,
getElementsNamed(java.lang.String)
,
Namespace
public NodeList getElementsNamed(java.lang.String qName)
qName
- Qualified name to match against in immediate children.searchChildrenAll(java.lang.String)
,
getElementsByTagName(java.lang.String)
,
searchDescendantsAll(java.lang.String)
,
Parent.getChildNodes()
,
Namespace
public NodeList getElementsNamed(java.lang.String uri, java.lang.String localName)
uri
- The Namespace URI to match against in immediate children.localName
- The Namespace local name to match against in immediate children.searchChildrenAll(java.lang.String)
,
getElementsByTagName(java.lang.String)
,
searchDescendantsAll(java.lang.String)
,
Parent.getChildNodes()
,
Namespace
public NodeList getElementsNamed(int matchType, java.lang.String uri, java.lang.String qNameOrLocalName)
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.searchChildrenAll(java.lang.String)
,
getElementsByTagName(java.lang.String)
,
searchDescendantsAll(java.lang.String)
,
Parent.getChildNodes()
,
Namespace
public void acceptPre(Visitor visitor) throws java.lang.Exception
visitor
- The implemention of the Visitor operation (toXMLString, digest, ...)Visitor
,
TreeTraversal
,
NonRecursivePreorderTreeTraversal
,
TreeTraversalException
public void acceptPost(Visitor visitor) throws java.lang.Exception
visitor
- The implemention of the Visitor operation (toXMLString, digest, ...)Visitor
,
TreeTraversal
,
NonRecursivePreorderTreeTraversal
,
TreeTraversalException
protected void checkChildType(Node child) throws DOMException
public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
namespace URI String | for valid prefix or no prefix with default namespace |
"" | for no prefix and no default namespace |
null | for undefined prefix |
prefix
- Namespace prefix; null isn't allowed.public java.lang.String getNamespaceForQName(java.lang.String qname)
getNamespaceForPrefix(java.lang.String)
public static java.lang.String getLocalNameForQName(java.lang.String qname)
public void collectNamespaceAttributes()
<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()
.
TXDocument.isProcessNamespace()
public void collectNamespaceAttributes(Node parent)
TXDocument.isProcessNamespace()
public void removeOverlappedNamespaceAttributes()
<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.
TXDocument.isProcessNamespace()
|
XML Parser for Java 1.1.9 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |