Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xerces.validators.dtd
Class DTDGrammar

    java.lang.Object
      |
      +--org.apache.xerces.validators.common.Grammar
            |
            +--org.apache.xerces.validators.dtd.DTDGrammar

public class DTDGrammar
extends Grammar
implements XMLDTDScanner.EventHandler

A DTD grammar. This class is an EventHandler to receive callbacks from the XMLDTDScanner. When the callbacks are received, the grammar structures are directly populated from the callback information.

In addition to being a recipient of scanner callbacks, the DTD grammar class can act as a pass-through filter for the DTD events. This is useful for parsers that must expose the DTD information to the application. (e.g. SAX2 DeclHandler callbacks.)

Version:
  $Id: DTDGrammar.java,v 1.10 2001/07/20 17:27:38 lmartin Exp $
Author:
  Andy Clark

Fields inherited from class org.apache.xerces.validators.common.Grammar
`TOP_LEVEL_SCOPE`

Constructor Summary
`DTDGrammar(StringPool stringPool)` Default constructor.

Method Summary
`int` | `addAttDef(QName elementDecl, QName attributeDecl, int attType, boolean attList, int enumeration, int attDefaultType, int attDefaultValue, boolean isExternal)` Add an attribute definition
`int` | `addContentSpecNode(int nodeType, int nodeValue)` Create an XMLContentSpec for a single non-leaf
`int` | `addContentSpecNode(int nodeType, int leftNodeIndex, int rightNodeIndex)` Create an XMLContentSpec for a two child leaf
`int` | `addElementDecl(QName elementDecl)` Add an element declaration (forward reference)
`int` | `addElementDecl(QName elementDecl, int contentSpecType, int contentSpec, boolean isExternal)` Add an element declaration
`int` | `addExternalEntityDecl(int name, int publicId, int systemId)` Add a declaration for an entity
`int` | `addExternalPEDecl(int name, int publicId, int systemId)` Add a declaration for an external parameter entity
`int` | `addInternalEntityDecl(int name, int value)` Add a declaration for an internal entity
`int` | `addInternalPEDecl(int name, int value)` Add a declaration for an internal parameter entity
`void` | `addNameToEnumeration(int enumIndex, int elementType, int attrName, int nameIndex, boolean isNotationType)` Add a name to an enumeration
`int` | `addNotationDecl(int notationName, int publicId, int systemId)` Add a declaration for a notation
`int` | `addUniqueLeafNode(int nameIndex)` create an XMLContentSpec for a leaf
`int` | `addUnparsedEntityDecl(int name, int publicId, int systemId, int notationName)` Add a declaration for an unparsed entity
`void` | `callComment(int data)` Called when a comment has been scanned
`void` | `callEndDTD()` End of DTD.
`void` | `callProcessingInstruction(int piTarget, int piData)` Called when a processing instruction has been scanned
`void` | `callStartDTD()` Start of DTD.
`void` | `callTextDecl(int version, int encoding)` Signal the Text declaration of an external entity.
`void` | `doctypeDecl(QName rootElement, int publicId, int systemId)` Called when the doctype decl is scanned
`void` | `endEntityDecl()` End the scope of an entity declaration.
`void` | `endEnumeration(int enumIndex)` Finish processing an enumeration
`boolean` | `getAttributeDeclIsExternal(int attributeDeclIndex)`
`java.lang.String` | `getContentSpecNodeAsString(int nodeIndex)` Create a string representation of an XMLContentSpec tree
`int` | `getElementDeclIndex(QName element, int scopeIndex)` public int getElementDeclIndex(int localpartIndex, int scopeIndex) { //System.out.println("getElementDeclIndex: "+localpartIndex+", "+scopeIndex); return super.getElementDeclIndex(localpartIndex, scopeIndex); } public int getElementDeclIndex(int uriIndex, int localpartIndex, int scopeIndex) { //System.out.println("!!! getElementDeclIndex: "+uriIndex+", "+localpartIndex+", "+scopeIndex); return super.getElementDeclIndex(localpartIndex, -1); } /
`boolean` | `getElementDeclIsExternal(int elementDeclIndex)`
`boolean` | `getRootElementQName(QName root)`
`void` | `internalSubset(int internalSubset)` Supports DOM Level 2 internalSubset additions.
`protected boolean` | `isDTD()`
`protected void` | `putElementNameMapping(QName name, int scope, int elementDeclIndex)`
`void` | `reset(StringPool stringPool)` Resets the DTD grammar.
`void` | `setElementDeclDTD(int elementDeclIndex, XMLElementDecl elementDecl)`
`void` | `setElementDeclIsExternal(int elementDeclIndex, boolean isExternal)` public void setContentSpecLeaf(int contentSpecIndex, QName elementName) { fTempContentSpec.setValues(XMLContentSpec.CONTENTSPECNODE_LEAF, elementName.rawname, -1); super.setContentSpec(contentSpecIndex, fTempContentSpec); } /
`boolean` | `startEntityDecl(boolean isPE, int entityName)` Start the scope of an entity declaration.
`int` | `startEnumeration()` Called when the scanner start scanning an enumeration
`void` | `startReadingFromExternalSubset(int publicId, int systemId)` Called when the DTDScanner starts reading from the external subset
`void` | `stopReadingFromExternalSubset()` Called when the DTDScanner stop reading from the external subset

Methods inherited from class org.apache.xerces.validators.common.Grammar
`clearContentModel, convertContentSpecTree, createAttributeDecl, createContentSpec, createElementDecl, existContentModel, getAttributeDecl, getContentModel, getContentSpec, getElementContentModel, getElementDecl, getElementDeclIndex, getElementDeclIndex, getFirstAttributeDeclIndex, getGrammarDocument, getNextAttributeDeclIndex, printAttributes, printElements, setAttributeDecl, setContentSpec, setElementDecl, setFirstAttributeDeclIndex, setGrammarDocument`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DTDGrammar

    public DTDGrammar(StringPool stringPool)

  Default constructor.

Method Detail

### reset

    public void reset(StringPool stringPool)

  Resets the DTD grammar.

### callStartDTD

    public void callStartDTD()
                      throws java.lang.Exception

  Start of DTD.
  Specified by:
    callStartDTD in interface XMLDTDScanner.EventHandler

### callEndDTD

    public void callEndDTD()
                    throws java.lang.Exception

  End of DTD.
  Specified by:
    callEndDTD in interface XMLDTDScanner.EventHandler

### callTextDecl

    public void callTextDecl(int version,
                             int encoding)
                      throws java.lang.Exception

  Signal the Text declaration of an external entity.
  Specified by:
    callTextDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `version` - the handle in the string pool for the version number
    `encoding` - the handle in the string pool for the encoding
  Throws:
    java.lang.Exception -

### doctypeDecl

    public void doctypeDecl(QName rootElement,
                            int publicId,
                            int systemId)
                     throws java.lang.Exception

  Called when the doctype decl is scanned
  Specified by:
    doctypeDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `rootElementType` - handle of the rootElement
    `publicId` - StringPool handle of the public id
    `systemId` - StringPool handle of the system id
  Throws:
    java.lang.Exception -

### startReadingFromExternalSubset

    public void startReadingFromExternalSubset(int publicId,
                                               int systemId)
                                        throws java.lang.Exception

  Called when the DTDScanner starts reading from the external subset
  Specified by:
    startReadingFromExternalSubset in interface XMLDTDScanner.EventHandler
  Parameters:
    `publicId` - StringPool handle of the public id
    `systemId` - StringPool handle of the system id
  Throws:
    java.lang.Exception -

### stopReadingFromExternalSubset

    public void stopReadingFromExternalSubset()
                                       throws java.lang.Exception

  Called when the DTDScanner stop reading from the external subset
  Specified by:
    stopReadingFromExternalSubset in interface XMLDTDScanner.EventHandler
  Throws:
    java.lang.Exception -

### addElementDecl

    public int addElementDecl(QName elementDecl)
                       throws java.lang.Exception

  Add an element declaration (forward reference)
  Specified by:
    addElementDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `handle` - to the name of the element being declared
  Returns:
    handle to the element whose declaration was added
  Throws:
    java.lang.Exception -

### addElementDecl

    public int addElementDecl(QName elementDecl,
                              int contentSpecType,
                              int contentSpec,
                              boolean isExternal)
                       throws java.lang.Exception

  Add an element declaration
  Specified by:
    addElementDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `handle` - to the name of the element being declared
    `contentSpecType` - handle to the type name of the content spec
    `ContentSpec` - handle to the content spec node for the contentSpecType
  Returns:
    handle to the element declaration that was added
  Throws:
    java.lang.Exception -

### putElementNameMapping

    protected void putElementNameMapping(QName name,
                                         int scope,
                                         int elementDeclIndex)

  Overrides:
    putElementNameMapping in class Grammar

### getElementDeclIndex

    public int getElementDeclIndex(QName element,
                                   int scopeIndex)

  public int getElementDeclIndex(int localpartIndex, int scopeIndex) { //System.out.println("getElementDeclIndex: "+localpartIndex+", "+scopeIndex); return super.getElementDeclIndex(localpartIndex, scopeIndex); } public int getElementDeclIndex(int uriIndex, int localpartIndex, int scopeIndex) { //System.out.println("!!! getElementDeclIndex: "+uriIndex+", "+localpartIndex+", "+scopeIndex); return super.getElementDeclIndex(localpartIndex, -1); } /
  Overrides:
    getElementDeclIndex in class Grammar

### setElementDeclDTD

    public void setElementDeclDTD(int elementDeclIndex,
                                  XMLElementDecl elementDecl)

### setElementDeclIsExternal

    public void setElementDeclIsExternal(int elementDeclIndex,
                                         boolean isExternal)

  public void setContentSpecLeaf(int contentSpecIndex, QName elementName) { fTempContentSpec.setValues(XMLContentSpec.CONTENTSPECNODE_LEAF, elementName.rawname, -1); super.setContentSpec(contentSpecIndex, fTempContentSpec); } /

### getElementDeclIsExternal

    public boolean getElementDeclIsExternal(int elementDeclIndex)

### getAttributeDeclIsExternal

    public boolean getAttributeDeclIsExternal(int attributeDeclIndex)

### getRootElementQName

    public boolean getRootElementQName(QName root)

### addAttDef

    public int addAttDef(QName elementDecl,
                         QName attributeDecl,
                         int attType,
                         boolean attList,
                         int enumeration,
                         int attDefaultType,
                         int attDefaultValue,
                         boolean isExternal)
                  throws java.lang.Exception

  Add an attribute definition
  Specified by:
    addAttDef in interface XMLDTDScanner.EventHandler
  Parameters:
    `handle` - to the element whose attribute is being declared
    `attName` - StringPool handle to the attribute name being declared
    `attType` - type of the attribute
    `enumeration` - StringPool handle of the attribute's enumeration list (if any)
    `attDefaultType` - an integer value denoting the DefaultDecl value
    `attDefaultValue` - StringPool handle of this attribute's default value
  Returns:
    handle to the attribute definition
  Throws:
    java.lang.Exception -

### addUniqueLeafNode

    public int addUniqueLeafNode(int nameIndex)
                          throws java.lang.Exception

  create an XMLContentSpec for a leaf
  Specified by:
    addUniqueLeafNode in interface XMLDTDScanner.EventHandler
  Parameters:
    `nameIndex` - StringPool handle to the name (Element) for the node
  Returns:
    handle to the newly create XMLContentSpec
  Throws:
    java.lang.Exception -

### addContentSpecNode

    public int addContentSpecNode(int nodeType,
                                  int nodeValue)
                           throws java.lang.Exception

  Create an XMLContentSpec for a single non-leaf
  Specified by:
    addContentSpecNode in interface XMLDTDScanner.EventHandler
  Parameters:
    `nodeType` - the type of XMLContentSpec to create - from XMLContentSpec.CONTENTSPECNODE_*
    `nodeValue` - handle to an XMLContentSpec
  Returns:
    handle to the newly create XMLContentSpec
  Throws:
    java.lang.Exception -

### addContentSpecNode

    public int addContentSpecNode(int nodeType,
                                  int leftNodeIndex,
                                  int rightNodeIndex)
                           throws java.lang.Exception

  Create an XMLContentSpec for a two child leaf
  Specified by:
    addContentSpecNode in interface XMLDTDScanner.EventHandler
  Parameters:
    `nodeType` - the type of XMLContentSpec to create - from XMLContentSpec.CONTENTSPECNODE_*
    `leftNodeIndex` - handle to an XMLContentSpec
    `rightNodeIndex` - handle to an XMLContentSpec
  Returns:
    handle to the newly create XMLContentSpec
  Throws:
    java.lang.Exception -

### getContentSpecNodeAsString

    public java.lang.String getContentSpecNodeAsString(int nodeIndex)
                                                throws java.lang.Exception

  Create a string representation of an XMLContentSpec tree
  Specified by:
    getContentSpecNodeAsString in interface XMLDTDScanner.EventHandler
  Parameters:
    `handle` - to an XMLContentSpec
  Returns:
    String representation of the content spec tree
  Throws:
    java.lang.Exception -

### startEntityDecl

    public boolean startEntityDecl(boolean isPE,
                                   int entityName)
                            throws java.lang.Exception

  Start the scope of an entity declaration.
  Specified by:
    startEntityDecl in interface XMLDTDScanner.EventHandler
  Returns:
    `true` on success; otherwise `false` if the entity declaration is recursive.
  Throws:
    java.lang.Exception -

### endEntityDecl

    public void endEntityDecl()
                       throws java.lang.Exception

  End the scope of an entity declaration.
  Specified by:
    endEntityDecl in interface XMLDTDScanner.EventHandler
  Throws:
    java.lang.Exception -

### addInternalPEDecl

    public int addInternalPEDecl(int name,
                                 int value)
                          throws java.lang.Exception

  Add a declaration for an internal parameter entity
  Specified by:
    addInternalPEDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `name` - StringPool handle of the parameter entity name
    `value` - StringPool handle of the parameter entity value
  Returns:
    handle to the parameter entity declaration
  Throws:
    java.lang.Exception -

### addExternalPEDecl

    public int addExternalPEDecl(int name,
                                 int publicId,
                                 int systemId)
                          throws java.lang.Exception

  Add a declaration for an external parameter entity
  Specified by:
    addExternalPEDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `name` - StringPool handle of the parameter entity name
    `publicId` - StringPool handle of the publicId
    `systemId` - StringPool handle of the systemId
  Returns:
    handle to the parameter entity declaration
  Throws:
    java.lang.Exception -

### addInternalEntityDecl

    public int addInternalEntityDecl(int name,
                                     int value)
                              throws java.lang.Exception

  Add a declaration for an internal entity
  Specified by:
    addInternalEntityDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `name` - StringPool handle of the entity name
    `value` - StringPool handle of the entity value
  Returns:
    handle to the entity declaration
  Throws:
    java.lang.Exception -

### addExternalEntityDecl

    public int addExternalEntityDecl(int name,
                                     int publicId,
                                     int systemId)
                              throws java.lang.Exception

  Add a declaration for an entity
  Specified by:
    addExternalEntityDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `name` - StringPool handle of the entity name
    `publicId` - StringPool handle of the publicId
    `systemId` - StringPool handle of the systemId
  Returns:
    handle to the entity declaration
  Throws:
    java.lang.Exception -

### addUnparsedEntityDecl

    public int addUnparsedEntityDecl(int name,
                                     int publicId,
                                     int systemId,
                                     int notationName)
                              throws java.lang.Exception

  Add a declaration for an unparsed entity
  Specified by:
    addUnparsedEntityDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `name` - StringPool handle of the entity name
    `publicId` - StringPool handle of the publicId
    `systemId` - StringPool handle of the systemId
    `notationName` - StringPool handle of the notationName
  Returns:
    handle to the entity declaration
  Throws:
    java.lang.Exception -

### startEnumeration

    public int startEnumeration()
                         throws java.lang.Exception

  Called when the scanner start scanning an enumeration
  Specified by:
    startEnumeration in interface XMLDTDScanner.EventHandler
  Returns:
    StringPool handle to a string list that will hold the enumeration names
  Throws:
    java.lang.Exception -

### addNameToEnumeration

    public void addNameToEnumeration(int enumIndex,
                                     int elementType,
                                     int attrName,
                                     int nameIndex,
                                     boolean isNotationType)
                              throws java.lang.Exception

  Add a name to an enumeration
  Specified by:
    addNameToEnumeration in interface XMLDTDScanner.EventHandler
  Parameters:
    `enumIndex` - StringPool handle to the string list for the enumeration
    `elementType` - handle to the element that owns the attribute with the enumeration
    `attrName` - StringPool handle to the name of the attribut with the enumeration
    `nameIndex` - StringPool handle to the name to be added to the enumeration
    `isNotationType` - true if the enumeration is an enumeration of NOTATION names
  Throws:
    java.lang.Exception -

### endEnumeration

    public void endEnumeration(int enumIndex)
                        throws java.lang.Exception

  Finish processing an enumeration
  Specified by:
    endEnumeration in interface XMLDTDScanner.EventHandler
  Parameters:
    `enumIndex` - handle to the string list which holds the enumeration to be finshed.
  Throws:
    java.lang.Exception -

### addNotationDecl

    public int addNotationDecl(int notationName,
                               int publicId,
                               int systemId)
                        throws java.lang.Exception

  Add a declaration for a notation
  Specified by:
    addNotationDecl in interface XMLDTDScanner.EventHandler
  Parameters:
    `notationName` -
    `publicId` -
    `systemId` -
  Returns:
    handle to the notation declaration
  Throws:
    java.lang.Exception -

### callComment

    public void callComment(int data)
                     throws java.lang.Exception

  Called when a comment has been scanned
  Specified by:
    callComment in interface XMLDTDScanner.EventHandler
  Parameters:
    `data` - StringPool handle of the comment text
  Throws:
    java.lang.Exception -

### callProcessingInstruction

    public void callProcessingInstruction(int piTarget,
                                          int piData)
                                   throws java.lang.Exception

  Called when a processing instruction has been scanned
  Specified by:
    callProcessingInstruction in interface XMLDTDScanner.EventHandler
  Parameters:
    `piTarget` - StringPool handle of the PI target
    `piData` - StringPool handle of the PI data
  Throws:
    java.lang.Exception -

### internalSubset

    public void internalSubset(int internalSubset)
                        throws java.lang.Exception

  Supports DOM Level 2 internalSubset additions. Called when the internal subset is completely scanned.
  Specified by:
    internalSubset in interface XMLDTDScanner.EventHandler

### isDTD

    protected boolean isDTD()

  Overrides:
    isDTD in class Grammar

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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