com.sun.msv.reader.dtd

Class DTDReader

Implemented Interfaces:
DTDEventListener, EventListener

public class DTDReader
extends Object
implements DTDEventListener

constructs TREXGrammar object that exactly matches to the parsed DTD.

Each element declaration will have its own ReferenceExp by the name of the element.

Note that this class does NOT extend GrammarReader, because DTD is not written in XML format.

Author:
Kohsuke KAWAGUCHI

Field Summary

static String
ERR_UNDECLARED_PREFIX
static String
ERR_UNDEFINED_ELEMENT
static String
WRN_ATTEMPT_TO_USE_NAMESPACE

Fields inherited from interface com.sun.msv.scanner.dtd.DTDEventListener

CHOICE, CONTENT_MODEL_ANY, CONTENT_MODEL_CHILDREN, CONTENT_MODEL_EMPTY, CONTENT_MODEL_MIXED, OCCURENCE_ONCE, OCCURENCE_ONE_OR_MORE, OCCURENCE_ZERO_OR_MORE, OCCURENCE_ZERO_OR_ONE, SEQUENCE, USE_FIXED, USE_IMPLIED, USE_NORMAL, USE_REQUIRED

Constructor Summary

DTDReader(GrammarReaderController controller, ExpressionPool pool)

Method Summary

void
attributeDecl(String elementName, String attributeName, String attributeType, String[] enums, short attributeUse, String defaultValue)
void
characters(ch[] , int start, int length)
void
childElement(String elementName, short occurence)
void
comment(String n)
void
connector(short type)
Datatype
createDatatype(String name)
Obtains a Datatype object from its name.
void
endCDATA()
void
endContentModel(String elementName, short type)
void
endDTD()
void
endModelGroup(short occurence)
void
error(SAXParseException e)
void
externalGeneralEntityDecl(String n, String p, String s)
void
externalParameterEntityDecl(String n, String p, String s)
void
fatalError(SAXParseException e)
Locator
getDeclaredLocationOf(Object o)
TREXGrammar
getResult()
Obtains the parsed grammar object.
void
ignorableWhitespace(ch[] , int start, int length)
void
internalGeneralEntityDecl(String n, String v)
void
internalParameterEntityDecl(String n, String v)
boolean
isUnparsedEntity(String entityName)
void
mixedElement(String elementName)
void
notationDecl(String name, String publicId, String systemId)
static TREXGrammar
parse(InputSource source, GrammarReaderController controller)
static TREXGrammar
parse(InputSource source, GrammarReaderController controller, ExpressionPool pool)
void
processingInstruction(String target, String data)
String
resolveNamespacePrefix(String prefix)
void
setDatatypeLibrary(DatatypeLibrary datatypeLibrary)
void
setDeclaredLocationOf(Object o)
void
setDocumentLocator(Locator loc)
void
startCDATA()
void
startContentModel(String elementName, short type)
void
startDTD(InputEntity in)
void
startModelGroup()
void
unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
void
warning(SAXParseException e)

Field Details

ERR_UNDECLARED_PREFIX

public static final String ERR_UNDECLARED_PREFIX

ERR_UNDEFINED_ELEMENT

public static final String ERR_UNDEFINED_ELEMENT

WRN_ATTEMPT_TO_USE_NAMESPACE

public static final String WRN_ATTEMPT_TO_USE_NAMESPACE

Constructor Details

DTDReader

public DTDReader(GrammarReaderController controller,
                 ExpressionPool pool)

Method Details

attributeDecl

public void attributeDecl(String elementName,
                          String attributeName,
                          String attributeType,
                          String[] enums,
                          short attributeUse,
                          String defaultValue)
            throws SAXException
Specified by:
attributeDecl in interface DTDEventListener

characters

public void characters(ch[] ,
                       int start,
                       int length)
            throws SAXException
Specified by:
characters in interface DTDEventListener

childElement

