Package com.sun.xml.dtdparser
Class DTDParser
- java.lang.Object
-
- com.sun.xml.dtdparser.DTDParser
-
public class DTDParser extends java.lang.ObjectThis 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 $
- Author:
- David Brownell, Janet Koenig, Kohsuke KAWAGUCHI
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.SetdeclaredElementsstatic java.lang.StringTYPE_CDATAstatic java.lang.StringTYPE_ENTITIESstatic java.lang.StringTYPE_ENTITYstatic java.lang.StringTYPE_ENUMERATIONstatic java.lang.StringTYPE_IDstatic java.lang.StringTYPE_IDREFstatic java.lang.StringTYPE_IDREFSstatic java.lang.StringTYPE_NMTOKENstatic java.lang.StringTYPE_NMTOKENSstatic java.lang.StringTYPE_NOTATION
-
Constructor Summary
Constructors Constructor Description DTDParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.LocalechooseLocale(java.lang.String[] languages)Chooses a client locale to use for diagnostics, using the first language specified in the list that is supported by this parser.intgetColumnNumber()DTDEventListenergetDtdHandler()Returns the handler used to for DTD parsing events.org.xml.sax.EntityResolvergetEntityResolver()Returns the object used to resolve entitiesintgetLineNumber()java.util.LocalegetLocale()Returns the diagnostic locale.java.lang.StringgetPublicId()java.lang.StringgetSystemId()voidparse(java.lang.String uri)Parse a DTD.voidparse(org.xml.sax.InputSource in)Parse a DTD.voidsetDtdHandler(DTDEventListener handler)Used by applications to set handling of DTD parsing events.voidsetEntityResolver(org.xml.sax.EntityResolver r)Lets applications control entity resolution.voidsetLocale(java.util.Locale l)Used by applications to request locale for diagnostics.
-
-
-
Field Detail
-
TYPE_CDATA
public static final java.lang.String TYPE_CDATA
- See Also:
- Constant Field Values
-
TYPE_ID
public static final java.lang.String TYPE_ID
- See Also:
- Constant Field Values
-
TYPE_IDREF
public static final java.lang.String TYPE_IDREF
- See Also:
- Constant Field Values
-
TYPE_IDREFS
public static final java.lang.String TYPE_IDREFS
- See Also:
- Constant Field Values
-
TYPE_ENTITY
public static final java.lang.String TYPE_ENTITY
- See Also:
- Constant Field Values
-
TYPE_ENTITIES
public static final java.lang.String TYPE_ENTITIES
- See Also:
- Constant Field Values
-
TYPE_NMTOKEN
public static final java.lang.String TYPE_NMTOKEN
- See Also:
- Constant Field Values
-
TYPE_NMTOKENS
public static final java.lang.String TYPE_NMTOKENS
- See Also:
- Constant Field Values
-
TYPE_NOTATION
public static final java.lang.String TYPE_NOTATION
- See Also:
- Constant Field Values
-
TYPE_ENUMERATION
public static final java.lang.String TYPE_ENUMERATION
- See Also:
- Constant Field Values
-
declaredElements
protected final java.util.Set declaredElements
-
-
Method Detail
-
setLocale
public void setLocale(java.util.Locale l) throws org.xml.sax.SAXExceptionUsed 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:
org.xml.sax.SAXException
-
getLocale
public java.util.Locale getLocale()
Returns the diagnostic locale.
-
chooseLocale
public java.util.Locale chooseLocale(java.lang.String[] languages) throws org.xml.sax.SAXExceptionChooses 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:
org.xml.sax.SAXException- See Also:
MessageCatalog
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver r)
Lets applications control entity resolution.
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
Returns the object used to resolve entities
-
setDtdHandler
public void setDtdHandler(DTDEventListener handler)
Used by applications to set handling of DTD parsing events.
-
getDtdHandler
public DTDEventListener getDtdHandler()
Returns the handler used to for DTD parsing events.
-
parse
public void parse(org.xml.sax.InputSource in) throws java.io.IOException, org.xml.sax.SAXExceptionParse a DTD.- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
parse
public void parse(java.lang.String uri) throws java.io.IOException, org.xml.sax.SAXExceptionParse a DTD.- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
getPublicId
public java.lang.String getPublicId()
-
getSystemId
public java.lang.String getSystemId()
-
getLineNumber
public int getLineNumber()
-
getColumnNumber
public int getColumnNumber()
-
-