com.sun.xml.stream.dtd.nonvalidating
Class DTDGrammar

java.lang.Object
  extended by com.sun.xml.stream.dtd.nonvalidating.DTDGrammar

public class DTDGrammar
extends java.lang.Object

A DTD grammar. This class implements the XNI handler interfaces for DTD information so that it can build the approprate validation structures automatically from the callbacks.

Version:
$Id: DTDGrammar.java,v 1.3 2007-07-19 22:33:13 ofung Exp $
Author:
Eric Ye, IBM, Jeffrey Rodriguez, IBM, Andy Clark, IBM, Neil Graham, IBM

Nested Class Summary
protected static class DTDGrammar.QNameHashtable
          A simple Hashtable implementation that takes a tuple (String, String) as the key and a int as value.
 
Field Summary
protected  XMLAttributeDecl fAttributeDecl
          Temporary Attribute decl.
protected  int fCurrentAttributeIndex
          Current attribute index.
protected  int fCurrentElementIndex
          Current element index.
protected  org.apache.xerces.xni.parser.XMLDTDContentModelSource fDTDContentModelSource
           
protected  org.apache.xerces.xni.parser.XMLDTDSource fDTDSource
           
protected  boolean fReadingExternalDTD
          fReadingExternalDTD
static int TOP_LEVEL_SCOPE
          Top level scope (-1).
 
Constructor Summary
DTDGrammar(org.apache.xerces.util.SymbolTable symbolTable)
          Default constructor.
 
Method Summary
 void attributeDecl(java.lang.String elementName, java.lang.String attributeName, java.lang.String type, java.lang.String[] enumeration, java.lang.String defaultType, org.apache.xerces.xni.XMLString defaultValue, org.apache.xerces.xni.XMLString nonNormalizedDefaultValue, org.apache.xerces.xni.Augmentations augs)
          An attribute declaration.
protected  int createAttributeDecl()
           
protected  int createElementDecl()
           
 void elementDecl(java.lang.String name, java.lang.String contentModel, org.apache.xerces.xni.Augmentations augs)
          An element declaration.
 void endDTD(org.apache.xerces.xni.Augmentations augs)
           
 boolean getAttributeDecl(int attributeDeclIndex, XMLAttributeDecl attributeDecl)
          getAttributeDecl
 int getAttributeDeclIndex(int elementDeclIndex, java.lang.String attributeDeclName)
           
 short getContentSpecType(int elementIndex)
          make separate function for getting contentSpecType of element.
 boolean getElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)
          getElementDecl
 int getElementDeclIndex(org.apache.xerces.xni.QName elementDeclQName)
          Returns the element decl index.
 int getElementDeclIndex(java.lang.String elementDeclName)
          getElementDeclIndex
 int getFirstAttributeDeclIndex(int elementDeclIndex)
          getFirstAttributeDeclIndex
 int getFirstElementDeclIndex()
          Returns the index of the first element declaration.
 int getNextAttributeDeclIndex(int attributeDeclIndex)
          getNextAttributeDeclIndex
 int getNextElementDeclIndex(int elementDeclIndex)
          Returns the next index of the element declaration following the specified element declaration.
 java.util.List getNotationDecls()
           
 org.apache.xerces.util.SymbolTable getSymbolTable()
          Returns the symbol table.
 boolean isCDATAAttribute(org.apache.xerces.xni.QName elName, org.apache.xerces.xni.QName atName)
          Returns whether the given attribute is of type CDATA or not
 void notationDecl(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, org.apache.xerces.xni.Augmentations augs)
           
 void printAttributes(int elementDeclIndex)
           
 void printElements()
           
protected  void setAttributeDecl(int elementDeclIndex, int attributeDeclIndex, XMLAttributeDecl attributeDecl)
           
protected  void setElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)
           
protected  void setFirstAttributeDeclIndex(int elementDeclIndex, int newFirstAttrIndex)
           
 void startDTD(org.apache.xerces.xni.XMLLocator locator, org.apache.xerces.xni.Augmentations augs)
          The start of the DTD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP_LEVEL_SCOPE

public static final int TOP_LEVEL_SCOPE
Top level scope (-1).

See Also:
Constant Field Values

fDTDSource

protected org.apache.xerces.xni.parser.XMLDTDSource fDTDSource

fDTDContentModelSource

protected org.apache.xerces.xni.parser.XMLDTDContentModelSource fDTDContentModelSource

fCurrentElementIndex

protected int fCurrentElementIndex
Current element index.


fCurrentAttributeIndex

protected int fCurrentAttributeIndex
Current attribute index.


fReadingExternalDTD

protected boolean fReadingExternalDTD
fReadingExternalDTD


fAttributeDecl

protected XMLAttributeDecl fAttributeDecl
Temporary Attribute decl.

Constructor Detail

DTDGrammar

public DTDGrammar(org.apache.xerces.util.SymbolTable symbolTable)
Default constructor.

Method Detail

getAttributeDeclIndex

public int getAttributeDeclIndex(int elementDeclIndex,
                                 java.lang.String attributeDeclName)

startDTD

public void startDTD(org.apache.xerces.xni.XMLLocator locator,
                     org.apache.xerces.xni.Augmentations augs)
              throws org.apache.xerces.xni.XNIException
The start of the DTD.

Parameters:
locator - The document locator, or null if the document location cannot be reported during the parsing of the document DTD. However, it is strongly recommended that a locator be supplied that can at least report the base system identifier of the DTD.
augs - Additional information that may include infoset augmentations.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

