XML for Java Compatibility API 2.0.15

com.ibm.xml.parser
Class Attlist

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

public class Attlist
extends Child

The Attlist class provides services in support of DTD attribute list declarations.

We will use the following example to illustrate the capabilities of attribute lists within a PERSON Element:

 <!ATTLIST PERSON
   EMPLOYEETYPE CDATA "PERMANENT"
   LASTNAME CDATA #REQUIRED
   PHONE ENTITY #IMPLIED
   COMPANY CDATA #FIXED "IBM" >
 

In this example, the attributes EMPLOYEETYPE and COMPANY have been assigned default values; EMPLOYEETYPE's default value may be changed, but COMPANY's value is fixed and may not be changed.

The LASTNAME attribute must be specified with each PERSON Element because this attribute is defined as REQUIRED.

Just because an attribute is not defined by the attribute list definition, it does not mean that the attribute can not be defined in the document. These attributes are known as IMPLIED attributes. However, you will need to explicitly define IMPLIED attributes if you want them to have a value type other than CDATA.

Value types are defined as follows:

CDATA
A string-type attribute that can take any literal string as its value.
ID
An unique identifier for an Element within a given XML document.
IDREF
A pointer to an Element's ID within a given XML document.
IDREFS
Same as IDREF except multiple pointers may be provided.
ENTITY
A pointer to an external binary general entity (see Entity for details) defined in this DTD.
ENTITIES
Same as ENTITY except multiple pointers may be provided.
NMTOKEN
Also known as a name token. This is any mixture of name characters.
NMTOKENS
Same as NMTOKEN except multiple names may be provided.
NOTATION
A set of notations (see TXNotation for details) that are declared in this DTD.
NAME_TOKEN_GROUP
A set of NMTOKEN tokens.

Version:
Revision: 55 1.5 src/com/ibm/xml/parser/Attlist.java, parser, xml4j2, xml4j2_0_15
See Also:
AttDef, Child, EntityDecl, ExternalID, TXNotation, Serialized Form

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
Attlist(java.lang.String name)
          Constructor.
 
Method Summary
 void acceptPost(Visitor visitor)
          Implements the accept operation of the visitor design pattern when the end of an Attlist 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 Attlist Node is recognized when traversing the document object tree.
 boolean addElement(AttDef attDef)
          Adds the specified attribute definition to the end of this attribute list .
 java.lang.Object clone()
          Clone this attribute list Node and its children (AttDefs) using the appropriate factory.
 boolean contains(java.lang.String attDefName)
          Returns whether the specified attribute definition name is currently defined in this attribute list.
 AttDef elementAt(int index)
          Returns the attribute definition at the specified index in this attribute list
 java.util.Enumeration elements()
          Returns an enumeration of all attribute definitions in this attribute list.
 boolean equals(org.w3c.dom.Node arg, boolean deep)
           
 AttDef getAttDef(java.lang.String attDefName)
          Returns the attribute definition that matches the specified attribute definition name in this attribute list.
 java.lang.String getName()
          Returns this attribute list's name; this value is also known as the Element type.
 java.lang.String getNodeName()
           
 short getNodeType()
          Returns that this object is an attribute list Node.
 int size()
          Returns the number of attribute definitions in this attribute list.
 
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
 

Constructor Detail

Attlist

public Attlist(java.lang.String name)
Constructor.
Parameters:
name - This attribute list's name; this value is also known as the Element type.
Method Detail

clone

public java.lang.Object clone()
Clone this attribute list Node and its children (AttDefs) using the appropriate factory.
Returns:
Cloned attribute list Node.
Overrides:
clone in class Child

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 attribute list Node.

This method is defined by DOM.

Returns:
Element Node indicator.

getNodeName

public java.lang.String getNodeName()

getName

public java.lang.String getName()
Returns this attribute list's name; this value is also known as the Element type.
Returns:
The string that is this attribute list's name, or null if no name.

addElement

public boolean addElement(AttDef attDef)
Adds the specified attribute definition to the end of this attribute list .
Parameters:
attDef - Attribute definition to add to this atribute list.
Returns:
=true if the attribute definition does not already exist in this attribute list; otherwise, =false.
See Also:
elementAt(int), getAttDef(java.lang.String), contains(java.lang.String), size()

elementAt

public AttDef elementAt(int index)
Returns the attribute definition at the specified index in this attribute list
Parameters:
index - Index into this list of attribute definitions.
Returns:
Attribute definition at the specified index, or null if an invalid index.
See Also:
addElement(com.ibm.xml.parser.AttDef), getAttDef(java.lang.String), contains(java.lang.String), size()

getAttDef

public AttDef getAttDef(java.lang.String attDefName)
Returns the attribute definition that matches the specified attribute definition name in this attribute list.
Parameters:
attDefName - Attribute definition name to match in this attribute list.
Returns:
The matching attribute definition, or null if the attribute is not currently defined.
See Also:
addElement(com.ibm.xml.parser.AttDef), elementAt(int), contains(java.lang.String), size(), elements()

contains

public boolean contains(java.lang.String attDefName)
Returns whether the specified attribute definition name is currently defined in this attribute list.
Parameters:
attDefName - Attribute definition name to match in this attribute list.
Returns:
=true if attDefName is defined; otherwise, =false.
See Also:
addElement(com.ibm.xml.parser.AttDef), elementAt(int), getAttDef(java.lang.String), size(), elements()

size

public int size()
Returns the number of attribute definitions in this attribute list.
Returns:
Number of attribute list definitions, or null if no definitions defined.
See Also:
addElement(com.ibm.xml.parser.AttDef), elementAt(int), getAttDef(java.lang.String), contains(java.lang.String)

elements

public java.util.Enumeration elements()
Returns an enumeration of all attribute definitions in this attribute list.
Returns:
An enumeration of all attribute definitions, or null if none specified.
See Also:
addElement(com.ibm.xml.parser.AttDef), elementAt(int), getAttDef(java.lang.String), contains(java.lang.String), size()

acceptPre

public void acceptPre(Visitor visitor)
               throws java.lang.Exception
Implements the accept operation of the visitor design pattern when the start of an Attlist 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 visited, 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 Attlist 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 visited, or traversal modification is requested.
See Also:
Visitor, TreeTraversal, NonRecursivePreorderTreeTraversal, TreeTraversalException

XML for Java Compatibility API 2.0.15