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.2 2009-04-16 15:25:49 snajper Exp $
    Author:
    David Brownell, Janet Koenig, Kohsuke KAWAGUCHI
    • Constructor Detail

      • DTDParser

        public DTDParser()
        Constructs a DTDParser.
    • Method Detail

      • 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).
        Throws:
        SAXException - for errors
      • getLocale

        public Locale getLocale()
        Returns the diagnostic locale.
        Returns:
        the diagnostic locale
      • chooseLocale

        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 - 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:
        MessageCatalog
      • setEntityResolver

        public void setEntityResolver​(EntityResolver r)
        Lets applications control entity resolution.
        Parameters:
        r - EntityResolver
      • getEntityResolver

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

        public void setDtdHandler​(DTDEventListener handler)
        Used by applications to set handling of DTD parsing events.
        Parameters:
        handler -
      • getDtdHandler

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

        public String getPublicId()
      • getSystemId

        public String getSystemId()
      • getLineNumber

        public int getLineNumber()
      • getColumnNumber

        public int getColumnNumber()