Class DtdDemo

  • All Implemented Interfaces:
    XmlHandler

    public class DtdDemo
    extends XmlApp
    Demonstration application showing DTD queries.

    Usage: java DtdDemo <url>

    Or, use it as an applet, supplying the URL as the url parameter.

    Note: This does not preserve any processing instructions or parameter entities in the DTD; otherwise, produces a fully expanded and normalised version.

    Since:
    Ptolemy II 0.2
    Version:
    1.1
    Author:
    Copyright (c) 1997, 1998 by Microstar Software Ltd.;, written by David Megginson <dmeggins@microstar.com>
    See Also:
    XmlParser, XmlHandler, XmlApp
    • Constructor Detail

      • DtdDemo

        public DtdDemo()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Entry point for an application (applets enter through XmlApp.init()).
        Parameters:
        args - The arguments. The first argument should be the uri
        Throws:
        java.lang.Exception - If the parse fails
        See Also:
        XmlApp
      • endDocument

        public void endDocument​(int errorCount)
        Print a comment showing where the DTD (if any) ends.
        Parameters:
        errorCount - Ignored in this method.
      • doctypeDecl

        public void doctypeDecl​(java.lang.String name,
                                java.lang.String pubid,
                                java.lang.String sysid)
        Dump the DTD.

        Once this event is received, we know that the DTD is completely parsed, and can use AElfred's query routines to reconstruct a normalised version of it.

        Specified by:
        doctypeDecl in interface XmlHandler
        Overrides:
        doctypeDecl in class XmlApp
        Parameters:
        name - The document type name.
        pubid - The public identifier, or null if unspecified.
        sysid - The system identifier, or null if unspecified.
        See Also:
        dumpNotations(), dumpEntities(), dumpElements()
      • makeAttributeType

        public java.lang.String makeAttributeType​(java.lang.String elname,
                                                  java.lang.String aname)
        Generate the attribute type as a normalised string.
        Parameters:
        elname - The element name.
        aname - The attribute name.
        Returns:
        The attribute type as a normalised string.
      • makeAttributeValue

        public java.lang.String makeAttributeValue​(java.lang.String elname,
                                                   java.lang.String aname)
        Generate a full attribute default value.
        Parameters:
        elname - The element name.
        aname - The attribute name.
        Returns:
        The full attribute default value
        See Also:
        makeLiteral(java.lang.String)
      • makeExternalIdentifiers

        public java.lang.String makeExternalIdentifiers​(java.lang.String pubid,
                                                        java.lang.String sysid)
        Construct a string equivalent of external identifiers.
        Parameters:
        pubid - The public identifier
        sysid - The string id
        Returns:
        The external identifiers
        See Also:
        makeLiteral(java.lang.String)
      • makeLiteral

        public java.lang.String makeLiteral​(java.lang.String data)
        Quote a literal, and escape any '"' or non-ASCII characters within it.
        Parameters:
        data - The data
        Returns:
        the data as a literal