Package com.sun.xml.dtdparser
Class DTDParser
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.
- Version:
- $Id: DTDParser.java,v 1.2 2009-04-16 15:25:49 snajper Exp $
-
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 char[]
protected final Set
private boolean
private DTDEventListener
(package private) SimpleHashtable
private SimpleHashtable
private InputEntity
private Locale
private static final Logger
(package private) static final DTDParser.Catalog
private DTDParser.NameCache
private char[]
(package private) Hashtable
private SimpleHashtable
private EntityResolver
(package private) static final String
(package private) static final String
private StringBuffer
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
private void
chooseLocale
(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) void
private void
expandEntityInLiteral
(String name, SimpleHashtable table, boolean isEntityValue) private void
private void
private void
private char
getc()
int
private void
getcps
(String elementName, InputEntity start) Returns the handler used to for DTD parsing events.Returns the object used to resolve entitiesprivate short
int
Returns the diagnostic locale.private String
getMarkupDeclname
(String roleId, boolean qname) private void
getMixed
(String elementName, InputEntity start) private short
getMixedOrChildren
(String elementName) returns content model type.private String
private String
getQuotedString
(String type, String extra) private void
init()
private boolean
private boolean
private boolean
maybeComment
(boolean skipStart) private boolean
private boolean
To validate, subclassers should at this time make sure that values are of the declared types: ID and IDREF(S) values are Names NMTOKEN(S) are Nmtokens ENUMERATION values match one of the tokens NOTATION values match a notation name ENTITIY(IES) values match an unparsed external entityprivate boolean
private ExternalEntity
private String
private DTDParser.NameCacheEntry
private boolean
private boolean
private boolean
private boolean
maybePI
(boolean skipStart) private String
maybeReadAttribute
(String name, boolean must) private void
private boolean
private DTDParser.NameCacheEntry
nameCharString
(char c) private void
private String
normalize
(boolean invalidIfNeeded) void
Parse a DTD.void
parse
(InputSource in) Parse a DTD.private int
private void
parseInternal
(InputSource input) private void
parseLiteral
(boolean isEntityValue) private String
private String
private boolean
private InputEntity
private void
pushReader
(char[] buf, String name, boolean isGeneral) private boolean
pushReader
(ExternalEntity next) private void
readEncoding
(boolean must) private void
readVersion
(boolean must, String versionNum) private void
reportConnector
(char type) void
setDtdHandler
(DTDEventListener handler) Used by applications to set handling of DTD parsing events.void
Lets applications control entity resolution.void
Used by applications to request locale for diagnostics.private int
surrogatesToCharTmp
(int ucs4) private void
ungetc()
private void
private void
whitespace
(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 char[] charTmp -
doLexicalPE
private boolean doLexicalPE -
declaredElements
-
params
-
notations
Hashtable notations -
entities
SimpleHashtable entities -
ids
-
dtdHandler
-
resolver
-
locale
-
strANY
- See Also:
-
strEMPTY
- See Also:
-
LOGGER
-
XmlLang
- See Also:
-
messages
-
-
Constructor Details
-
DTDParser
public 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
-
getLocale
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
- See Also:
-
setEntityResolver
Lets applications control entity resolution. -
getEntityResolver
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. -
parse
Parse a DTD.- Throws:
IOException
SAXException
-
parse
Parse a DTD.- Throws:
IOException
SAXException
-
init
private void init() -
builtin
-
parseInternal
- Throws:
IOException
SAXException
-
afterRoot
- Throws:
SAXException
-
whitespace
- Throws:
IOException
SAXException
-
maybeWhitespace
- Throws:
IOException
SAXException
-
maybeGetName
- Throws:
IOException
SAXException
-
maybeGetNameCacheEntry
- Throws:
IOException
SAXException
-
getNmtoken
- Throws:
IOException
SAXException
-
nameCharString
- Throws:
IOException
SAXException
-
parseLiteral
- Throws:
IOException
SAXException
-
expandEntityInLiteral
private void expandEntityInLiteral(String name, SimpleHashtable table, boolean isEntityValue) throws IOException, SAXException - Throws:
IOException
SAXException
-
getQuotedString
- Throws:
IOException
SAXException
-
parsePublicId
- Throws:
IOException
SAXException
-
maybeComment
- Throws:
IOException
SAXException
-
maybePI
- Throws:
IOException
SAXException
-
maybeReadAttribute
- Throws:
IOException
SAXException
-
readVersion
- Throws:
IOException
SAXException
-
getMarkupDeclname
- Throws:
IOException
SAXException
-
maybeMarkupDecl
- Throws:
IOException
SAXException
-
isXmlLang
-
maybeElementDecl
To validate, subclassers should at this time make sure that values are of the declared types:- ID and IDREF(S) values are Names
- NMTOKEN(S) are Nmtokens
- ENUMERATION values match one of the tokens
- NOTATION values match a notation name
- ENTITIY(IES) values match an unparsed external entity
Separately, make sure IDREF values match some ID provided in the document (in the afterRoot method).
- Throws:
IOException
SAXException
-
getMixedOrChildren
returns content model type.- Throws:
IOException
SAXException
-
getcps
- Throws:
IOException
SAXException
-
reportConnector
- Throws:
SAXException
-
getFrequency
- Throws:
IOException
SAXException
-
getMixed
- Throws:
IOException
SAXException
-
maybeAttlistDecl
- Throws:
IOException
SAXException
-
normalize
-
maybeConditionalSect
- Throws:
IOException
SAXException
-
parseCharNumber
- Throws:
IOException
SAXException
-
surrogatesToCharTmp
- Throws:
SAXException
-
maybePEReference
- Throws:
IOException
SAXException
-
maybeEntityDecl
- Throws:
IOException
SAXException
-
maybeExternalID
- Throws:
IOException
SAXException
-
parseSystemId
- Throws:
IOException
SAXException
-
maybeTextDecl
- Throws:
IOException
SAXException
-
externalParameterEntity
- Throws:
IOException
SAXException
-
readEncoding
- Throws:
IOException
SAXException
-
maybeNotationDecl
- Throws:
IOException
SAXException
-
getc
- Throws:
IOException
SAXException
-
ungetc
private void ungetc() -
peek
- Throws:
IOException
SAXException
-
peekDeclaration
- Throws:
IOException
SAXException
-
nextChar
- Throws:
IOException
SAXException
-
pushReader
- Throws:
SAXException
-
pushReader
- Throws:
IOException
SAXException
-
getPublicId
-
getSystemId
-
getLineNumber
public int getLineNumber() -
getColumnNumber
public int getColumnNumber() -
warning
- Throws:
SAXException
-
error
- Throws:
SAXException
-
fatal
- Throws:
SAXException
-
fatal
- Throws:
SAXException
-