org.xBaseJ
Class XBASEXMLParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.xBaseJ.XBASEXMLParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class XBASEXMLParser
extends DefaultHandler


Field Summary
 org.apache.xerces.parsers.SAXParser parser
          SAX parser
 
Constructor Summary
XBASEXMLParser()
          constructor, sets up SAX parser, turns off validation, turns on namespaces, sets up content handler and error handler as this object.
 
Method Summary
 void characters(char[] ch, int start, int length)
          catches the element's value
 void endElement(String uri, String localName, String rawName)
          Method called by the SAX parser at the
 void error(SAXParseException e)
          catches error SAXParseExceptions this code causes exception to continue
 void fatalError(SAXParseException e)
          catches fatal SAXParseExceptions this code causes exception to continue
 void ignorableWhitespace(char[] ch, int start, int length)
          I use this to keep track of line #s
static void main(String[] args)
          accepts on String parameter, filename to parse
 void parse(String inXMLFile)
          makes the SAX2 parser call
 void startElement(String uri, String localName, String rawName, Attributes attributes)
          method called for each xml element found.
 void warning(SAXParseException e)
          catches warning SAXParseExceptions this code sends exception to stdio and allows public classto continue
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, processingInstruction, resolveEntity, 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

parser

public org.apache.xerces.parsers.SAXParser parser
SAX parser

Constructor Detail

XBASEXMLParser

public XBASEXMLParser()
constructor, sets up SAX parser, turns off validation, turns on namespaces, sets up content handler and error handler as this object. sax exceptions go to System.err

Method Detail

main

public static void main(String[] args)
accepts on String parameter, filename to parse


parse

public void parse(String inXMLFile)
makes the SAX2 parser call

Parameters:
inXMLFile - String of filename to parse

startElement

public void startElement(String uri,
                         String localName,
                         String rawName,
                         Attributes attributes)
                  throws SAXException
method called for each xml element found.
process logic

Parameters:
uri - URI of incoming file
localName - String of element's local name
rawName - String of element's raw name
attributes - Vector of the elements attributes
Throws:
SAXException - many possible exceptions

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
catches the element's value

Parameters:
ch - char array of the current element value contents
start - int start position within the array
length - int of characters found so far
Throws:
SAXException - many possible

endElement

public void endElement(String uri,
                       String localName,
                       String rawName)
                throws SAXException
Method called by the SAX parser at the
Parameters:
uri - URI of incoming file
localName - String of element's local name
rawName - String of element's raw name
Throws:
SAXException - many possible

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
I use this to keep track of line #s

Parameters:
ch - char array of found whitespaces
start - int start position in array
length - int length of what's been found

warning

public void warning(SAXParseException e)
             throws SAXException
catches warning SAXParseExceptions this code sends exception to stdio and allows public classto continue

Parameters:
e - SaxException object
Throws:
SAXException - exception

error

public void error(SAXParseException e)
           throws SAXException
catches error SAXParseExceptions this code causes exception to continue

Parameters:
e - SaxException object
Throws:
SAXException - thrown

fatalError

public void fatalError(SAXParseException e)
                throws SAXException
catches fatal SAXParseExceptions this code causes exception to continue

Parameters:
e - SAXException object
Throws:
SAXException - thrown


Copyright 1997-2007 American Coders Ltd. All Rights Reserved.