public void childElement(String elementName,
                         short occurence)
Specified by:
childElement in interface DTDEventListener

comment

public void comment(String n)
            throws SAXException
Specified by:
comment in interface DTDEventListener

connector

public void connector(short type)
            throws SAXException
Specified by:
connector in interface DTDEventListener

createDatatype

public Datatype createDatatype(String name)
Obtains a Datatype object from its name.

endCDATA

public void endCDATA()
            throws SAXException
Specified by:
endCDATA in interface DTDEventListener

endContentModel

public void endContentModel(String elementName,
                            short type)
Specified by:
endContentModel in interface DTDEventListener

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface DTDEventListener

endModelGroup

public void endModelGroup(short occurence)
Specified by:
endModelGroup in interface DTDEventListener

error

public void error(SAXParseException e)
            throws SAXException
Specified by:
error in interface DTDEventListener

externalGeneralEntityDecl

public void externalGeneralEntityDecl(String n,
                                      String p,
                                      String s)
            throws SAXException
Specified by:
externalGeneralEntityDecl in interface DTDEventListener

externalParameterEntityDecl

public void externalParameterEntityDecl(String n,
                                        String p,
                                        String s)
            throws SAXException
Specified by:
externalParameterEntityDecl in interface DTDEventListener

fatalError

public void fatalError(SAXParseException e)
            throws SAXException
Specified by:
fatalError in interface DTDEventListener

getDeclaredLocationOf

public Locator getDeclaredLocationOf(Object o)

getResult

public TREXGrammar getResult()
Obtains the parsed grammar object.
Returns:
null if there was an error. Otherwise a parsed grammar object will be returned.

ignorableWhitespace

public void ignorableWhitespace(ch[] ,
                                int start,
                                int length)
            throws SAXException
Specified by:
ignorableWhitespace in interface DTDEventListener

internalGeneralEntityDecl

public void internalGeneralEntityDecl(String n,
                                      String v)
            throws SAXException
Specified by:
internalGeneralEntityDecl in interface DTDEventListener

internalParameterEntityDecl

public void internalParameterEntityDecl(String n,
                                        String v)
            throws SAXException
Specified by:
internalParameterEntityDecl in interface DTDEventListener

isUnparsedEntity

public boolean isUnparsedEntity(String entityName)

mixedElement

public void mixedElement(String elementName)
Specified by:
mixedElement in interface DTDEventListener

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
            throws SAXException
Specified by:
notationDecl in interface DTDEventListener

parse

public static TREXGrammar parse(InputSource source,
                                GrammarReaderController controller)

parse

public static TREXGrammar parse(InputSource source,
                                GrammarReaderController controller,
                                ExpressionPool pool)

processingInstruction

public void processingInstruction(String target,
                                  String data)
            throws SAXException
Specified by:
processingInstruction in interface DTDEventListener

resolveNamespacePrefix

public String resolveNamespacePrefix(String prefix)

setDatatypeLibrary

public void setDatatypeLibrary(DatatypeLibrary datatypeLibrary)

setDeclaredLocationOf

public void setDeclaredLocationOf(Object o)

setDocumentLocator

public void setDocumentLocator(Locator loc)
Specified by:
setDocumentLocator in interface DTDEventListener

startCDATA

public void startCDATA()
            throws SAXException
Specified by:
startCDATA in interface DTDEventListener

startContentModel

public void startContentModel(String elementName,
                              short type)
Specified by:
startContentModel in interface DTDEventListener

startDTD

public void startDTD(InputEntity in)
            throws SAXException
Specified by:
startDTD in interface DTDEventListener

startModelGroup

public void startModelGroup()
Specified by:
startModelGroup in interface DTDEventListener

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
            throws SAXException
Specified by:
unparsedEntityDecl in interface DTDEventListener

warning

public void warning(SAXParseException e)
            throws SAXException
Specified by:
warning in interface DTDEventListener