elementDecl

public void elementDecl(java.lang.String name,
                        java.lang.String contentModel,
                        org.apache.xerces.xni.Augmentations augs)
                 throws org.apache.xerces.xni.XNIException
An element declaration.

Parameters:
name - The name of the element.
contentModel - The element content model.
augs - Additional information that may include infoset augmentations.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

attributeDecl

public void attributeDecl(java.lang.String elementName,
                          java.lang.String attributeName,
                          java.lang.String type,
                          java.lang.String[] enumeration,
                          java.lang.String defaultType,
                          org.apache.xerces.xni.XMLString defaultValue,
                          org.apache.xerces.xni.XMLString nonNormalizedDefaultValue,
                          org.apache.xerces.xni.Augmentations augs)
                   throws org.apache.xerces.xni.XNIException
An attribute declaration.

Parameters:
elementName - The name of the element that this attribute is associated with.
attributeName - The name of the attribute.
type - The attribute type. This value will be one of the following: "CDATA", "ENTITY", "ENTITIES", "ENUMERATION", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", or "NOTATION".
enumeration - If the type has the value "ENUMERATION", this array holds the allowed attribute values; otherwise, this array is null.
defaultType - The attribute default type. This value will be one of the following: "#FIXED", "#IMPLIED", "#REQUIRED", or null.
defaultValue - The attribute default value, or null if no default value is specified.
nonNormalizedDefaultValue - The attribute default value with no normalization performed, or null if no default value is specified.
augs - Additional information that may include infoset augmentations.
Throws:
org.apache.xerces.xni.XNIException - Thrown by handler to signal an error.

getSymbolTable

public org.apache.xerces.util.SymbolTable getSymbolTable()
Returns the symbol table.


getFirstElementDeclIndex

public int getFirstElementDeclIndex()
Returns the index of the first element declaration. This index is then used to query more information about the element declaration.

See Also:
getNextElementDeclIndex(int), getElementDecl(int, com.sun.xml.stream.dtd.nonvalidating.XMLElementDecl)

getNextElementDeclIndex

public int getNextElementDeclIndex(int elementDeclIndex)
Returns the next index of the element declaration following the specified element declaration.

Parameters:
elementDeclIndex - The element declaration index.

getElementDeclIndex

public int getElementDeclIndex(java.lang.String elementDeclName)
getElementDeclIndex

Parameters:
elementDeclName -
Returns:
index of the elementDeclName in scope

getElementDeclIndex

public int getElementDeclIndex(org.apache.xerces.xni.QName elementDeclQName)
Returns the element decl index.

Parameters:
elementDeclQName - qualilfied name of the element

getContentSpecType

public short getContentSpecType(int elementIndex)
make separate function for getting contentSpecType of element. we can avoid setting of the element values.


getElementDecl

public boolean getElementDecl(int elementDeclIndex,
                              XMLElementDecl elementDecl)
getElementDecl

Parameters:
elementDeclIndex -
elementDecl - The values of this structure are set by this call.
Returns:
True if find the element, False otherwise.

getFirstAttributeDeclIndex

public int getFirstAttributeDeclIndex(int elementDeclIndex)
getFirstAttributeDeclIndex

Parameters:
elementDeclIndex -
Returns:
index of the first attribute for element declaration elementDeclIndex

getNextAttributeDeclIndex

public int getNextAttributeDeclIndex(int attributeDeclIndex)
getNextAttributeDeclIndex

Parameters:
attributeDeclIndex -
Returns:
index of the next attribute of the attribute at attributeDeclIndex

getAttributeDecl

public boolean getAttributeDecl(int attributeDeclIndex,
                                XMLAttributeDecl attributeDecl)
getAttributeDecl

Parameters:
attributeDeclIndex -
attributeDecl - The values of this structure are set by this call.
Returns:
true if getAttributeDecl was able to fill in the value of attributeDecl

isCDATAAttribute

public boolean isCDATAAttribute(org.apache.xerces.xni.QName elName,
                                org.apache.xerces.xni.QName atName)
Returns whether the given attribute is of type CDATA or not

Parameters:
elName - The element name.
atName - The attribute name.
Returns:
true if the attribute is of type CDATA

printElements

public void printElements()

printAttributes

public void printAttributes(int elementDeclIndex)

createElementDecl

protected int createElementDecl()

setElementDecl

protected void setElementDecl(int elementDeclIndex,
                              XMLElementDecl elementDecl)

setFirstAttributeDeclIndex

protected void setFirstAttributeDeclIndex(int elementDeclIndex,
                                          int newFirstAttrIndex)

createAttributeDecl

protected int createAttributeDecl()

setAttributeDecl

protected void setAttributeDecl(int elementDeclIndex,
                                int attributeDeclIndex,
                                XMLAttributeDecl attributeDecl)

notationDecl

public void notationDecl(java.lang.String name,
                         org.apache.xerces.xni.XMLResourceIdentifier identifier,
                         org.apache.xerces.xni.Augmentations augs)
                  throws org.apache.xerces.xni.XNIException
Throws:
org.apache.xerces.xni.XNIException

getNotationDecls

public java.util.List getNotationDecls()

endDTD

public void endDTD(org.apache.xerces.xni.Augmentations augs)
            throws org.apache.xerces.xni.XNIException
Throws:
org.apache.xerces.xni.XNIException


Copyright ? 2002-2003 Apache XML Project. All Rights Reserved.