Top Description Inners Fields Constructors Methods
com.sun.msv.scanner.dtd

public Class DTDParser

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Enumeration, .Hashtable, .Locale, .Set, .Vector, org.xml.sax.EntityResolver, .InputSource, .Locator, .SAXException, .SAXParseException

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.
Authors
David Brownell, Janet Koenig, Kohsuke KAWAGUCHI

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private char[]
protected final Set<String>
private boolean
private DTDEventListener
pack-priv SimpleHashtable
private SimpleHashtable
private InputEntity
private Locale
pack-priv static final DTDParser.Catalog
private DTDParser.NameCache
private char[]
pack-priv Hashtable<String, Object>
private SimpleHashtable
private EntityResolver
pack-priv static final String
pack-priv static final String
private StringBuffer
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv void
private void
builtin(String entityName, String entityValue)

public Locale

Returns:

The chosen locale, or null.
chooseLocale
(String[]
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.
languages
)

Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser.

pack-priv void
error(String messageId, Object[] parameters)

private void
expandEntityInLiteral(String name, SimpleHashtable table, boolean isEntityValue)

private void
private void
fatal(String messageId)

private void
fatal(String messageId, Object[] parameters)

private char
getc()

public int
private void
getcps(String elementName, InputEntity start)

public DTDEventListener
getDtdHandler()

Returns the handler used to for DTD parsing events.

public EntityResolver
getEntityResolver()

Returns the object used to resolve entities

private short
public int
public Locale
getLocale()

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
public String
private String
public String
private void
init()

private boolean
private boolean
private boolean
maybeComment(boolean skipStart)

private boolean
private boolean
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
private 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
private void
nextChar(char c, String location, String near)

private String
normalize(boolean invalidIfNeeded)

public void
parse(InputSource in)

Parse a DTD.

public void
parse(String uri)

Parse a DTD.

private int
private void
private void
parseLiteral(boolean isEntityValue)

private String
private String
private boolean
private InputEntity
private void
pushReader(char[] buf, String name, boolean isGeneral)

private boolean
private void
readEncoding(boolean must)

private void
readVersion(boolean must, String versionNum)

private void
reportConnector(char type)

public void
setDtdHandler(DTDEventListener handler)

Used by applications to set handling of DTD parsing events.

public void
setEntityResolver(EntityResolver r)

Lets applications control entity resolution.

public void
setLocale(Locale
The locale to use, or null to use system defaults (which may include only message IDs).
l
)

Used by applications to request locale for diagnostics.

private int
private void
private void
warning(String messageId, Object[] parameters)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charTmpback to summary
private char[] charTmp
declaredElementsback to summary
protected final Set<String> declaredElements
doLexicalPEback to summary
private boolean doLexicalPE
dtdHandlerback to summary
private DTDEventListener dtdHandler
entitiesback to summary
pack-priv SimpleHashtable entities
idsback to summary
private SimpleHashtable ids
inback to summary
private InputEntity in
localeback to summary
private Locale locale
messagesback to summary
pack-priv static final DTDParser.Catalog messages
nameCacheback to summary
private DTDParser.NameCache nameCache
nameTmpback to summary
private char[] nameTmp
notationsback to summary
pack-priv Hashtable<String, Object> notations
paramsback to summary
private SimpleHashtable params
resolverback to summary
private EntityResolver resolver
strANYback to summary
pack-priv static final String strANY
strEMPTYback to summary
pack-priv static final String strEMPTY
strTmpback to summary
private StringBuffer strTmp
TYPE_CDATAback to summary
public static final String TYPE_CDATA
TYPE_ENTITIESback to summary
public static final String TYPE_ENTITIES
TYPE_ENTITYback to summary
public static final String TYPE_ENTITY
TYPE_ENUMERATIONback to summary
public static final String TYPE_ENUMERATION
TYPE_IDback to summary
public static final String TYPE_ID
TYPE_IDREFback to summary
public static final String TYPE_IDREF
TYPE_IDREFSback to summary
public static final String TYPE_IDREFS
TYPE_NMTOKENback to summary
public static final String TYPE_NMTOKEN
TYPE_NMTOKENSback to summary
public static final String TYPE_NMTOKENS
TYPE_NOTATIONback to summary
public static final String TYPE_NOTATION
XmlLangback to summary
private static final String XmlLang

