com.sun.tools.xjc.reader.dtd
Class TDTDReader

java.lang.Object
  extended by com.sun.xml.dtdparser.DTDHandlerBase
      extended by com.sun.tools.xjc.reader.dtd.TDTDReader
All Implemented Interfaces:
DTDEventListener, EventListener

public class TDTDReader
extends DTDHandlerBase

Parses DTD grammar along with binding information into BGM.

Author:
Kohsuke KAWAGUCHI

Field Summary
 
Fields inherited from interface com.sun.xml.dtdparser.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
protected TDTDReader(ErrorReceiver errorReceiver, Options opts, InputSource _bindInfo)
           
 
Method Summary
 void attributeDecl(String elementName, String attributeName, String attributeType, String[] enumeration, short attributeUse, String defaultValue)
          For each entry in an ATTLIST declaration, this event will be fired.
 void childElement(String elementName, short occurence)
           
 void connector(short connectorType)
          Connectors in one model group is guaranteed to be the same.
protected  CPropertyInfo createAttribute(String elementName, String attributeName, String attributeType, String[] enums, short attributeUse, String defaultValue)
           
 void endContentModel(String elementName, short contentModelType)
          receives notification that parsing of content model is finished.
 void endDTD()
          Receive notification of the end of a DTD.
 void endModelGroup(short occurence)
           
protected  void error(Locator loc, String prop, Object... args)
           
 void error(SAXParseException e)
           
 void fatalError(SAXParseException e)
           
static Model parse(InputSource dtd, InputSource bindingInfo, ErrorReceiver errorReceiver, Options opts)
          Parses DTD grammar and a binding information into BGM.
 void setDocumentLocator(Locator loc)
           
 void startContentModel(String elementName, short contentModelType)
          receives notification that parsing of content model is beginning.
 void startDTD(InputEntity entity)
          Receive notification of the beginning of the DTD.
 void startModelGroup()
           
 void warning(SAXParseException e)
           
 
Methods inherited from class com.sun.xml.dtdparser.DTDHandlerBase
characters, comment, endCDATA, externalGeneralEntityDecl, externalParameterEntityDecl, ignorableWhitespace, internalGeneralEntityDecl, internalParameterEntityDecl, mixedElement, notationDecl, processingInstruction, startCDATA, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TDTDReader

protected TDTDReader(ErrorReceiver errorReceiver,
                     Options opts,
                     InputSource _bindInfo)
              throws AbortException
Throws:
AbortException
Method Detail

parse

public static Model parse(InputSource dtd,
                          InputSource bindingInfo,
                          ErrorReceiver errorReceiver,
                          Options opts)
Parses DTD grammar and a binding information into BGM.

This method is just a utility method that covers 80% of the use cases.

Parameters:
bindingInfo - binding information file, if any. Can be null.

startDTD

public void startDTD(InputEntity entity)
              throws SAXException
Description copied from interface: DTDEventListener
Receive notification of the beginning of the DTD.

Specified by:
startDTD in interface DTDEventListener
Overrides:
startDTD in class DTDHandlerBase
Parameters:
entity - Current input entity.
Throws:
SAXException
See Also:
DTDEventListener.endDTD()

endDTD

public void endDTD()
            throws SAXException
Description copied from interface: DTDEventListener
Receive notification of the end of a DTD. The parser will invoke this method only once.

Specified by:
endDTD in interface DTDEventListener
Overrides:
endDTD in class DTDHandlerBase
Throws:
SAXException
See Also:
DTDEventListener.startDTD(InputEntity)

attributeDecl

public void attributeDecl(String elementName,
                          String attributeName,
                          String attributeType,
                          String[] enumeration,
                          short attributeUse,
                          String defaultValue)
                   throws SAXException
Description copied from interface: DTDEventListener
For each entry in an ATTLIST declaration, this event will be fired.

DTD allows the same attributes to be declared more than once, and in that case the first one wins. I think this method will be only fired for the first one, but I need to check.

Specified by:
attributeDecl in interface DTDEventListener
Overrides:
attributeDecl in class DTDHandlerBase
Throws:
SAXException

createAttribute

protected CPropertyInfo createAttribute(String elementName,
                                        String attributeName,
                                        String attributeType,
                                        String[] enums,
                                        short attributeUse,
                                        String defaultValue)
                                 throws SAXException
Throws:
SAXException

startContentModel

public void startContentModel(String elementName,
                              short contentModelType)
                       throws SAXException
Description copied from interface: DTDEventListener
receives notification that parsing of content model is beginning.

Specified by:
startContentModel in interface DTDEventListener
Overrides:
startContentModel in class DTDHandlerBase
Parameters:
elementName - name of the element whose content model is going to be defined.
contentModelType - DTDEventListener.CONTENT_MODEL_EMPTY this element has EMPTY content model. This notification will be immediately followed by the corresponding endContentModel. DTDEventListener.CONTENT_MODEL_ANY this element has ANY content model. This notification will be immediately followed by the corresponding endContentModel. DTDEventListener.CONTENT_MODEL_MIXED this element has mixed content model. #PCDATA will not be reported. each child element will be reported by mixedElement method. DTDEventListener.CONTENT_MODEL_CHILDREN this elemen has child content model. The actual content model will be reported by childElement, startModelGroup, endModelGroup, and connector methods. Possible call sequences are:

START := MODEL_GROUP MODEL_GROUP := startModelGroup TOKEN (connector TOKEN)* endModelGroup TOKEN := childElement | MODEL_GROUP

Throws:
SAXException

endContentModel

public void endContentModel(String elementName,
                            short contentModelType)
                     throws SAXException
Description copied from interface: DTDEventListener
receives notification that parsing of content model is finished.

Specified by:
endContentModel in interface DTDEventListener
Overrides:
endContentModel in class DTDHandlerBase
Throws:
SAXException

startModelGroup

public void startModelGroup()
                     throws SAXException
Specified by:
startModelGroup in interface DTDEventListener
Overrides:
startModelGroup in class DTDHandlerBase
Throws:
SAXException

endModelGroup

public void endModelGroup(short occurence)
                   throws SAXException
Specified by:
endModelGroup in interface DTDEventListener
Overrides:
endModelGroup in class DTDHandlerBase
Throws:
SAXException

connector

public void connector(short connectorType)
               throws SAXException
Description copied from interface: DTDEventListener
Connectors in one model group is guaranteed to be the same.

IOW, you'll never see an event sequence like (a|b,c)

Specified by:
connector in interface DTDEventListener
Overrides:
connector in class DTDHandlerBase
Throws:
SAXException

childElement

public void childElement(String elementName,
                         short occurence)
                  throws SAXException
Specified by:
childElement in interface DTDEventListener
Overrides:
childElement in class DTDHandlerBase
Throws:
SAXException

setDocumentLocator

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

error

public void error(SAXParseException e)
           throws SAXException
Specified by:
error in interface DTDEventListener
Overrides:
error in class DTDHandlerBase
Throws:
SAXException

fatalError

public void fatalError(SAXParseException e)
                throws SAXException
Specified by:
fatalError in interface DTDEventListener
Overrides:
fatalError in class DTDHandlerBase
Throws:
SAXException

warning

public void warning(SAXParseException e)
             throws SAXException
Specified by:
warning in interface DTDEventListener
Overrides:
warning in class DTDHandlerBase
Throws:
SAXException

error

protected final void error(Locator loc,
                           String prop,
                           Object... args)


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.