org.apache.fulcrum.intake.transform
Class XmlToAppData

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.fulcrum.intake.transform.XmlToAppData
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class XmlToAppData
extends DefaultHandler
implements org.apache.avalon.framework.logger.LogEnabled

A Class that is used to parse an input xml schema file and creates and AppData java structure. It uses apache Xerces to do the xml parsing.

Version:
$Id: XmlToAppData.java 732101 2009-01-06 20:30:43Z tv $
Author:
John McNally, Henning P. Schmiedehausen, Quinton McCombs

Constructor Summary
XmlToAppData()
          Creates a new instance of the Intake XML Parser
 
Method Summary
 void characters(char[] mesgArray, int start, int length)
          Handles the character data, which we are using to specify the error message.
 void enableLogging(org.apache.avalon.framework.logger.Logger logger)
          Provide an Avalon logger
 void endElement(String uri, String localName, String name)
          Handles closing elements of the xml file.
 void error(SAXParseException spe)
          Callback function for the xml parser to give errors.
 void fatalError(SAXParseException spe)
          Callback function for the xml parser to give fatalErrors.
 AppData parseFile(String xmlFile)
          Parses a XML input file and returns a newly created and populated AppData structure.
 InputSource resolveEntity(String publicId, String systemId)
          EntityResolver implementation.
 void startElement(String uri, String localName, String rawName, Attributes attributes)
          Handles opening elements of the xml file.
 void warning(SAXParseException spe)
          Callback function for the xml parser to give warnings.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlToAppData

public XmlToAppData()
Creates a new instance of the Intake XML Parser

Method Detail

parseFile

public AppData parseFile(String xmlFile)
                  throws ParserConfigurationException,
                         SAXException,
                         IOException
Parses a XML input file and returns a newly created and populated AppData structure.

Parameters:
xmlFile - The input file to parse.
Returns:
AppData populated by xmlFile.
Throws:
ParserConfigurationException
SAXException
IOException

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
Provide an Avalon logger

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
See Also:
LogEnabled.enableLogging(org.apache.avalon.framework.logger.Logger)

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
EntityResolver implementation. Called by the XML parser

Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class DefaultHandler
Returns:
an InputSource for the database.dtd file

startElement

public void startElement(String uri,
                         String localName,
                         String rawName,
                         Attributes attributes)
Handles opening elements of the xml file.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler

endElement

public void endElement(String uri,
                       String localName,
                       String name)
                throws SAXException
Handles closing elements of the xml file.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException
See Also:
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] mesgArray,
                       int start,
                       int length)
Handles the character data, which we are using to specify the error message.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler

warning

public void warning(SAXParseException spe)
Callback function for the xml parser to give warnings.

Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler
Parameters:
spe - a SAXParseException value

error

public void error(SAXParseException spe)
Callback function for the xml parser to give errors.

Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler
Parameters:
spe - a SAXParseException value

fatalError

public void fatalError(SAXParseException spe)
Callback function for the xml parser to give fatalErrors.

Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class DefaultHandler
Parameters:
spe - a SAXParseException value


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.