Constructor Detail

DTDParserback to summary
public DTDParser()

Method Detail

afterRootback to summary
pack-priv void afterRoot() throws SAXException
builtinback to summary
private void builtin(String entityName, String entityValue)
chooseLocaleback to summary
public Locale chooseLocale(String[] languages) throws SAXException

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:String[]

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:Locale

The chosen locale, or null.

See Also
MessageCatalog
errorback to summary
pack-priv void error(String messageId, Object[] parameters) throws SAXException
expandEntityInLiteralback to summary
private void expandEntityInLiteral(String name, SimpleHashtable table, boolean isEntityValue) throws IOException, SAXException
externalParameterEntityback to summary
private void externalParameterEntity(ExternalEntity next) throws IOException, SAXException
fatalback to summary
private void fatal(String messageId) throws SAXException
fatalback to summary
private void fatal(String messageId, Object[] parameters) throws SAXException
getcback to summary
private char getc() throws IOException, SAXException
getColumnNumberback to summary
public int getColumnNumber()
getcpsback to summary
private void getcps(String elementName, InputEntity start) throws IOException, SAXException
getDtdHandlerback to summary
public DTDEventListener getDtdHandler()

Returns the handler used to for DTD parsing events.

getEntityResolverback to summary
public EntityResolver getEntityResolver()

Returns the object used to resolve entities

getFrequencyback to summary
private short getFrequency() throws IOException, SAXException
getLineNumberback to summary
public int getLineNumber()
getLocaleback to summary
public Locale getLocale()

Returns the diagnostic locale.

getMarkupDeclnameback to summary
private String getMarkupDeclname(String roleId, boolean qname) throws IOException, SAXException
getMixedback to summary
private void getMixed(String elementName, InputEntity start) throws IOException, SAXException
getMixedOrChildrenback to summary
private short getMixedOrChildren(String elementName) throws IOException, SAXException

returns content model type.

getNmtokenback to summary
private String getNmtoken() throws IOException, SAXException
getPublicIdback to summary
public String getPublicId()
getQuotedStringback to summary
private String getQuotedString(String type, String extra) throws IOException, SAXException
getSystemIdback to summary
public String getSystemId()
initback to summary
private void init()
isXmlLangback to summary
private boolean isXmlLang(String value)
maybeAttlistDeclback to summary
private boolean maybeAttlistDecl() throws IOException, SAXException
maybeCommentback to summary
private boolean maybeComment(boolean skipStart) throws IOException, SAXException
maybeConditionalSectback to summary
private boolean maybeConditionalSect() throws IOException, SAXException
maybeElementDeclback to summary
private boolean maybeElementDecl() throws IOException, SAXException

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).

maybeEntityDeclback to summary
private boolean maybeEntityDecl() throws IOException, SAXException
maybeExternalIDback to summary
private ExternalEntity maybeExternalID() throws IOException, SAXException
maybeGetNameback to summary
private String maybeGetName() throws IOException, SAXException
maybeGetNameCacheEntryback to summary
private DTDParser.NameCacheEntry maybeGetNameCacheEntry() throws IOException, SAXException
maybeMarkupDeclback to summary
private boolean maybeMarkupDecl() throws IOException, SAXException
maybeNotationDeclback to summary
private boolean maybeNotationDecl() throws IOException, SAXException
maybePEReferenceback to summary
private boolean maybePEReference() throws IOException, SAXException
maybePIback to summary
private boolean maybePI(boolean skipStart) throws IOException, SAXException
maybeReadAttributeback to summary
private String maybeReadAttribute(String name, boolean must) throws IOException, SAXException
maybeTextDeclback to summary
private void maybeTextDecl() throws IOException, SAXException
maybeWhitespaceback to summary
private boolean maybeWhitespace() throws IOException, SAXException
nameCharStringback to summary
private DTDParser.NameCacheEntry nameCharString(char c) throws IOException, SAXException
nextCharback to summary
private void nextChar(char c, String location, String near) throws IOException, SAXException
normalizeback to summary
private String normalize(boolean invalidIfNeeded)
parseback to summary
public void parse(InputSource in) throws IOException, SAXException

