Package com.microstar.xml.demo
Class DtdDemo
- java.lang.Object
-
- com.microstar.xml.demo.XmlApp
-
- 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:
XmlParser
,XmlHandler
,XmlApp
-
-
Constructor Summary
Constructors Constructor Description DtdDemo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 com.microstar.xml.demo.XmlApp
attribute, charData, endDocument, endElement, endExternalEntity, error, ignorableWhitespace, processingInstruction, resolveEntity, startElement, startExternalEntity
-
-
-
-
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
-
startDocument
public void startDocument()
Print a comment showing where the DTD (if any) begins.- Specified by:
startDocument
in interfaceXmlHandler
- Overrides:
startDocument
in classXmlApp
- See Also:
XmlHandler.startDocument()
-
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 interfaceXmlHandler
- Overrides:
doctypeDecl
in classXmlApp
- 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()
-
dumpNotations
public void dumpNotations()
Produce normalised declarations for all notations.
-
dumpEntities
public void dumpEntities()
Produce normalised declarations for all general entities.
-
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.- Parameters:
elname
- The element name.- 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.- 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 identifiersysid
- 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
-
-