org.apache.xerces.impl.validation
Class Grammar

java.lang.Object
  |
  +--org.apache.xerces.impl.validation.Grammar
Direct Known Subclasses:
DTDGrammar, SchemaGrammar

public abstract class Grammar
extends java.lang.Object

A generic grammar for use in validating XML documents. The Grammar object stores the validation information in a compiled form. Specific subclasses extend this class and "populate" the grammar by compiling the specific syntax (DTD, Schema, etc) into the data structures used by this object.

Note: The Grammar object is not useful as a generic grammar access or query object. In other words, you cannot round-trip specific grammar syntaxes with the compiled grammar information in the Grammar object. You can create equivalent validation rules in your choice of grammar syntax but there is no guarantee that the input and output will be the same.

Version:
$Id: Grammar.java,v 1.1.2.33 2001/07/16 08:09:35 andyc Exp $
Author:
Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000, Jeffrey Rodriguez, IBM, Eric Ye, IBM, Andy Clark, IBM

Inner Class Summary
protected static class Grammar.TupleHashtable
          A simple Hashtable implementation that takes a tuple (int, String, String) as the key and a int as value.
 
Field Summary
protected  XMLAttributeDecl fAttributeDecl
          Temporary Attribute decl.
static int TOP_LEVEL_SCOPE
          Top level scope (-1).
 
Constructor Summary
protected Grammar(SymbolTable symbolTable)
          Default constructor.
 
Method Summary
protected  int createAttributeDecl()
           
protected  int createContentSpec()
           
protected  int createElementDecl()
           
protected  int createEntityDecl()
           
protected  int createNotationDecl()
           
 boolean getAttributeDecl(int attributeDeclIndex, XMLAttributeDecl attributeDecl)
          getAttributeDecl
 int getAttributeDeclIndex(int elementDeclIndex, java.lang.String attributeDeclName)
          getAttributeDeclIndex
 boolean getContentSpec(int contentSpecIndex, XMLContentSpec contentSpec)
          getContentSpec
 java.lang.String getContentSpecAsString(int elementDeclIndex)
          getContentSpecAsString
protected  ContentModelValidator getElementContentModelValidator(int elementDeclIndex)
          getElementContentModelValidator
 boolean getElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)
          getElementDecl
 int getElementDeclIndex(org.apache.xerces.xni.QName elementDeclQName, int scope)
          getElementDeclIndex
 int getElementDeclIndex(java.lang.String elementDeclName, int scope)
          getElementDeclIndex
 boolean getEntityDecl(int entityDeclIndex, XMLEntityDecl entityDecl)
          getEntityDecl
 int getEntityDeclIndex(java.lang.String entityDeclName)
          getEntityDeclIndex
 int getFirstAttributeDeclIndex(int elementDeclIndex)
          getFirstAttributeDeclIndex
 int getFirstElementDeclIndex()
          Returns the index of the first element declaration.
 int getFirstEntityDeclIndex()
          getFirstEntityDeclIndex
 int getFirstNotationDeclIndex()
          getFirstNotationDeclIndex
 int getNextAttributeDeclIndex(int attributeDeclIndex)
          getNextAttributeDeclIndex
 int getNextElementDeclIndex(int elementDeclIndex)
          Returns the next index of the element declaration following the specified element declaration.
 int getNextEntityDeclIndex(int elementDeclIndex)
          getNextEntityDeclIndex
 int getNextNotationDeclIndex(int elementDeclIndex)
          getNextNotationDeclIndex
 boolean getNotationDecl(int notationDeclIndex, XMLNotationDecl notationDecl)
          getNotationDecl
 int getNotationDeclIndex(java.lang.String notationDeclName)
          getNotationDeclIndex
 SymbolTable getSymbolTable()
          Returns the symbol table.
 java.lang.String getTargetNamespace()
          Returns this grammar's target namespace.
 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
protected  boolean isDTD()
           
abstract  boolean isNamespaceAware()
          Returns true if this grammar is namespace aware.
 void printAttributes(int elementDeclIndex)
           
 void printElements()
           
protected  void putElementNameMapping(org.apache.xerces.xni.QName name, int scope, int elementDeclIndex)
           
protected  void setAttributeDecl(int elementDeclIndex, int attributeDeclIndex, XMLAttributeDecl attributeDecl)
           
protected  void setContentSpec(int contentSpecIndex, XMLContentSpec contentSpec)
           
protected  void setContentSpecIndex(int elementDeclIndex, int contentSpecIndex)
           
protected  void setElementDecl(int elementDeclIndex, XMLElementDecl elementDecl)
           
protected  void setEntityDecl(int entityDeclIndex, XMLEntityDecl entityDecl)
           
protected  void setFirstAttributeDeclIndex(int elementDeclIndex, int newFirstAttrIndex)
           
protected  void setNotationDecl(int notationDeclIndex, XMLNotationDecl notationDecl)
           
protected  void setTargetNamespace(java.lang.String targetNamespace)
           
 
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).

fAttributeDecl

protected XMLAttributeDecl fAttributeDecl
Temporary Attribute decl.
Constructor Detail

Grammar

protected Grammar(SymbolTable symbolTable)
Default constructor.
Method Detail

isNamespaceAware

public abstract boolean isNamespaceAware()
Returns true if this grammar is namespace aware.

getSymbolTable

public SymbolTable getSymbolTable()
Returns the symbol table.

getTargetNamespace

public java.lang.String getTargetNamespace()
Returns this grammar's target namespace.

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, org.apache.xerces.impl.validation.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,
                               int scope)
getElementDeclIndex
Parameters:
elementDeclName -  
scope -  
Returns:
 

getElementDeclIndex

public int getElementDeclIndex(org.apache.xerces.xni.QName elementDeclQName,
                               int scope)
getElementDeclIndex
Parameters:
elementDeclQName -  
scope -  
Returns:
 

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:
int

getNextAttributeDeclIndex

public int getNextAttributeDeclIndex(int attributeDeclIndex)
getNextAttributeDeclIndex
Parameters:
attributeDeclIndex -  
Returns:
 

getAttributeDeclIndex

public int getAttributeDeclIndex(int elementDeclIndex,
                                 java.lang.String attributeDeclName)
getAttributeDeclIndex
Parameters:
elementDeclIndex -  
attributeDeclName -  
Returns:
 

getAttributeDecl

public boolean getAttributeDecl(int attributeDeclIndex,
                                XMLAttributeDecl attributeDecl)
getAttributeDecl
Parameters:
attributeDeclIndex -  
attributeDecl - The values of this structure are set by this call.
Returns:
 

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

getFirstEntityDeclIndex

public int getFirstEntityDeclIndex()
getFirstEntityDeclIndex
Returns:
 

getNextEntityDeclIndex

public int getNextEntityDeclIndex(int elementDeclIndex)
getNextEntityDeclIndex
Parameters:
elementDeclIndex -  
Returns:
 

getEntityDeclIndex

public int getEntityDeclIndex(java.lang.String entityDeclName)
getEntityDeclIndex
Parameters:
entityDeclName -  
Returns:
 

getEntityDecl

public boolean getEntityDecl(int entityDeclIndex,
                             XMLEntityDecl entityDecl)
getEntityDecl
Parameters:
entityDeclIndex -  
entityDecl -  
Returns:
 

getFirstNotationDeclIndex

public int getFirstNotationDeclIndex()
getFirstNotationDeclIndex
Returns:
 

getNextNotationDeclIndex

public int getNextNotationDeclIndex(int elementDeclIndex)
getNextNotationDeclIndex
Parameters:
elementDeclIndex -  
Returns:
 

getNotationDeclIndex

public int getNotationDeclIndex(java.lang.String notationDeclName)
getNotationDeclIndex
Parameters:
notationDeclName -  
Returns:
the index if found a notation with the name, otherwise -1.

getNotationDecl

public boolean getNotationDecl(int notationDeclIndex,
                               XMLNotationDecl notationDecl)
getNotationDecl
Parameters:
notationDeclIndex -  
notationDecl -  
Returns:
 

getContentSpec

public boolean getContentSpec(int contentSpecIndex,
                              XMLContentSpec contentSpec)
getContentSpec
Parameters:
contentSpecIndex -  
contentSpec -  
Returns:
true if find the requested contentSpec node, false otherwise

getContentSpecAsString

public java.lang.String getContentSpecAsString(int elementDeclIndex)
getContentSpecAsString
Parameters:
elementDeclIndex -  

printElements

public void printElements()

printAttributes

public void printAttributes(int elementDeclIndex)

getElementContentModelValidator

protected ContentModelValidator getElementContentModelValidator(int elementDeclIndex)
getElementContentModelValidator
Parameters:
elementDeclIndex -  
Returns:
its ContentModelValidator if any.

createElementDecl

protected int createElementDecl()

setElementDecl

protected void setElementDecl(int elementDeclIndex,
                              XMLElementDecl elementDecl)

putElementNameMapping

protected void putElementNameMapping(org.apache.xerces.xni.QName name,
                                     int scope,
                                     int elementDeclIndex)

setFirstAttributeDeclIndex

protected void setFirstAttributeDeclIndex(int elementDeclIndex,
                                          int newFirstAttrIndex)

setContentSpecIndex

protected void setContentSpecIndex(int elementDeclIndex,
                                   int contentSpecIndex)

createAttributeDecl

protected int createAttributeDecl()

setAttributeDecl

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

createContentSpec

protected int createContentSpec()

setContentSpec

protected void setContentSpec(int contentSpecIndex,
                              XMLContentSpec contentSpec)

createEntityDecl

protected int createEntityDecl()

setEntityDecl

protected void setEntityDecl(int entityDeclIndex,
                             XMLEntityDecl entityDecl)

createNotationDecl

protected int createNotationDecl()

setNotationDecl

protected void setNotationDecl(int notationDeclIndex,
                               XMLNotationDecl notationDecl)

setTargetNamespace

protected void setTargetNamespace(java.lang.String targetNamespace)

isDTD

protected boolean isDTD()


Copyright © 1999-2001 Apache XML Project. All Rights Reserved.