Parse a DTD.

parseback to summary
public void parse(String uri) throws IOException, SAXException

Parse a DTD.

parseCharNumberback to summary
private int parseCharNumber() throws IOException, SAXException
parseInternalback to summary
private void parseInternal(InputSource input) throws IOException, SAXException
parseLiteralback to summary
private void parseLiteral(boolean isEntityValue) throws IOException, SAXException
parsePublicIdback to summary
private String parsePublicId() throws IOException, SAXException
parseSystemIdback to summary
private String parseSystemId() throws IOException, SAXException
peekback to summary
private boolean peek(String s) throws IOException, SAXException
peekDeclarationback to summary
private InputEntity peekDeclaration(String s) throws IOException, SAXException
pushReaderback to summary
private void pushReader(char[] buf, String name, boolean isGeneral) throws SAXException
pushReaderback to summary
private boolean pushReader(ExternalEntity next) throws IOException, SAXException
readEncodingback to summary
private void readEncoding(boolean must) throws IOException, SAXException
readVersionback to summary
private void readVersion(boolean must, String versionNum) throws IOException, SAXException
reportConnectorback to summary
private void reportConnector(char type) throws SAXException
setDtdHandlerback to summary
public void setDtdHandler(DTDEventListener handler)

Used by applications to set handling of DTD parsing events.

setEntityResolverback to summary
public void setEntityResolver(EntityResolver r)

Lets applications control entity resolution.

setLocaleback to summary
public void setLocale(Locale l) throws SAXException

Used by applications to request locale for diagnostics.

Parameters
l:Locale

The locale to use, or null to use system defaults (which may include only message IDs).

surrogatesToCharTmpback to summary
private int surrogatesToCharTmp(int ucs4) throws SAXException
ungetcback to summary
private void ungetc()
warningback to summary
private void warning(String messageId, Object[] parameters) throws SAXException
whitespaceback to summary
private void whitespace(String roleId) throws IOException, SAXException
com.sun.msv.scanner.dtd back to summary

pack-priv final Class DTDParser.Catalog

extends MessageCatalog
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from com.sun.msv.scanner.dtd.MessageCatalog:
chooseLocalegetMessagegetMessageisLocaleSupported

Constructor Detail

Catalogback to summary
pack-priv Catalog()
com.sun.msv.scanner.dtd back to summary

pack-priv Class DTDParser.NameCache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv DTDParser.NameCacheEntry[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv String
lookup(char[] value, int len)

pack-priv DTDParser.NameCacheEntry
lookupEntry(char[] value, int len)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hashtableback to summary
pack-priv DTDParser.NameCacheEntry[] hashtable

Constructor Detail

NameCacheback to summary
pack-priv NameCache()

Method Detail

lookupback to summary
pack-priv String lookup(char[] value, int len)
lookupEntryback to summary
pack-priv DTDParser.NameCacheEntry lookupEntry(char[] value, int len)
com.sun.msv.scanner.dtd back to summary

pack-priv Class DTDParser.NameCacheEntry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv char[]
pack-priv String
pack-priv DTDParser.NameCacheEntry

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
matches(char[] value, int len)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charsback to summary
pack-priv char[] chars
nameback to summary
pack-priv String name
nextback to summary
pack-priv DTDParser.NameCacheEntry next

Constructor Detail

NameCacheEntryback to summary
pack-priv NameCacheEntry()

Method Detail

matchesback to summary
pack-priv boolean matches(char[] value, int len)