utils.ptplot5_2.com.microstar.xml.demo
Class DtdDemo

java.lang.Object
  |
  +--utils.ptplot5_2.com.microstar.xml.demo.XmlApp
        |
        +--utils.ptplot5_2.com.microstar.xml.demo.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:
com.microstar.xml.XmlParser, com.microstar.xml.XmlHandler, XmlApp

Field Summary
 
Fields inherited from class utils.ptplot5_2.com.microstar.xml.demo.XmlApp
isApplet, parser
 
Constructor Summary
DtdDemo()
           
 
Method Summary
 void doctypeDecl(java.lang.String name, java.lang.String pubid, java.lang.String sysid)
          Dump the DTD.
 void dumpAttributes(java.lang.String elname)
          Dump attributes for an element.
 void dumpElements()
          Produce normalised declarations for all elements.
 void dumpEntities()
          Produce normalised declarations for all general entities.
 void dumpNotations()
          Produce normalised declarations for all notations.
 void endDocument(int errorCount)
          Print a comment showing where the DTD (if any) ends.
static void main(java.lang.String[] args)
          Entry point for an application (applets enter through XmlApp.init()).
 java.lang.String makeAttributeType(java.lang.String elname, java.lang.String aname)
          Generate the attribute type as a normalised string.
 java.lang.String makeAttributeValue(java.lang.String elname, java.lang.String aname)
          Generate a full attribute default value.
 java.lang.String makeExternalIdentifiers(java.lang.String pubid, java.lang.String sysid)
          Construct a string equivalent of external identifiers.
 java.lang.String makeLiteral(java.lang.String data)
          Quote a literal, and escape any '"' or non-ASCII characters within it.
 void startDocument()
          Print a comment showing where the DTD (if any) begins.
 
Methods inherited from class utils.ptplot5_2.com.microstar.xml.demo.XmlApp
attribute, charData, endDocument, endElement, endExternalEntity, error, ignorableWhitespace, processingInstruction, resolveEntity, startElement, startExternalEntity
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

java.lang.Exception
See Also:
XmlApp

startDocument

public void startDocument()
Print a comment showing where the DTD (if any) begins.

Specified by:
startDocument in interface XmlHandler
Overrides:
startDocument in class XmlApp
See Also:
com.microstar.xml.XmlHandler#startDocument

endDocument

public void endDocument(int errorCount)
Print a comment showing where the DTD (if any) ends.


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
See Also:
dumpNotations(), dumpEntities(), dumpElements()

dumpNotations

public void dumpNotations()
Produce normalised declarations for all notations.

See Also:
makeExternalIdentifiers(java.lang.String, java.lang.String)

dumpEntities

public void dumpEntities()
Produce normalised declarations for all general entities.

See Also:
makeLiteral(java.lang.String), makeExternalIdentifiers(java.lang.String, java.lang.String)

dumpElements

public void dumpElements()
Produce normalised declarations for all elements.

See Also:
dumpAttributes(java.lang.String)

dumpAttributes

public void dumpAttributes(java.lang.String elname)
Dump attributes for an element.

See Also:
makeAttributeType(java.lang.String, java.lang.String), makeAttributeValue(java.lang.String, java.lang.String)

makeAttributeType

public java.lang.String makeAttributeType(java.lang.String elname,
                                          java.lang.String aname)
Generate 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.

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.

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.