Open SiteSearch 4.1.1
Final

ORG.oclc.xml.om
Interface Element

All Known Implementing Classes:
ElementImpl

public abstract interface Element

This interface implements an Element object. Each XML tag in a document is represented by an Element object in the XML parse tree. The elements are named with a string, have attributes, and can contain child nodes.

There are seven types of elements, DOCUMENT, ELEMENT, PCDATA, PI, META, COMMENT, and CDATA.


Field Summary
static int CDATA
          Raw character data specified with special CDATA construct: <![CDATA[...]]> where ...
static int COMMENT
          An XML comment ( <!-- ...
static int DOCUMENT
          Reserved for use by the Document node only.
static int DTD
          Reserved for use by the DTD node only.
static int ELEMENT
          A general container element having optional attributes and optional child elements.
static int ELEMENTDECL
          An element declaration node.
static int ENTITY
          An entity node.
static int ENTITYREF
          Entity reference nodes.
static int IGNORESECTION
          IGNORE conditional section
static int INCLUDESECTION
          INCLUDE conditional section
static int NAMESPACE
          A namespace node that declares new namespaces in the element tree.
static int NOTATION
          A notation node.
static int PCDATA
          A text element that has no children or attributes and that contains parsed character data.
static int PI
          A processing instruction node ( <? ...
static int WHITESPACE
          Ignorable white space between elements.
 
Method Summary
 void addChild(Element elem, Element after)
          Adds a child to this element.
 void addChild(Element elem, int pos, int reserved)
          Adds a child to this element.
 Object getAttribute(Name n)
          Retrieves an attribute's value given its name.
 Object getAttribute(String name)
          Retrieves an attribute's value given its name.
 Enumeration getAttributes()
          Retrieves an enumeration for the element attributes.
 Element getChild(int index)
          Retrieves the child element by index.
 ElementCollection getChildren()
          Returns an element collection of the children of this element.
 Enumeration getElements()
          Returns an enumeration of the children of this element.
 Element getParent()
          Retrieves the parent of this element.
 Name getTagName()
          Retrieves the name of the tag as a string.
 String getText()
          Returns the non-marked-up text contained by this element.
 int getType()
          Retrieves the type of the element.
 int numAttributes()
          Retrieves the number of attributes.
 int numElements()
          Retrieves the number of child elements.
 void removeAttribute(Name name)
          Deletes an attribute from an element.
 void removeAttribute(String name)
          Deletes an attribute from an element.
 void removeChild(Element elem)
          Removes a child element from the tree.
 void save(XMLOutputStream o)
          Saves this element.
 void setAttribute(Name name, Object value)
          Sets the attribute of this element.
 void setAttribute(String name, Object value)
          Sets the attribute of this element.
 void setParent(Element parent)
          Sets the parent of this element.
 void setText(String text)
          Sets the text for this element.
 Element toSchema()
          Returns the XML-DATA specification for the DTD element.
 

Field Detail

ELEMENT

public static final int ELEMENT
A general container element having optional attributes and optional child elements.

PCDATA

public static final int PCDATA
A text element that has no children or attributes and that contains parsed character data.

COMMENT

public static final int COMMENT
An XML comment ( <!-- ... --> ).

DOCUMENT

public static final int DOCUMENT
Reserved for use by the Document node only.

DTD

public static final int DTD
Reserved for use by the DTD node only.

PI

public static final int PI
A processing instruction node ( <? ... ?> ).

CDATA

public static final int CDATA
Raw character data specified with special CDATA construct: <![CDATA[...]]> where ... can be anything except ]]>, including HTML tags.

ENTITY

public static final int ENTITY
An entity node.

NOTATION

public static final int NOTATION
A notation node.

ELEMENTDECL

public static final int ELEMENTDECL
An element declaration node.

NAMESPACE

public static final int NAMESPACE
A namespace node that declares new namespaces in the element tree.

ENTITYREF

public static final int ENTITYREF
Entity reference nodes.

WHITESPACE

public static final int WHITESPACE
Ignorable white space between elements.

INCLUDESECTION

public static final int INCLUDESECTION
INCLUDE conditional section

IGNORESECTION

public static final int IGNORESECTION
IGNORE conditional section
Method Detail

getTagName

public Name getTagName()
Retrieves the name of the tag as a string. The string will be in uppercase.
Returns:
the tag name or null for DATA and PCDATA elements.

