com.ibm.ims.xms
Class XMSParser

com.ibm.ims.xms.XMSParser
All Implemented Interfaces:
XMSIntactXMLHandler

public class XMSParser
implements XMSIntactXMLHandler

This is the main XMS parser class. It uses the abstract Xerces SAX parser with a document scanner, a dtd scanner, and a validator, as well as a grammar pool.

Author:
Christopher Holtz, IBM

Field Summary
protected  java.lang.String defaultNamespace
           
protected  java.util.Stack elementStack
           
protected  XMSDocumentHandler fXMSDocHandler
           
protected static java.lang.String NAMESPACES_FEATURE_ID
          Namespaces feature id (http://xml.org/sax/features/namespaces).
protected static java.lang.String NOTIFY_BUILTIN_REFS
          Feature identifier: notify built-in refereces.
protected static java.lang.String NOTIFY_CHAR_REFS_FEATURE_ID
          Character ref notification feature id (http://apache.org/xml/features/scanner/notify-char-refs).
protected static java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
          Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).
protected static java.lang.String SCHEMA_VALIDATION_FEATURE_ID
          Schema validation feature id (http://apache.org/xml/features/validation/schema).
protected static java.lang.String SYMBOL_TABLE
          Property identifier: symbol table.
protected static java.lang.String VALIDATION_FEATURE_ID
          Validation feature id (http://xml.org/sax/features/validation).
protected static java.lang.String XMLGRAMMAR_POOL
          Property identifier: XML grammar pool.
protected  org.apache.xerces.xni.parser.XMLInputSource xmlInputSource
           
protected  org.apache.xerces.xni.grammars.XSGrammar xsGrammar
           
 
Constructor Summary
XMSParser(org.apache.xerces.xni.grammars.XSGrammar xsGrammar, org.apache.xerces.util.SymbolTable symbolTable, org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
          Constructs a XMS parser using the specified symbol Table and grammar Pool.
 
Method Summary
protected  java.lang.StringBuffer buildOpenTag(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
           
protected  void buildSideSegments()
           
 void characters(char[] array, int offset, int length)
          Accepts characters from an intact source.
 void characters(org.apache.xerces.xni.XMLString text, org.apache.xerces.xni.Augmentations augs)
          Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.
protected  void consumeIntact(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
          Consumes intact sub-tree as clob strait from reader until we a close element for passed in element
 void endDocument(org.apache.xerces.xni.Augmentations augs)
          Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.
 void endElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.Augmentations augs)
          Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.
 void endGeneralEntity(java.lang.String name, org.apache.xerces.xni.Augmentations augs)
           
protected  void finishedIntact(org.apache.xerces.xni.QName element)
          Consumes intact sub-tree as clob strait from reader until we a close element for passed in element
 XMSDocumentHandler getXMSDocumentHandler()
          Returns the registered document handler.
protected  int getXMSType(java.lang.String name)
          Returns the type of the passed in element.
 boolean parse(boolean complete)
          Parses the document in a pull parsing fashion.
 void processingInstruction(java.lang.String target, org.apache.xerces.xni.XMLString data, org.apache.xerces.xni.Augmentations augs)
           
 void reset()
          Resets all components before parsing
 void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
          Sets the input source to parse.
 void setXMSDocumentHandler(XMSDocumentHandler xmsDocumentHandler)
          Sets the document handler to receive information about the document.
 void startDocument(org.apache.xerces.xni.XMLLocator locator, java.lang.String encoding, org.apache.xerces.xni.NamespaceContext namespaceContext, org.apache.xerces.xni.Augmentations augs)
          Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.
 void startElement(org.apache.xerces.xni.QName element, org.apache.xerces.xni.XMLAttributes attributes, org.apache.xerces.xni.Augmentations augs)
          Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.
 void startGeneralEntity(java.lang.String name, org.apache.xerces.xni.XMLResourceIdentifier identifier, java.lang.String encoding, org.apache.xerces.xni.Augmentations augs)
          Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.
 

Field Detail

NAMESPACES_FEATURE_ID

protected static final java.lang.String NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces).

VALIDATION_FEATURE_ID

protected static final java.lang.String VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).

SCHEMA_VALIDATION_FEATURE_ID

protected static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).

SCHEMA_FULL_CHECKING_FEATURE_ID

protected static final java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).

NOTIFY_CHAR_REFS_FEATURE_ID

protected static final java.lang.String NOTIFY_CHAR_REFS_FEATURE_ID
Character ref notification feature id (http://apache.org/xml/features/scanner/notify-char-refs).

NOTIFY_BUILTIN_REFS

protected static final java.lang.String NOTIFY_BUILTIN_REFS
Feature identifier: notify built-in refereces.

SYMBOL_TABLE

protected static final java.lang.String SYMBOL_TABLE
Property identifier: symbol table.

XMLGRAMMAR_POOL

protected static final java.lang.String XMLGRAMMAR_POOL
Property identifier: XML grammar pool.

fXMSDocHandler

protected XMSDocumentHandler fXMSDocHandler

defaultNamespace

protected java.lang.String defaultNamespace

elementStack

protected java.util.Stack elementStack

xsGrammar

protected org.apache.xerces.xni.grammars.XSGrammar xsGrammar

xmlInputSource

protected org.apache.xerces.xni.parser.XMLInputSource xmlInputSource
Constructor Detail

XMSParser

public XMSParser(org.apache.xerces.xni.grammars.XSGrammar xsGrammar,
                 org.apache.xerces.util.SymbolTable symbolTable,
                 org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
Constructs a XMS parser using the specified symbol Table and grammar Pool.
Method Detail

setInputSource

public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
                    throws org.apache.xerces.xni.parser.XMLConfigurationException,
                           java.io.IOException
Sets the input source to parse.
Parameters:
inputSource - The document's input source.
Throws:
XMLConfigurationException - Thrown if there is a configuration error when initializing the parser.
java.io.IOException - Thrown on I/O error.
See Also:
parse(boolean)

parse

public boolean parse(boolean complete)
              throws java.io.IOException,
                     org.apache.xerces.xni.parser.XMLParseException
Parses the document in a pull parsing fashion.
Parameters:
complete - True if the pull parser should parse the remaining document completely.
Throws:
XNIException - Any XNI exception, possibly wrapping another exception.
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the parser.
See Also:
setInputSource(org.apache.xerces.xni.parser.XMLInputSource)

reset

public void reset()
           throws org.apache.xerces.xni.XNIException
Resets all components before parsing

setXMSDocumentHandler

public void setXMSDocumentHandler(XMSDocumentHandler xmsDocumentHandler)
Sets the document handler to receive information about the document.
Parameters:
documentHandler - The document handler.

getXMSDocumentHandler

public XMSDocumentHandler getXMSDocumentHandler()
Returns the registered document handler.

startDocument

public void startDocument(org.apache.xerces.xni.XMLLocator locator,
                          java.lang.String encoding,
                          org.apache.xerces.xni.NamespaceContext namespaceContext,
                          org.apache.xerces.xni.Augmentations augs)
                   throws org.apache.xerces.xni.XNIException
Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.

startGeneralEntity

public void startGeneralEntity(java.lang.String name,
                               org.apache.xerces.xni.XMLResourceIdentifier identifier,
                               java.lang.String encoding,
                               org.apache.xerces.xni.Augmentations augs)
                        throws org.apache.xerces.xni.XNIException
Intercept XMLDocumentHandler call and call XMSDocumentHandler interface. Prohibits any Prefix declarations except the default which must match preset defaultNamespace.

endGeneralEntity

public void endGeneralEntity(java.lang.String name,
                             org.apache.xerces.xni.Augmentations augs)
                      throws org.apache.xerces.xni.XNIException

startElement

public void startElement(org.apache.xerces.xni.QName element,
                         org.apache.xerces.xni.XMLAttributes attributes,
                         org.apache.xerces.xni.Augmentations augs)
                  throws org.apache.xerces.xni.XNIException
Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.

characters

public void characters(org.apache.xerces.xni.XMLString text,
                       org.apache.xerces.xni.Augmentations augs)
Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.

endElement

public void endElement(org.apache.xerces.xni.QName element,
                       org.apache.xerces.xni.Augmentations augs)
                throws org.apache.xerces.xni.XNIException
Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.

processingInstruction

public void processingInstruction(java.lang.String target,
                                  org.apache.xerces.xni.XMLString data,
                                  org.apache.xerces.xni.Augmentations augs)
                           throws org.apache.xerces.xni.XNIException

endDocument

public void endDocument(org.apache.xerces.xni.Augmentations augs)
Intercept XMLDocumentHandler call and call XMSDocumentHandler interface.

characters

public void characters(char[] array,
                       int offset,
                       int length)
Accepts characters from an intact source.
Specified by:
characters in interface XMSIntactXMLHandler
Following copied from interface: com.ibm.ims.xms.XMSIntactXMLHandler
Parameters:
charArray - The array of characters snooped. This array will be reused, it is up to the implementor to immediately use or copy the passed in characters.

buildOpenTag

protected java.lang.StringBuffer buildOpenTag(org.apache.xerces.xni.QName element,
                                              org.apache.xerces.xni.XMLAttributes attributes,
                                              org.apache.xerces.xni.Augmentations augs)
                                       throws org.apache.xerces.xni.XNIException

consumeIntact

protected void consumeIntact(org.apache.xerces.xni.QName element,
                             org.apache.xerces.xni.XMLAttributes attributes,
                             org.apache.xerces.xni.Augmentations augs)
                      throws java.io.IOException,
                             org.apache.xerces.xni.XNIException
Consumes intact sub-tree as clob strait from reader until we a close element for passed in element

finishedIntact

protected void finishedIntact(org.apache.xerces.xni.QName element)
                       throws org.apache.xerces.xni.XNIException
Consumes intact sub-tree as clob strait from reader until we a close element for passed in element

buildSideSegments

protected void buildSideSegments()
                          throws org.apache.xerces.xni.XNIException

getXMSType

protected int getXMSType(java.lang.String name)
Returns the type of the passed in element.


(C) International Business Machines Corporation 2004. All rights reserved.