org.apache.torque.engine.database.transform
Class XmlToData

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.apache.torque.engine.database.transform.XmlToData
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XmlToData
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.EntityResolver

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: XmlToData.java,v 1.9 2002/10/08 18:17:06 mpoeschl Exp $
Author:
Leon Messerschmidt, Jason van Zyl, Martin Poeschl, Fedor Karpelevitch

Nested Class Summary
 class XmlToData.ColumnValue
           
 class XmlToData.DataRow
           
 
Field Summary
private  java.util.List data
           
private  Database database
           
private  org.xml.sax.InputSource dataDTD
           
private  java.io.File dtdFile
           
private  java.lang.String dtdFileName
           
private  java.lang.String errorMessage
           
private static javax.xml.parsers.SAXParserFactory saxFactory
           
 
Constructor Summary
XmlToData(Database database, java.lang.String dtdFilePath)
          Default custructor
 
Method Summary
 void error(org.xml.sax.SAXParseException spe)
          Error callback.
 void fatalError(org.xml.sax.SAXParseException spe)
          Fatal error callback.
 org.xml.sax.InputSource getInputSource(java.lang.String urlString)
          get an InputSource for an URL String
 java.util.List parseFile(java.lang.String xmlFile)
           
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          called by the XML parser
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)
          Handles opening elements of the xml file.
 void warning(org.xml.sax.SAXParseException spe)
          Warning callback.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, 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
 

Field Detail

database

private Database database

errorMessage

private java.lang.String errorMessage

data

private java.util.List data

dtdFileName

private java.lang.String dtdFileName

dtdFile

private java.io.File dtdFile

dataDTD

private org.xml.sax.InputSource dataDTD

saxFactory

private static javax.xml.parsers.SAXParserFactory saxFactory
Constructor Detail

XmlToData

public XmlToData(Database database,
                 java.lang.String dtdFilePath)
          throws java.net.MalformedURLException,
                 java.io.IOException
Default custructor

Method Detail

parseFile

public java.util.List parseFile(java.lang.String xmlFile)

startElement

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

Specified by:
startElement in interface org.xml.sax.ContentHandler

warning

public void warning(org.xml.sax.SAXParseException spe)
Warning callback.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
spe - The parse exception that caused the callback to be invoked.

error

public void error(org.xml.sax.SAXParseException spe)
Error callback.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
spe - The parse exception that caused the callback to be invoked.

fatalError

public void fatalError(org.xml.sax.SAXParseException spe)
Fatal error callback.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
spe - The parse exception that caused the callback to be invoked.

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
called by the XML parser

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Returns:
an InputSource for the database.dtd file

getInputSource

public org.xml.sax.InputSource getInputSource(java.lang.String urlString)
get an InputSource for an URL String

Parameters:
urlString -
Returns:
an InputSource for the URL String


Copyright © 1999-2003 Apache Software Foundation. All Rights Reserved.