getType

public int getType()
Retrieves the type of the element. This is always one of the following values: DOCUMENT, ELEMENT, PCDATA, PI, META, COMMENT, or CDATA.
Returns:
element type.

getText

public String getText()
Returns the non-marked-up text contained by this element. For text elements, this is the raw data. For elements with child nodes, this traverses the entire subtree and appends the text for each terminal text element, effectively stripping out the XML markup for the subtree. For example, if the XML document contains the following: <AUTHOR> <FIRST>William</FIRST> <LAST>Shakespeare</LAST> </AUTHOR>

Document.getText returns "William Shakespeare".


setText

public void setText(String text)
Sets the text for this element. Only meaningful in CDATA, PCDATA, and COMMENT nodes.
Parameters:
text - The text to set.
Returns:
No return value.

getParent

public Element getParent()
Retrieves the parent of this element. Every element in the tree except the Document itself, has a parent.
Returns:
the parent element or null if at the root of the tree.

getElements

public Enumeration getElements()
Returns an enumeration of the children of this element. Enumeration.nextElement returns Element objects.
Returns:
an enumeration of child objects. It must not return null. See EnumWrapper for an easy way to return an empty enumeration.

getChildren

public ElementCollection getChildren()
Returns an element collection of the children of this element. It must not return null. See EnumWrapper for an emptyEnumeration.
Returns:
ElementCollection of child objects.

numElements

public int numElements()
Retrieves the number of child elements.
Returns:
the number of child elements.

addChild

public void addChild(Element elem,
                     Element after)
Adds a child to this element. Any element can only have one parent element and so the previous parent will lose this child from its subtree.
Parameters:
elem - The element to add. The child element becomes the last element if after is null. The child is added to the beginning of the list if after is this object.
after - The element after which to add it.
Returns:
No return value.

addChild

public void addChild(Element elem,
                     int pos,
                     int reserved)
Adds a child to this element.
Parameters:
elem - The element to add.
pos - The position to add this element (calling getChild(pos) will return this element). If pos is less than 0, elem becomes the new last element.
reserved - The reserved parameter.
Returns:
No return value.

getChild

public Element getChild(int index)
Retrieves the child element by index.
Parameters:
index - The index of the child element.
Returns:
null if there is no child by that index.

removeChild

public void removeChild(Element elem)
Removes a child element from the tree.
Parameters:
elem - The element to remove.

getAttributes

public Enumeration getAttributes()
Retrieves an enumeration for the element attributes. The enumeration returns Attribute objects.
Returns:
the enumeration. It must not return null (see EnumWrapper for returning empty enumerations).
See Also:
Attribute

numAttributes

public int numAttributes()
Retrieves the number of attributes.
Returns:
the number of attributes.

getAttribute

public Object getAttribute(String name)
Retrieves an attribute's value given its name.
Parameters:
name - The name of the attribute.
Returns:
the value of the attribute or null if the attribute is not found.

getAttribute

public Object getAttribute(Name n)
Retrieves an attribute's value given its name.
Parameters:
name - The name of the attribute.
Returns:
the value of the attribute or null if the attribute is not found.

setAttribute

public void setAttribute(String name,
                         Object value)
Sets the attribute of this element.
Parameters:
name - The attribute name.
value - The attribute value.

setAttribute

public void setAttribute(Name name,
                         Object value)
Sets the attribute of this element.
Parameters:
name - The attribute name.
value - The attribute value.

removeAttribute

public void removeAttribute(String name)
Deletes an attribute from an element.
Parameters:
name - The attribute to delete.
Returns:
No return value.

removeAttribute

public void removeAttribute(Name name)
Deletes an attribute from an element.
Parameters:
name - The attribute to delete.
Returns:
No return value.

setParent

public void setParent(Element parent)
Sets the parent of this element.
Parameters:
parent - The element to set as parent.
Returns:
No return value.

toSchema

public Element toSchema()
Returns the XML-DATA specification for the DTD element. (Only applies to ElementDecl and Entity nodes). This is DTD information represented in an XML Object Model. See Specification for XML-Data for details.

save

public void save(XMLOutputStream o)
          throws IOException
Saves this element.
Parameters:
o - The output stream to save to.
Returns:
No return value.
Throws:
IOException - if there is a problem saving the output.

Open SiteSearch 4.1.1
Final