com.sun.msv.scanner.dtd

Class DTDParser


public class DTDParser
extends Object

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.10 2005/04/25 17:31:43 kohsuke Exp $
Authors:
David Brownell
Janet Koenig
Kohsuke KAWAGUCHI

Field Summary

static String
TYPE_CDATA
static String
TYPE_ENTITIES
static String
TYPE_ENTITY
static String
TYPE_ENUMERATION
static String
TYPE_ID
static String
TYPE_IDREF
static String
TYPE_IDREFS
static String
TYPE_NMTOKEN
static String
TYPE_NMTOKENS
static String
TYPE_NOTATION

Method Summary

Locale
chooseLocale(languages[] )
Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser.
int
getColumnNumber()
DTDEventListener
getDtdHandler()
Returns the handler used to for DTD parsing events.
EntityResolver
getEntityResolver()
Returns the object used to resolve entities
int
getLineNumber()
Locale
getLocale()
Returns the diagnostic locale.
String
getPublicId()
String
getSystemId()
void
parse(InputSource in)
Parse a DTD.
void
parse(String uri)
Parse a DTD.
void
setDtdHandler(DTDEventListener handler)
Used by applications to set handling of DTD parsing events.
void
setEntityResolver(EntityResolver r)
Lets applications control entity resolution.
void
setLocale(Locale l)
Used by applications to request locale for diagnostics.

Field Details

TYPE_CDATA

public static final String TYPE_CDATA

TYPE_ENTITIES

public static final String TYPE_ENTITIES

TYPE_ENTITY

public static final String TYPE_ENTITY

TYPE_ENUMERATION

public static final String TYPE_ENUMERATION

TYPE_ID

public static final String TYPE_ID

TYPE_IDREF

public static final String TYPE_IDREF

TYPE_IDREFS

public static final String TYPE_IDREFS

TYPE_NMTOKEN

public static final String TYPE_NMTOKEN

TYPE_NMTOKENS

public static final String TYPE_NMTOKENS

TYPE_NOTATION

public static final String TYPE_NOTATION

Method Details

chooseLocale

public Locale chooseLocale(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:
Returns:
The chosen locale, or null.

getColumnNumber

public int getColumnNumber()

getDtdHandler

public DTDEventListener getDtdHandler()
Returns the handler used to for DTD parsing events.

getEntityResolver

public EntityResolver getEntityResolver()
Returns the object used to resolve entities

getLineNumber

public int getLineNumber()

getLocale

public Locale getLocale()
Returns the diagnostic locale.

getPublicId

public String getPublicId()

getSystemId

public String getSystemId()

parse

public void parse(InputSource in)
            throws IOException,
                   SAXException
Parse a DTD.

parse

public void parse(String uri)
            throws IOException,
                   SAXException
Parse a DTD.

setDtdHandler

public void setDtdHandler(DTDEventListener handler)
Used by applications to set handling of DTD parsing events.

setEntityResolver

public void setEntityResolver(EntityResolver r)
Lets applications control entity resolution.

setLocale

public void setLocale(Locale l)
            throws SAXException
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).