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
urlparameter.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 voiddoctypeDecl(java.lang.String name, java.lang.String pubid, java.lang.String sysid)Dump the DTD.voiddumpAttributes(java.lang.String elname)Dump attributes for an element.voiddumpElements()Produce normalised declarations for all elements.voiddumpEntities()Produce normalised declarations for all general entities.voiddumpNotations()Produce normalised declarations for all notations.voidendDocument(int errorCount)Print a comment showing where the DTD (if any) ends.static voidmain(java.lang.String[] args)Entry point for an application (applets enter through XmlApp.init()).java.lang.StringmakeAttributeType(java.lang.String elname, java.lang.String aname)Generate the attribute type as a normalised string.java.lang.StringmakeAttributeValue(java.lang.String elname, java.lang.String aname)Generate a full attribute default value.java.lang.StringmakeExternalIdentifiers(java.lang.String pubid, java.lang.String sysid)Construct a string equivalent of external identifiers.java.lang.StringmakeLiteral(java.lang.String data)Quote a literal, and escape any '"' or non-ASCII characters within it.voidstartDocument()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.ExceptionEntry 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:
startDocumentin interfaceXmlHandler- Overrides:
startDocumentin 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:
doctypeDeclin interfaceXmlHandler- Overrides:
doctypeDeclin 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
-
-