| java.lang.Object org.xml.sax.helpers.DefaultHandler org.apache.commons.jelly.parser.XMLParser
XMLParser | public class XMLParser extends DefaultHandler (Code) | | XMLParser parses the XML Jelly format.
The SAXParser and XMLReader portions of this code come from Digester.
author: James Strachan version: $Revision: 155420 $ |
Field Summary | |
protected ClassLoader | classLoader The class loader to use for instantiating application objects. | protected ErrorHandler | errorHandler The application-supplied error handler that is notified when parsing
warnings, errors, or fatal errors occur. | protected static SAXParserFactory | factory The SAXParserFactory that is created the first time we need it. | protected Locator | locator The Locator associated with our parser. | protected Map | namespaces Registered namespaces we are currently processing. | protected SAXParser | parser The SAXParser we will use to parse the input stream. | protected XMLReader | reader The XMLReader used to parse digester rules. | protected boolean | useContextClassLoader Do we want to use the Context ClassLoader when loading classes
for instantiating new objects? Default is false . | protected boolean | validating |
Constructor Summary | |
public | XMLParser() Construct a new XMLParser with default properties. | public | XMLParser(SAXParser parser) Construct a new XMLParser, allowing a SAXParser to be passed in. | public | XMLParser(XMLReader reader) Construct a new XMLParser, allowing an XMLReader to be passed in. |
Method Summary | |
protected void | addExpressionScript(ScriptBlock script, Expression expression) Adds the given Expression object to the current Script. | protected void | addTextScript(String text) Adds the text to the current script block parsing any embedded
expressions inot ExpressionScript objects. | public void | characters(char buffer, int start, int length) Process notification of character data received from the body of
an XML element. | protected void | configure() | protected void | configureTagScript(TagScript aTagScript) | protected Expression | createConstantExpression(String tagName, String attributeName, String attributeValue) | protected ExpressionFactory | createExpressionFactory() | protected SAXException | createSAXException(String message, Exception e) | protected SAXException | createSAXException(Exception e) | protected SAXException | createSAXException(String message) | protected TagScript | createStaticTag(String namespaceURI, String localName, String qName, Attributes list) Factory method to create a static Tag that represents some static content. | protected TagScript | createTag(String namespaceURI, String localName, Attributes list) Factory method to create new Tag script for the given namespaceURI and name or
return null if this is not a custom Tag. | public void | endDocument() Process notification of the end of the document being reached. | public void | endElement(String namespaceURI, String localName, String qName) Process notification of the end of an XML element being reached. | public void | endPrefixMapping(String prefix) Process notification that a namespace prefix is going out of scope. | public void | error(SAXParseException exception) Forward notification of a parsing error to the application supplied
error handler, if any, otherwise throw a SAXException with the error. | public void | fatalError(SAXParseException exception) Forward notification of a fatal parsing error to the application
supplied error handler, if any, otherwise throw a SAXException with the error. | public String | findNamespaceURI(String prefix) Return the currently mapped namespace URI for the specified prefix,
if any; otherwise return null . | public ClassLoader | getClassLoader() Return the class loader to be used for instantiating application objects
when required. | public JellyContext | getContext() | protected String | getCurrentURI() | public ErrorHandler | getErrorHandler() Return the error handler for this XMLParser. | public ExpressionFactory | getExpressionFactory() | protected synchronized Properties | getJellyProperties() | public Log | getLogger() | public SAXParser | getParser() Return the SAXParser we will use to parse the input stream. | public XMLReader | getReader() By setting the reader in the constructor, you can bypass JAXP and
be able to use digester in Weblogic 6.0. | public ScriptBlock | getScript() Returns the script that has just been created if this class is used
as a SAX ContentHandler and passed into some XML processor or parser. | public boolean | getUseContextClassLoader() Return the boolean as to whether the context classloader should be used. | public boolean | getValidating() Return the validating parser flag. | public synchronized XMLReader | getXMLReader() Return the XMLReader to be used for parsing the input document. | public void | ignorableWhitespace(char buffer, int start, int len) Process notification of ignorable whitespace received from the body of
an XML element. | public void | notationDecl(String name, String publicId, String systemId) Receive notification of a notation declaration event. | public Script | parse(File file) Parse the content of the specified file using this XMLParser. | public Script | parse(URL url) Parse the content of the specified file using this XMLParser. | public Script | parse(InputSource input) Parse the content of the specified input source using this XMLParser. | public Script | parse(InputStream input) Parse the content of the specified input stream using this XMLParser.
Returns the root element from the object stack (if any).
(Note: if reading a File or URL, use one of the URL-based
parse methods instead. | public Script | parse(Reader reader) Parse the content of the specified reader using this XMLParser.
Returns the root element from the object stack (if any).
(Note: if reading a File or URL, use one of the URL-based
parse methods instead. | public Script | parse(String uri) Parse the content of the specified URI using this XMLParser. | public void | processingInstruction(String target, String data) Process notification of a processing instruction that was encountered. | public void | setClassLoader(ClassLoader classLoader) Set the class loader to be used for instantiating application objects
when required. | public void | setContext(JellyContext context) | public void | setDefaultNamespaceURI(String namespace) Set the jelly namespace to use for unprefixed elements.
Will be overridden by an explicit namespace in the
XML document.
Parameters: namespace - jelly namespace to use (e.g. | public void | setDocumentLocator(Locator locator) Set the document locator associated with our parser. | public void | setErrorHandler(ErrorHandler errorHandler) Set the error handler for this XMLParser. | public void | setExpressionFactory(ExpressionFactory expressionFactory) | public void | setLogger(Log log) Set the current logger for this XMLParser. | public void | setUseContextClassLoader(boolean use) Determine whether to use the Context ClassLoader (the one found by
calling Thread.currentThread().getContextClassLoader() )
to resolve/load classes. | public void | setValidating(boolean validating) Set the validating parser flag. | public void | skippedEntity(String name) Process notification of a skipped entity. | public void | startDocument() Process notification of the beginning of the document being reached. | public void | startElement(String namespaceURI, String localName, String qName, Attributes list) Process notification of the start of an XML element being reached.
Parameters: namespaceURI - The Namespace URI, or the empty string if theelement has no Namespace URI or if Namespace processing is notbeing performed. Parameters: localName - The local name (without prefix), or the emptystring if Namespace processing is not being performed. Parameters: qName - The qualified name (with prefix), or the emptystring if qualified names are not available.\ Parameters: list - The attributes attached to the element. | public void | startPrefixMapping(String prefix, String namespaceURI) Process notification that a namespace prefix is coming in to scope. | public void | unparsedEntityDecl(String name, String publicId, String systemId, String notation) Receive notification of an unparsed entity declaration event. | public void | warning(SAXParseException exception) Forward notification of a parse warning to the application supplied
error handler (if any). |
classLoader | protected ClassLoader classLoader(Code) | | The class loader to use for instantiating application objects.
If not specified, the context class loader, or the class loader
used to load XMLParser itself, is used, based on the value of the
useContextClassLoader variable.
|
errorHandler | protected ErrorHandler errorHandler(Code) | | The application-supplied error handler that is notified when parsing
warnings, errors, or fatal errors occur.
|
factory | protected static SAXParserFactory factory(Code) | | The SAXParserFactory that is created the first time we need it.
|
locator | protected Locator locator(Code) | | The Locator associated with our parser.
|
namespaces | protected Map namespaces(Code) | | Registered namespaces we are currently processing. The key is the
namespace prefix that was declared in the document. The value is an
ArrayStack of the namespace URIs this prefix has been mapped to --
the top Stack element is the most current one. (This architecture
is required because documents can declare nested uses of the same
prefix for different Namespace URIs).
|
parser | protected SAXParser parser(Code) | | The SAXParser we will use to parse the input stream.
|
reader | protected XMLReader reader(Code) | | The XMLReader used to parse digester rules.
|
useContextClassLoader | protected boolean useContextClassLoader(Code) | | Do we want to use the Context ClassLoader when loading classes
for instantiating new objects? Default is false .
|
validating | protected boolean validating(Code) | | Do we want to use a validating parser?
|
XMLParser | public XMLParser()(Code) | | Construct a new XMLParser with default properties.
|
XMLParser | public XMLParser(SAXParser parser)(Code) | | Construct a new XMLParser, allowing a SAXParser to be passed in. This
allows XMLParser to be used in environments which are unfriendly to
JAXP1.1 (such as WebLogic 6.0). Thanks for the request to change go to
James House (james@interobjective.com). This may help in places where
you are able to load JAXP 1.1 classes yourself.
|
XMLParser | public XMLParser(XMLReader reader)(Code) | | Construct a new XMLParser, allowing an XMLReader to be passed in. This
allows XMLParser to be used in environments which are unfriendly to
JAXP1.1 (such as WebLogic 6.0). Note that if you use this option you
have to configure namespace and validation support yourself, as these
properties only affect the SAXParser and emtpy constructor.
|
addExpressionScript | protected void addExpressionScript(ScriptBlock script, Expression expression)(Code) | | Adds the given Expression object to the current Script.
|
addTextScript | protected void addTextScript(String text) throws JellyException(Code) | | Adds the text to the current script block parsing any embedded
expressions inot ExpressionScript objects.
|
characters | public void characters(char buffer, int start, int length) throws SAXException(Code) | | Process notification of character data received from the body of
an XML element.
Parameters: buffer - The characters from the XML document Parameters: start - Starting offset into the buffer Parameters: length - Number of characters from the buffer exception: SAXException - if a parsing error is to be reported |
configure | protected void configure()(Code) | | This method is called only once before parsing occurs
which allows tag libraries to be registered and so forth
|
configureTagScript | protected void configureTagScript(TagScript aTagScript)(Code) | | Configure a newly created TagScript instance before any Expressions are created
Parameters: aTagScript - |
createSAXException | protected SAXException createSAXException(String message, Exception e)(Code) | | Create a SAX exception which also understands about the location in
the file where the exception occurs
the new exception |
createSAXException | protected SAXException createSAXException(Exception e)(Code) | | Create a SAX exception which also understands about the location in
the digester file where the exception occurs
the new exception |
createSAXException | protected SAXException createSAXException(String message)(Code) | | Create a SAX exception which also understands about the location in
the digester file where the exception occurs
the new exception |
endDocument | public void endDocument() throws SAXException(Code) | | Process notification of the end of the document being reached.
exception: SAXException - if a parsing error is to be reported |
endElement | public void endElement(String namespaceURI, String localName, String qName) throws SAXException(Code) | | Process notification of the end of an XML element being reached.
Parameters: namespaceURI - The Namespace URI, or the empty string if theelement has no Namespace URI or if Namespace processing is notbeing performed. Parameters: localName - The local name (without prefix), or the emptystring if Namespace processing is not being performed. Parameters: qName - The qualified XML 1.0 name (with prefix), or theempty string if qualified names are not available. exception: SAXException - if a parsing error is to be reported |
endPrefixMapping | public void endPrefixMapping(String prefix) throws SAXException(Code) | | Process notification that a namespace prefix is going out of scope.
Parameters: prefix - Prefix that is going out of scope exception: SAXException - if a parsing error is to be reported |
error | public void error(SAXParseException exception) throws SAXException(Code) | | Forward notification of a parsing error to the application supplied
error handler, if any, otherwise throw a SAXException with the error.
Parameters: exception - The error information exception: SAXException - if a parsing exception occurs |
fatalError | public void fatalError(SAXParseException exception) throws SAXException(Code) | | Forward notification of a fatal parsing error to the application
supplied error handler, if any, otherwise throw a SAXException with the error.
Parameters: exception - The fatal error information exception: SAXException - if a parsing exception occurs |
findNamespaceURI | public String findNamespaceURI(String prefix)(Code) | | Return the currently mapped namespace URI for the specified prefix,
if any; otherwise return null . These mappings come and
go dynamically as the document is parsed.
Parameters: prefix - Prefix to look up |
getClassLoader | public ClassLoader getClassLoader()(Code) | | Return the class loader to be used for instantiating application objects
when required. This is determined based upon the following rules:
- The class loader set by
setClassLoader() , if any
- The thread context class loader, if it exists and the
useContextClassLoader property is set to true
- The class loader used to load the XMLParser class itself.
|
getCurrentURI | protected String getCurrentURI()(Code) | | the current context URI as a String or null if there is nocurrent context defined on the JellyContext |
getErrorHandler | public ErrorHandler getErrorHandler()(Code) | | Return the error handler for this XMLParser.
|
getExpressionFactory | public ExpressionFactory getExpressionFactory()(Code) | | the expression factory used to evaluate tag attributes |
getJellyProperties | protected synchronized Properties getJellyProperties()(Code) | | A helper method which loads the static Jelly properties once on startup
|
getLogger | public Log getLogger()(Code) | | Return the current Logger associated with this instance of the XMLParser
|
getParser | public SAXParser getParser()(Code) | | Return the SAXParser we will use to parse the input stream. If there
is a problem creating the parser, return null .
|
getReader | public XMLReader getReader()(Code) | | By setting the reader in the constructor, you can bypass JAXP and
be able to use digester in Weblogic 6.0.
|
getScript | public ScriptBlock getScript()(Code) | | Returns the script that has just been created if this class is used
as a SAX ContentHandler and passed into some XML processor or parser.
the ScriptBlock created if SAX events are piped into this class,which must include a startDocument() and endDocument() |
getUseContextClassLoader | public boolean getUseContextClassLoader()(Code) | | Return the boolean as to whether the context classloader should be used.
|
getValidating | public boolean getValidating()(Code) | | Return the validating parser flag.
|
getXMLReader | public synchronized XMLReader getXMLReader() throws SAXException(Code) | | Return the XMLReader to be used for parsing the input document.
exception: SAXException - if no XMLReader can be instantiated |
ignorableWhitespace | public void ignorableWhitespace(char buffer, int start, int len) throws SAXException(Code) | | Process notification of ignorable whitespace received from the body of
an XML element.
Parameters: buffer - The characters from the XML document Parameters: start - Starting offset into the buffer Parameters: len - Number of characters from the buffer exception: SAXException - if a parsing error is to be reported |
notationDecl | public void notationDecl(String name, String publicId, String systemId)(Code) | | Receive notification of a notation declaration event.
Parameters: name - The notation name Parameters: publicId - The public identifier (if any) Parameters: systemId - The system identifier (if any) |
parse | public Script parse(File file) throws IOException, SAXException(Code) | | Parse the content of the specified file using this XMLParser. Returns
the root element from the object stack (if any).
Parameters: file - File containing the XML data to be parsed exception: IOException - if an input/output error occurs exception: SAXException - if a parsing exception occurs |
parse | public Script parse(URL url) throws IOException, SAXException(Code) | | Parse the content of the specified file using this XMLParser. Returns
the root element from the object stack (if any).
Parameters: url - URL containing the XML data to be parsed exception: IOException - if an input/output error occurs exception: SAXException - if a parsing exception occurs |
parse | public Script parse(InputSource input) throws IOException, SAXException(Code) | | Parse the content of the specified input source using this XMLParser.
Returns the root element from the object stack (if any).
Parameters: input - Input source containing the XML data to be parsed exception: IOException - if an input/output error occurs exception: SAXException - if a parsing exception occurs |
parse | public Script parse(InputStream input) throws IOException, SAXException(Code) | | Parse the content of the specified input stream using this XMLParser.
Returns the root element from the object stack (if any).
(Note: if reading a File or URL, use one of the URL-based
parse methods instead. This method will not be able
to resolve any relative paths inside a DTD.)
Parameters: input - Input stream containing the XML data to be parsed exception: IOException - if an input/output error occurs exception: SAXException - if a parsing exception occurs |
parse | public Script parse(Reader reader) throws IOException, SAXException(Code) | | Parse the content of the specified reader using this XMLParser.
Returns the root element from the object stack (if any).
(Note: if reading a File or URL, use one of the URL-based
parse methods instead. This method will not be able
to resolve any relative paths inside a DTD.)
Parameters: reader - Reader containing the XML data to be parsed exception: IOException - if an input/output error occurs exception: SAXException - if a parsing exception occurs |
parse | public Script parse(String uri) throws IOException, SAXException(Code) | | Parse the content of the specified URI using this XMLParser.
Returns the root element from the object stack (if any).
Parameters: uri - URI containing the XML data to be parsed exception: IOException - if an input/output error occurs exception: SAXException - if a parsing exception occurs |
processingInstruction | public void processingInstruction(String target, String data) throws SAXException(Code) | | Process notification of a processing instruction that was encountered.
Parameters: target - The processing instruction target Parameters: data - The processing instruction data (if any) exception: SAXException - if a parsing error is to be reported |
setClassLoader | public void setClassLoader(ClassLoader classLoader)(Code) | | Set the class loader to be used for instantiating application objects
when required.
Parameters: classLoader - The new class loader to use, or null to revert to the standard rules |
setDefaultNamespaceURI | public void setDefaultNamespaceURI(String namespace)(Code) | | Set the jelly namespace to use for unprefixed elements.
Will be overridden by an explicit namespace in the
XML document.
Parameters: namespace - jelly namespace to use (e.g. 'jelly:core') |
setDocumentLocator | public void setDocumentLocator(Locator locator)(Code) | | Set the document locator associated with our parser.
Parameters: locator - The new locator |
setErrorHandler | public void setErrorHandler(ErrorHandler errorHandler)(Code) | | Set the error handler for this XMLParser.
Parameters: errorHandler - The new error handler |
setExpressionFactory | public void setExpressionFactory(ExpressionFactory expressionFactory)(Code) | | Sets the expression factory used to evaluate tag attributes
|
setLogger | public void setLogger(Log log)(Code) | | Set the current logger for this XMLParser.
|
setUseContextClassLoader | public void setUseContextClassLoader(boolean use)(Code) | | Determine whether to use the Context ClassLoader (the one found by
calling Thread.currentThread().getContextClassLoader() )
to resolve/load classes. If not
using Context ClassLoader, then the class-loading defaults to
using the calling-class' ClassLoader.
Parameters: use - determines whether to use JellyContext ClassLoader. |
setValidating | public void setValidating(boolean validating)(Code) | | Set the validating parser flag. This must be called before
parse() is called the first time.
Parameters: validating - The new validating parser flag. |
skippedEntity | public void skippedEntity(String name) throws SAXException(Code) | | Process notification of a skipped entity.
Parameters: name - Name of the skipped entity exception: SAXException - if a parsing error is to be reported |
startDocument | public void startDocument() throws SAXException(Code) | | Process notification of the beginning of the document being reached.
exception: SAXException - if a parsing error is to be reported |
startElement | public void startElement(String namespaceURI, String localName, String qName, Attributes list) throws SAXException(Code) | | Process notification of the start of an XML element being reached.
Parameters: namespaceURI - The Namespace URI, or the empty string if theelement has no Namespace URI or if Namespace processing is notbeing performed. Parameters: localName - The local name (without prefix), or the emptystring if Namespace processing is not being performed. Parameters: qName - The qualified name (with prefix), or the emptystring if qualified names are not available.\ Parameters: list - The attributes attached to the element. If there areno attributes, it shall be an empty Attributes object. exception: SAXException - if a parsing error is to be reported |
startPrefixMapping | public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException(Code) | | Process notification that a namespace prefix is coming in to scope.
Parameters: prefix - Prefix that is being declared Parameters: namespaceURI - Corresponding namespace URI being mapped to exception: SAXException - if a parsing error is to be reported |
unparsedEntityDecl | public void unparsedEntityDecl(String name, String publicId, String systemId, String notation)(Code) | | Receive notification of an unparsed entity declaration event.
Parameters: name - The unparsed entity name Parameters: publicId - The public identifier (if any) Parameters: systemId - The system identifier (if any) Parameters: notation - The name of the associated notation |
warning | public void warning(SAXParseException exception) throws SAXException(Code) | | Forward notification of a parse warning to the application supplied
error handler (if any). Unlike XMLParser.error(SAXParseException) and
XMLParser.fatalError(SAXParseException), this implementation will
NOT throw a SAXException by default if no error handler is supplied.
Parameters: exception - The warning information exception: SAXException - if a parsing exception occurs |
Methods inherited from org.xml.sax.helpers.DefaultHandler | public void characters(char ch, int start, int length) throws SAXException(Code)(Java Doc) public void endDocument() throws SAXException(Code)(Java Doc) public void endElement(String uri, String localName, String qName) throws SAXException(Code)(Java Doc) public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc) public void error(SAXParseException e) throws SAXException(Code)(Java Doc) public void fatalError(SAXParseException e) throws SAXException(Code)(Java Doc) public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code)(Java Doc) public void notationDecl(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc) public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc) public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException(Code)(Java Doc) public void setDocumentLocator(Locator locator)(Code)(Java Doc) public void skippedEntity(String name) throws SAXException(Code)(Java Doc) public void startDocument() throws SAXException(Code)(Java Doc) public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException(Code)(Java Doc) public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc) public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException(Code)(Java Doc) public void warning(SAXParseException e) throws SAXException(Code)(Java Doc)
|
|
|