|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.DefaultHandler org.umber.bellows.loader.SAXLoader
Generic loader for arbitrary XML formats. Creates a Datum tree with identical structure to the XML input. Each element maps to a Datum or ListDatum object, and attributes are mapped to Datum properties.
Field Summary | |
static java.lang.String |
CRIMSON_READER
The fully qualified class for the Apache Crimson SAX2 XML Reader |
static java.lang.String |
DOCUMENT_INFO_PROPERTY
The name of the root property which contains all document-level info |
static java.lang.String |
NOTATION_NAME_PROPERTY
The name of the property which contains the NOTATION target name |
static java.lang.String |
NOTATION_PUBLIC_PROPERTY
The name of the property which contains the NOTATION PUBLIC value |
static java.lang.String |
NOTATION_SYSTEM_PROPERTY
The name of the property which contains the NOTATION SYSTEM value |
static java.lang.String |
NOTATION_TYPE
The Datum 'type' of all Datum objects which contain NOTATION content |
static java.lang.String |
PCDATA_PROPERTY
The name of the property which contains the actual PCDATA content |
static java.lang.String |
PCDATA_TYPE
The Datum 'type' of all Datum objects which contain PCDATA content |
static java.lang.String |
PI_DATA_PROPERTY
The name of the property which contains the PI content |
static java.lang.String |
PI_TARGET_PROPERTY
The name of the property which contains the PI target name |
static java.lang.String |
PI_TYPE
The Datum 'type' of all Datum objects which contain PI content |
static java.lang.String |
XERCES_READER
The fully qualified class for the Apache Xerces SAX2 XML Reader |
Constructor Summary | |
SAXLoader()
Creates a new instance of SAXLoader |
|
SAXLoader(java.lang.String readerClass)
Creates a new instance of SAXLoader with a custom parser. |
Method Summary | |
void |
attributeDecl(java.lang.String eName,
java.lang.String aName,
java.lang.String type,
java.lang.String valueDefault,
java.lang.String value)
Report an attribute type declaration. |
void |
characters(char[] ch,
int start,
int length)
SAX callback for processing XML PCDATA character data. |
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document. |
void |
elementDecl(java.lang.String name,
java.lang.String model)
Report an element type declaration. |
void |
endCDATA()
Report the end of a CDATA section. |
void |
endDocument()
Receive SAX notification of the end of the document. |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
SAX callback for ending an XML element. |
void |
endEntity(java.lang.String name)
Report the end of an entity. |
void |
endPrefixMapping(java.lang.String prefix)
Ends the scope of a prefix-URI Namespace mapping. |
void |
error(org.xml.sax.SAXParseException e)
SAX callback for reporting serious, but non-fatal parsing problems. |
void |
externalEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report a parsed external entity declaration. |
void |
fatalError(org.xml.sax.SAXParseException e)
SAX callback for reporting fatal parsing problems. |
void |
internalEntityDecl(java.lang.String name,
java.lang.String value)
Report an internal entity declaration. |
boolean |
isNotationsEnabled()
Determines if the loader should keep track of XML NOTATIONs. |
boolean |
isProcessingInstructionsEnabled()
Determines if the loader should keep track of XML processing instructions. |
boolean |
isStrictWhitespace()
Determines if the loader should unconditionally load up all whitespace in the XML document. |
boolean |
isUnicodeCheckEnabled()
Determines if the loader is currently configured to check for invalid Unicode characters. |
Datum |
load(java.io.Reader reader)
Parses an XML stream into a tree of Datum objects. |
Datum |
load(java.io.Reader reader,
java.lang.String baseURI)
Parses an XML stream into a tree of Datum objects using a base URI path to resolve relative paths in the XML document. |
Datum |
load(java.lang.String fileName)
Parses the given file into a tree of Datum objects. |
static void |
main(java.lang.String[] args)
Convenience method for testing dynamic XMLReader loading. |
void |
notationDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Receive notification of a notation declaration. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
Receives a Locator for describing the current document position. |
void |
setNotationsEnabled(boolean notationsEnabled)
Changes the current policy for handling XML NOTATIONs. |
void |
setProcessingInstructionsEnabled(boolean piEnabled)
Changes the current policy for handling XML processing instructions. |
void |
setStrictWhitespace(boolean strictWhitespace)
Sets the current strict whitespace policy. |
void |
setUnicodeCheckEnabled(boolean unicodeCheckEnabled)
Changes the current Unicode content checking policy. |
void |
setValidate(boolean validate)
Enables or disables the SAX XML validation mode. |
void |
startCDATA()
Report the start of a CDATA section. |
void |
startDocument()
Receive SAX notification of the beginning of the document. |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report the start of DTD declarations, if any. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
SAX callback for starting a new XML element. |
void |
startEntity(java.lang.String name)
Report the beginning of some internal and external XML entities. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
Begins the scope of a prefix-URI Namespace mapping. |
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)
SAX callback for reporting non-fatal parsing problems. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
ignorableWhitespace, resolveEntity, skippedEntity |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String DOCUMENT_INFO_PROPERTY
public static final java.lang.String PCDATA_TYPE
public static final java.lang.String PCDATA_PROPERTY
public static final java.lang.String PI_TYPE
public static final java.lang.String PI_TARGET_PROPERTY
public static final java.lang.String PI_DATA_PROPERTY
public static final java.lang.String NOTATION_TYPE
public static final java.lang.String NOTATION_NAME_PROPERTY
public static final java.lang.String NOTATION_PUBLIC_PROPERTY
public static final java.lang.String NOTATION_SYSTEM_PROPERTY
public static final java.lang.String CRIMSON_READER
public static final java.lang.String XERCES_READER
Constructor Detail |
public SAXLoader()
public SAXLoader(java.lang.String readerClass)
readerClass
- SAX parser class name, or null to use defaultMethod Detail |
public boolean isStrictWhitespace()
public void setStrictWhitespace(boolean strictWhitespace)
strictWhitespace
- true if strict whitespace loading should be
enabledpublic boolean isProcessingInstructionsEnabled()
public void setProcessingInstructionsEnabled(boolean piEnabled)
piEnabled
- true if XML processing instructions should be
savedpublic boolean isNotationsEnabled()
public void setNotationsEnabled(boolean notationsEnabled)
notationsEnabled
- true if XML NOTATIONs should be savedpublic boolean isUnicodeCheckEnabled()
public void setUnicodeCheckEnabled(boolean unicodeCheckEnabled)
unicodeCheckEnabled
- true to turn on extra Unicode checking, or
false to turn it off.public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
locator
- SAX Locator objectpublic void setValidate(boolean validate)
validate
- if true, attempt to enable validation parsingpublic Datum load(java.io.Reader reader) throws UmberClassException, BellowsIOException, BellowsParseException
reader
- the input source for the XML
UmberClassException
- if unable to find any XML parsers
BellowsParseException
- if XML parsing errors occur
BellowsIOException
- if I/O errors occurpublic Datum load(java.lang.String fileName) throws UmberClassException, BellowsIOException, BellowsParseException
fileName
- the XML file to load
UmberClassException
- if unable to find any XML parsers
BellowsParseException
- if XML parsing errors occur
BellowsIOException
- if I/O errors occurpublic Datum load(java.io.Reader reader, java.lang.String baseURI) throws UmberClassException, BellowsIOException, BellowsParseException
reader
- the input source for the XMLbaseURI
- URI for resolving relative entity paths
UmberClassException
- if unable to find any XML parsers
BellowsParseException
- if XML parsing errors occur
BellowsIOException
- if I/O errors occurpublic void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
public void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
startPrefixMapping
in interface org.xml.sax.ContentHandler
prefix
- the namespace prefix being declareduri
- the namespace URI the prefix is mapped to
org.xml.sax.SAXException
- if a parsing error occurspublic void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
endPrefixMapping
in interface org.xml.sax.ContentHandler
prefix
- the namespace prefix being declared
org.xml.sax.SAXException
- if a parsing error occurspublic void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
uri
- localName
- qName
- attributes
-
org.xml.sax.SAXException
ContentHandler.startElement(java.lang.String,
java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
uri
- localName
- qName
-
org.xml.sax.SAXException
ContentHandler.endElement(java.lang.String,
java.lang.String, java.lang.String)
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
ch
- start
- length
-
org.xml.sax.SAXException
ContentHandler.characters(char[], int, int)
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
notationDecl
in interface org.xml.sax.DTDHandler
name
- the notation namepublicId
- the notation public identifier, or null if not
availablesystemId
- the notation system identifier
org.xml.sax.SAXException
- any SAX exception, possibly
wrapping another exceptionDTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
target
- the processing instruction targetdata
- the processing instruction data, or null if none is
supplied
org.xml.sax.SAXException
- any SAX exception, possibly
wrapping another exceptionContentHandler.processingInstruction(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) throws org.xml.sax.SAXException
unparsedEntityDecl
in interface org.xml.sax.DTDHandler
name
- the entity namepublicId
- the entity public identifier, or null if not availablesystemId
- the entity system identifiernotationName
- the name of the associated notation
org.xml.sax.SAXException
- any SAX exception, possibly
wrapping another exceptionDTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
startDTD
in interface org.xml.sax.ext.LexicalHandler
name
- the document type namepublicId
- the declared public identifier for the
external DTD subset, or null if none was declaredsystemId
- the declared system identifier for the
external DTD subset, or null if none was declared
org.xml.sax.SAXException
- if a parsing error occurspublic void endDTD() throws org.xml.sax.SAXException
endDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
- if a parsing error occurspublic void startEntity(java.lang.String name) throws org.xml.sax.SAXException
startEntity
in interface org.xml.sax.ext.LexicalHandler
name
- the name of the entity; if it is a parameter
entity, the name will begin with '%', and if it is the
external DTD subset, it will be "[dtd]"
org.xml.sax.SAXException
- if a parsing error occurspublic void endEntity(java.lang.String name) throws org.xml.sax.SAXException
endEntity
in interface org.xml.sax.ext.LexicalHandler
name
- the name of the entity that is ending
org.xml.sax.SAXException
- if a parsing error occurspublic void startCDATA() throws org.xml.sax.SAXException
startCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
- if a parsing error occurspublic void endCDATA() throws org.xml.sax.SAXException
endCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
- if a parsing error occurspublic void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
comment
in interface org.xml.sax.ext.LexicalHandler
ch
- an array holding the characters in the commentstart
- the starting position in the arraylength
- the number of characters to use from the array
org.xml.sax.SAXException
- if a parsing error occurspublic void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value) throws org.xml.sax.SAXException
attributeDecl
in interface org.xml.sax.ext.DeclHandler
eName
- the name of the associated elementaName
- the name of the attributetype
- a string representing the attribute typevalueDefault
- a string representing the attribute default
("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
none of these appliesvalue
- a string representing the attribute's default value,
or null if there is none
org.xml.sax.SAXException
- if a parsing error occurspublic void elementDecl(java.lang.String name, java.lang.String model) throws org.xml.sax.SAXException
elementDecl
in interface org.xml.sax.ext.DeclHandler
name
- the element type namemodel
- the content model as a normalized string
org.xml.sax.SAXException
- if a parsing error occurspublic void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
externalEntityDecl
in interface org.xml.sax.ext.DeclHandler
name
- the name of the entity; if it is a parameter
entity, the name will begin with '%'publicId
- the declared public identifier of the entity, or
null if none was declaredsystemId
- the declared system identifier of the entity
org.xml.sax.SAXException
- if a parsing error occurspublic void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXException
internalEntityDecl
in interface org.xml.sax.ext.DeclHandler
name
- the name of the entity; if it is a parameter
entity, the name will begin with '%'value
- the replacement text of the entity
org.xml.sax.SAXException
- if a parsing error occurspublic void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
e
- the warning information encoded as an exception
org.xml.sax.SAXException
- if a parsing error occurspublic void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
e
- the error information encoded as an exception
org.xml.sax.SAXException
- if a parsing error occurspublic void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
e
- the error information encoded as an exception
org.xml.sax.SAXException
- if a parsing error occurspublic static void main(java.lang.String[] args) throws UmberClassException
args
- not used
UmberClassException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |