|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--org.xml.sax.HandlerBase
|
+--uk.co.demon.ursus.dom.SAXAdapter
David Megginson's SAX demo, adapted gently to form a generic SAX implementation - SAXAdapter implies all methods have minimal implementations. Comments are from both authors. Where possible I have left in David's comments in case others wish to hack this code. David's code is commented out through slash-star-dash-dash.
Must be subclassed
| Field Summary | |
static int |
AELFRED
|
static java.lang.String |
defaultParserClassName
|
static int |
defaultParserType
|
static int |
DXP
|
static int |
LARK
|
static int |
MSXML
|
static int |
nParserTypes
|
protected org.xml.sax.Parser |
parser
|
static java.lang.String[] |
parserTypeStrings
|
protected java.io.StringReader |
reader
|
protected java.lang.String |
urlString
|
static int |
XERCESNV
|
static int |
XERCESSAX
|
static int |
XML4J
|
static int |
XP
|
| Constructor Summary | |
SAXAdapter()
Uses default parser if none supplied later |
|
SAXAdapter(org.xml.sax.Parser parser)
Uses given parser |
|
SAXAdapter(java.lang.String parserClassName)
Uses given parser name |
|
| Method Summary | |
static void |
addAttributes(org.w3c.dom.Element element,
org.xml.sax.AttributeList attributeList)
|
static java.lang.String |
attributeString(org.xml.sax.AttributeList attributeList)
|
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data inside an element. |
protected void |
elementCounter()
|
void |
endDocument()
Receive notification of the end of the document. |
void |
endElement(java.lang.String name)
Receive notification of the end of an element. |
void |
error(org.xml.sax.SAXParseException e)
Receive notification of a recoverable parser error. |
void |
fatalError(org.xml.sax.SAXParseException e)
Report a fatal XML parsing error. |
java.lang.String |
getErrorMessage(org.xml.sax.SAXParseException e)
get an error message string from a SAXParseException |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
static void |
main(java.lang.String[] args)
Main entry point for an application. |
void |
notationDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Receive notification of a notation declaration. |
void |
parse(java.lang.String urlString)
create a new SAXTree. |
void |
parse(java.io.StringReader reader)
parse. |
void |
parse(java.lang.String urlString,
java.io.StringReader reader,
java.lang.String parserClassName)
parse. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Resolve an external entity. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
Receive a Locator object for document events. |
void |
setParser(org.xml.sax.Parser p)
installs a parser |
org.xml.sax.Parser |
setParser(java.lang.String parserClassName)
creates a parser from the parserClassName and installs |
void |
startDocument()
Receive notification of the beginning of the document. |
void |
startElement(java.lang.String name,
org.xml.sax.AttributeList attributes)
Receive notification of the start of an element. |
void |
unparsedEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String notationName)
Receive notification of an unparsed entity declaration. |
void |
warning(org.xml.sax.SAXParseException e)
Receive notification of a parser warning. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final int AELFRED
public static final int DXP
public static final int LARK
public static final int MSXML
public static final int XML4J
public static final int XP
public static final int XERCESNV
public static final int XERCESSAX
public static final int nParserTypes
public static final java.lang.String[] parserTypeStrings
public static final int defaultParserType
public static final java.lang.String defaultParserClassName
protected java.lang.String urlString
protected java.io.StringReader reader
protected org.xml.sax.Parser parser
| Constructor Detail |
public SAXAdapter()
public SAXAdapter(java.lang.String parserClassName)
throws java.lang.Exception
public SAXAdapter(org.xml.sax.Parser parser)
| Method Detail |
public org.xml.sax.Parser setParser(java.lang.String parserClassName)
throws java.lang.Exception
public void setParser(org.xml.sax.Parser p)
public void parse(java.lang.String urlString,
java.io.StringReader reader,
java.lang.String parserClassName)
throws java.lang.Exception
String - urlString the URL with the XML document
Create a SAX from a UTF-16 character stream.
From DM's CharacterStreamDemo; the default parser is used. Precede
this by a call of the form:StringReader - reader the StringReader created from the String
public void parse(java.lang.String urlString)
throws java.lang.Exception
String - urlString the URL with the XML document
Create a SAX from a UTF-16 character stream.
From DM's CharacterStreamDemo; the default parser is used. Precede
this by a call of the form:StringReader - reader the StringReader created from the String
public void parse(java.io.StringReader reader)
throws java.lang.Exception
String - urlString the URL with the XML document
Create a SAX from a UTF-16 character stream.
From DM's CharacterStreamDemo; the default parser is used. Precede
this by a call of the form:StringReader - reader the StringReader created from the String
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws org.xml.sax.SAXException
publicId - The public identifer, or null if none is
available.systemId - The system identifier provided in the XML
document.EntityResolver.resolveEntity(java.lang.String, java.lang.String)
public void notationDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
name - The notation name.publicId - The notation public identifier, or null if not
available.systemId - The notation system identifier.DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
public void unparsedEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String notationName)
name - The entity name.publicId - The entity public identifier, or null if not
available.systemId - The entity system identifier.notationName - The name of the associated notation.DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)public void setDocumentLocator(org.xml.sax.Locator locator)
locator - A locator for all SAX document events.DocumentHandler.setDocumentLocator(org.xml.sax.Locator),
Locator
public void startDocument()
throws org.xml.sax.SAXException
DocumentHandler.startDocument()
public void endDocument()
throws org.xml.sax.SAXException
DocumentHandler.endDocument()
public void startElement(java.lang.String name,
org.xml.sax.AttributeList attributes)
throws org.xml.sax.SAXException
name - The element type name.attributes - The specified or defaulted attributes.DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)protected void elementCounter()
public void endElement(java.lang.String name)
throws org.xml.sax.SAXException
name - The element type name.attributes - The specified or defaulted attributes.DocumentHandler.endElement(java.lang.String)
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
ch - The characters.start - The start position in the character array.length - The number of characters to use from the
character array.DocumentHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
ch - The whitespace characters.start - The start position in the character array.length - The number of characters to use from the
character array.DocumentHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(java.lang.String target,
java.lang.String data)
throws org.xml.sax.SAXException
target - The processing instruction target.data - The processing instruction data, or null if
none is supplied.DocumentHandler.processingInstruction(java.lang.String, java.lang.String)
public void warning(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
e - The warning information encoded as an exception.ErrorHandler.warning(org.xml.sax.SAXParseException),
SAXParseException
public void error(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
e - The warning information encoded as an exception.ErrorHandler.warning(org.xml.sax.SAXParseException),
SAXParseException
public void fatalError(org.xml.sax.SAXParseException e)
throws org.xml.sax.SAXException
e - The error information encoded as an exception.ErrorHandler.fatalError(org.xml.sax.SAXParseException),
SAXParseExceptionpublic java.lang.String getErrorMessage(org.xml.sax.SAXParseException e)
public static java.lang.String attributeString(org.xml.sax.AttributeList attributeList)
public static void addAttributes(org.w3c.dom.Element element,
org.xml.sax.AttributeList attributeList)
public static void main(java.lang.String[] args)
throws java.lang.Exception
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||