XML for Java Compatibility API 2.0.6

com.ibm.xml.parser
Class ElementDecl

java.lang.Object
  |
  +--com.ibm.xml.parser.Child
        |
        +--com.ibm.xml.parser.ElementDecl
Direct Known Subclasses:
TreeFactory.TreeElementDecl

public class ElementDecl
extends Child

Element declarations in the DTD determine the possible structure of the XML document. The following structures, known as content models, are supported for element declaration:

EMPTY
This Element can not have any content, and must appear as an empty Element in the XML document. For example, the EMPTY element declaration <!ELEMENT graphic EMPTY> would have the Element tag <graphic/> appear in the XML document.
ANY
This Element can have any combination of character data and element types allow by the DTD.
#PCDATA
This Element must only contain character data. For example, the #PCDATA element declaration <!ELEMENT text (#PCDATA)> could have the Element tag <text>a group of character data</text> appear in the XML document.
MODEL_GROUP
This Element allows a mixture of #PCDATA and other Elements as their children. The following language primitives are used to help express this relationship:
( and )
Surround a sequence of alternatives
,
Separates each Element type in a sequence
|
Separates each Element type in a list of alternatives
? and *
Indicates that an Element or group occurs zero or more times
+
Indicates that an Element or group occurs one or more times

To illustrate this point, the element declaration <!ELEMENT memo (from, to+, cc*, date?, content)> could have the Element tag <memo> <from>me</from> <to>you</to> <to>and you</to> <content>hello world</content> </memo> appear in the XML document.

Version:
Revision: 63 1.5 src/com/ibm/xml/parser/ElementDecl.java, parser, xml4j2, xml4j2_0_6
See Also:
Child, Serialized Form

Field Summary
static int ANY
           
static int EMPTY
           
static int MODEL_GROUP
           
 
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
ElementDecl(java.lang.String name, ContentModel contentModel)
          Constructor.
 
Method Summary
 void acceptPost(Visitor visitor)
          Implements the accept operation of the visitor design pattern when the end of an ElementDecl 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 an ElementDecl Node is recognized when traversing the document object tree.
 java.lang.Object clone()
          Clone this element definition Node using the appropriate factory.
 boolean equals(org.w3c.dom.Node arg, boolean deep)
           
 int getContentType()
          Returns the content type which represents the content model used by this element definition.
 java.lang.String getName()
          Returns this element definition's name.
 java.lang.String getNodeName()
           
 short getNodeType()
          Returns that this object is an element definition Node.
 void setContentType(int contentType)
          Sets the content type which represents the content model used by this element definition.
 void setName(java.lang.String name)
          Sets this element definition's name.
 
Methods inherited from class com.ibm.xml.parser.Child
appendChild, clearDigest, cloneNode, getAttributes, getChildNodes, getDigest, getFactory, getFirstChild, getFirstWithoutReference, getLastChild, getLastWithoutReference, getNextSibling, getNextWithoutReference, getNodeValue, getOwnerDocument, getParentNode, getParentWithoutReference, getPreviousSibling, getPreviousWithoutReference, getText, getUserData, hasChildNodes, insertBefore, makeXPointer, print, print, removeChild, replaceChild, 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

EMPTY

public static final int EMPTY

ANY

public static final int ANY

MODEL_GROUP

public static final int MODEL_GROUP
Constructor Detail

ElementDecl

public ElementDecl(java.lang.String name,
                   ContentModel contentModel)
Constructor.
Parameters:
name - This element definition's name.
contentModel - The content model to associate with this element definition, or null if the content model is to be set later.
Method Detail

clone

public java.lang.Object clone()
Clone this element definition Node using the appropriate factory.

This method is defined by Child.

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

equals

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

getNodeType

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

This method is defined by DOM.

Returns:
Element definition Node indicator.

getNodeName

public java.lang.String getNodeName()

getName

public java.lang.String getName()
Returns this element definition's name.
Returns:
The string that is this Element's name, or null if no name.
See Also:
setName(java.lang.String)

setName

public void setName(java.lang.String name)
Sets this element definition's name.
Parameters:
name - The string that is this element definition's name.
See Also:
getName()

getContentType

public int getContentType()
Returns the content type which represents the content model used by this element definition.
Returns:
The content type for this element's definition, or null if no content type has been defined. Must be one of EMPTY/ANY/MODEL_GROUP.
See Also:
setContentType(int)

setContentType

public void setContentType(int contentType)
Sets the content type which represents the content model used by this element definition.
Parameters:
contentType - The content type for this element's definition. Must be one of EMPTY/ANY/MODEL_GROUP.
See Also:
getContentType()

acceptPre

public void acceptPre(Visitor visitor)
               throws java.lang.Exception
Implements the accept operation of the visitor design pattern when the start of an ElementDecl 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 an ElementDecl 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

XML for Java Compatibility API 2.0.6