public class DtdModelBuilder
extends com.sun.xml.dtdparser.DTDHandlerBase
DtdModelBuilder builds an in-memory model of a DTD.
One big drawback with Sun's classic DTD parser is that many crucial pieces of information
are not yet available when an element is processed. For example, it may be important to
know if an element is part of a sequence or a choice, however that information will not
be available until the first connector is encountered. For the
first element in a model group this information will therefore only be available after
the fact. Similarly, a model group's occurrence constraints are not known until the end
of the group, and any sort of processing decisions for elements in the group that might
depend on this information will have to be postponed.
Rather than dealing with all kinds of delayed decisions when processing a DTD, it is often
more convenient to build up a complete model ahead of time and so that any validation or
code generation can occur with all necessary information already available.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 and Description |
|---|
DtdModelBuilder() |
| Modifier and Type | Method and Description |
|---|---|
void |
attributeDecl(String elementName,
String attributeName,
String attributeType,
String[] enumeration,
short attributeUse,
String defaultValue) |
void |
childElement(String elementName,
short occurence) |
void |
connector(short connectorType) |
void |
endContentModel(String elementName,
short contentModelType) |
void |
endDTD() |
void |
endModelGroup(short occurence) |
Dtd |
getDtd() |
void |
mixedElement(String elementName) |
void |
startContentModel(String elementName,
short contentModelType) |
void |
startDTD(com.sun.xml.dtdparser.InputEntity entity) |
void |
startModelGroup() |
characters, comment, endCDATA, error, externalGeneralEntityDecl, externalParameterEntityDecl, fatalError, ignorableWhitespace, internalGeneralEntityDecl, internalParameterEntityDecl, notationDecl, processingInstruction, setDocumentLocator, startCDATA, unparsedEntityDecl, warningpublic Dtd getDtd()
public void startDTD(com.sun.xml.dtdparser.InputEntity entity)
throws SAXException
startDTD in interface com.sun.xml.dtdparser.DTDEventListenerstartDTD in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void endDTD()
throws SAXException
endDTD in interface com.sun.xml.dtdparser.DTDEventListenerendDTD in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void startContentModel(String elementName, short contentModelType) throws SAXException
startContentModel in interface com.sun.xml.dtdparser.DTDEventListenerstartContentModel in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void endContentModel(String elementName, short contentModelType) throws SAXException
endContentModel in interface com.sun.xml.dtdparser.DTDEventListenerendContentModel in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void startModelGroup()
throws SAXException
startModelGroup in interface com.sun.xml.dtdparser.DTDEventListenerstartModelGroup in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void endModelGroup(short occurence)
throws SAXException
endModelGroup in interface com.sun.xml.dtdparser.DTDEventListenerendModelGroup in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void childElement(String elementName, short occurence) throws SAXException
childElement in interface com.sun.xml.dtdparser.DTDEventListenerchildElement in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void mixedElement(String elementName) throws SAXException
mixedElement in interface com.sun.xml.dtdparser.DTDEventListenermixedElement in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void connector(short connectorType)
throws SAXException
connector in interface com.sun.xml.dtdparser.DTDEventListenerconnector in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionpublic void attributeDecl(String elementName, String attributeName, String attributeType, String[] enumeration, short attributeUse, String defaultValue) throws SAXException
attributeDecl in interface com.sun.xml.dtdparser.DTDEventListenerattributeDecl in class com.sun.xml.dtdparser.DTDHandlerBaseSAXExceptionCopyright © 2022. All rights reserved.