java.lang.Object
com.sun.xml.dtdparser.DTDParser
This implements parsing of XML 1.0 DTDs.
This conforms to the portion of the XML 1.0 specification related to the external DTD subset.
For multi-language applications (such as web servers using XML processing to create dynamic content), a method supports choosing a locale for parser diagnostics which is both understood by the message recipient and supported by the parser.
This parser produces a stream of parse events. It supports some features (exposing comments, CDATA sections, and entity references) which are not required to be reported by conformant XML processors.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final char[]private booleanprivate DTDEventListener(package private) SimpleHashtable<String, EntityDecl> private final SimpleHashtable<String, Boolean> private InputEntityprivate Localeprivate static final Logger(package private) static final DTDParser.Catalogprivate DTDParser.NameCacheprivate char[]private final SimpleHashtable<String, EntityDecl> private EntityResolver(package private) static final String(package private) static final Stringprivate StringBufferstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidprivate voidchooseLocale(String[] languages) Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser.(package private) voidprivate voidexpandEntityInLiteral(String name, SimpleHashtable<String, EntityDecl> table, boolean isEntityValue) private voidprivate voidprivate voidprivate chargetc()intprivate voidgetcps(String elementName, InputEntity start) Returns the handler used to for DTD parsing events.Returns the object used to resolve entitiesprivate shortintReturns the diagnostic locale.private StringgetMarkupDeclname(String roleId, boolean qname) private voidgetMixed(String elementName, InputEntity start) private shortgetMixedOrChildren(String elementName) returns content model type.private Stringprivate StringgetQuotedString(String type, String extra) private voidinit()private booleanprivate booleanprivate booleanmaybeComment(boolean skipStart) private booleanprivate booleanprivate booleanprivate ExternalEntityprivate Stringprivate DTDParser.NameCacheEntryprivate booleanprivate booleanprivate booleanprivate booleanmaybePI(boolean skipStart) private StringmaybeReadAttribute(String name, boolean must) private voidprivate booleanprivate DTDParser.NameCacheEntrynameCharString(char c) private voidprivate Stringnormalize(boolean invalidIfNeeded) voidParse a DTD.voidparse(InputSource in) Parse a DTD.private intprivate voidparseInternal(InputSource input) private voidparseLiteral(boolean isEntityValue) private Stringprivate Stringprivate booleanprivate InputEntityprivate voidpushReader(char[] buf, String name, boolean isGeneral) private voidpushReader(ExternalEntity next) private voidreadEncoding(boolean must) private voidreadVersion(boolean must, String versionNum) private voidreportConnector(char type) voidsetDtdHandler(DTDEventListener handler) Used by applications to set handling of DTD parsing events.voidLets applications control entity resolution.voidUsed by applications to request locale for diagnostics.private intsurrogatesToCharTmp(int ucs4) private voidungetc()private voidprivate voidwhitespace(String roleId)
-
Field Details
-
TYPE_CDATA
- See Also:
-
TYPE_ID
- See Also:
-
TYPE_IDREF
- See Also:
-
TYPE_IDREFS
- See Also:
-
TYPE_ENTITY
- See Also:
-
TYPE_ENTITIES
- See Also:
-
TYPE_NMTOKEN
- See Also:
-
TYPE_NMTOKENS
- See Also:
-
TYPE_NOTATION
- See Also:
-
TYPE_ENUMERATION
- See Also:
-
in
-
strTmp
-
nameTmp
private char[] nameTmp -
nameCache
-
charTmp
private final char[] charTmp -
doLexicalPE
private boolean doLexicalPE -
declaredElements
-
params
-
notations
-
entities
SimpleHashtable<String,EntityDecl> entities -
ids
-
dtdHandler
-
resolver
-
locale
-
strANY
- See Also:
-
strEMPTY
- See Also:
-
LOGGER
-
XML_LANG
- See Also:
-
messages
-
-
Constructor Details
-
DTDParser
public DTDParser()Constructs a DTDParser.
-
-
Method Details
-
setLocale
Used by applications to request locale for diagnostics.- Parameters:
l- The locale to use, or null to use system defaults (which may include only message IDs).- Throws:
SAXException- for errors
-
getLocale
Returns the diagnostic locale.- Returns:
- the diagnostic locale
-
chooseLocale
Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser. That locale is then set using setLocale(). Such a list could be provided by a variety of user preference mechanisms, including the HTTP Accept-Language header field.- Parameters:
languages- Array of language specifiers, ordered with the most preferable one at the front. For example, "en-ca" then "fr-ca", followed by "zh_CN". Both RFC 1766 and Java styles are supported.- Returns:
- The chosen locale, or null.
- Throws:
SAXException- for errors- See Also:
-
setEntityResolver
Lets applications control entity resolution.- Parameters:
r- EntityResolver
-
getEntityResolver
Returns the object used to resolve entities- Returns:
- the object used to resolve entities
-
setDtdHandler
Used by applications to set handling of DTD parsing events. -
getDtdHandler
Returns the handler used to for DTD parsing events.- Returns:
- the handler
-
parse
Parse a DTD.- Throws:
IOException- for errorsSAXException- for errors
-
parse
Parse a DTD.- Throws:
IOException- for errorsSAXException- for errors
-
init
private void init() -
builtin
-
parseInternal
- Throws:
IOExceptionSAXException
-
afterRoot
- Throws:
SAXException
-
whitespace
- Throws:
IOExceptionSAXException
-
maybeWhitespace
- Throws:
IOExceptionSAXException
-
maybeGetName
- Throws:
IOExceptionSAXException
-
maybeGetNameCacheEntry
- Throws:
IOExceptionSAXException
-
getNmtoken
- Throws:
IOExceptionSAXException
-
nameCharString
- Throws:
IOExceptionSAXException
-
parseLiteral
- Throws:
IOExceptionSAXException
-
expandEntityInLiteral
private void expandEntityInLiteral(String name, SimpleHashtable<String, EntityDecl> table, boolean isEntityValue) throws IOException, SAXException- Throws:
IOExceptionSAXException
-
getQuotedString
- Throws:
IOExceptionSAXException
-
parsePublicId
- Throws:
IOExceptionSAXException
-
maybeComment
- Throws:
IOExceptionSAXException
-
maybePI
- Throws:
IOExceptionSAXException
-
maybeReadAttribute
- Throws:
IOExceptionSAXException
-
readVersion
- Throws:
IOExceptionSAXException
-
getMarkupDeclname
- Throws:
IOExceptionSAXException
-
maybeMarkupDecl
- Throws:
IOExceptionSAXException
-
isXmlLang
-
maybeElementDecl
- Throws:
IOExceptionSAXException
-
getMixedOrChildren
returns content model type.- Throws:
IOExceptionSAXException
-
getcps
- Throws:
IOExceptionSAXException
-
reportConnector
- Throws:
SAXException
-
getFrequency
- Throws:
IOExceptionSAXException
-
getMixed
- Throws:
IOExceptionSAXException
-
maybeAttlistDecl
- Throws:
IOExceptionSAXException
-
normalize
-
maybeConditionalSect
- Throws:
IOExceptionSAXException
-
parseCharNumber
- Throws:
IOExceptionSAXException
-
surrogatesToCharTmp
- Throws:
SAXException
-
maybePEReference
- Throws:
IOExceptionSAXException
-
maybeEntityDecl
- Throws:
IOExceptionSAXException
-
maybeExternalID
- Throws:
IOExceptionSAXException
-
parseSystemId
- Throws:
IOExceptionSAXException
-
maybeTextDecl
- Throws:
IOExceptionSAXException
-
externalParameterEntity
- Throws:
IOExceptionSAXException
-
readEncoding
- Throws:
IOExceptionSAXException
-
maybeNotationDecl
- Throws:
IOExceptionSAXException
-
getc
- Throws:
IOExceptionSAXException
-
ungetc
private void ungetc() -
peek
- Throws:
IOExceptionSAXException
-
peekDeclaration
- Throws:
IOExceptionSAXException
-
nextChar
- Throws:
IOExceptionSAXException
-
pushReader
- Throws:
SAXException
-
pushReader
- Throws:
IOExceptionSAXException
-
getPublicId
-
getSystemId
-
getLineNumber
public int getLineNumber() -
getColumnNumber
public int getColumnNumber() -
warning
- Throws:
SAXException
-
error
- Throws:
SAXException
-
fatal
- Throws:
SAXException
-
fatal
- Throws:
SAXException
-