BEA Systems, Inc.


weblogic.apache.xerces.parsers
Class SAXParser

java.lang.Object
  |
  +--weblogic.apache.xerces.framework.XMLParser
        |
        +--weblogic.apache.xerces.parsers.SAXParser

public class SAXParser
extends XMLParser
implements XMLDocumentHandler, XMLDocumentHandler.DTDHandler, org.xml.sax.Parser, org.xml.sax.XMLReader

SAXParser provides a parser which implements the SAX1 and SAX2 parser APIs.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.

Version:
$Id: SAXParser.java,v 1.22 2001/02/01 09:58:19 andyc Exp $

Fields inherited from class weblogic.apache.xerces.framework.XMLParser
fEntityHandler, fErrorReporter, fGrammarResolver, fParseInProgress, fScanner, fStringPool, fValidator, SAX2_FEATURES_PREFIX, SAX2_PROPERTIES_PREFIX, WEBLOGIC_MAX_ENTITY_REFS, XERCES_FEATURES_PREFIX, XERCES_PROPERTIES_PREFIX
 
Constructor Summary
  SAXParser()
          Default constructor.
protected SAXParser(StringPool stringPool)
           
 
Method Summary
 void attlistDecl(QName elementDecl, QName attributeDecl, int attType, boolean attList, java.lang.String enumString, int attDefaultType, int attDefaultValue)
          Report an attribute type declaration.
 void characters(char[] ch, int start, int length)
          Characters.
 void characters(int dataIndex)
          Not called.
 void comment(int dataIndex)
          Comment.
 void elementDecl(QName elementDecl, int contentSpecType, int contentSpecIndex, XMLContentSpec.Provider contentSpecProvider)
          Report an element type declaration.
 void endCDATA()
          End CDATA section.
 void endDocument()
          End document.
 void endDTD()
          This function will be called at the end of the DTD.
 void endElement(QName element)
          End element.
 void endEntityReference(int entityName, int entityType, int entityContext)
          End entity reference.
 void endNamespaceDeclScope(int prefix)
          Report the end of the scope of a namespace declaration.
 void externalEntityDecl(int entityName, int publicId, int systemId)
          Report a parsed external general entity declaration.
 void externalPEDecl(int entityName, int publicId, int systemId)
          Report a parsed external parameter entity declaration.
 org.xml.sax.ContentHandler getContentHandler()
          Return the current content handler.
protected  org.xml.sax.ext.DeclHandler getDeclHandler()
          Returns the DTD declaration event handler.
 org.xml.sax.DTDHandler getDTDHandler()
          Return the current DTD handler.
 boolean getFeature(java.lang.String featureId)
          Query the state of a feature.
 java.lang.String[] getFeaturesRecognized()
          Returns a list of features that this parser recognizes.
protected  org.xml.sax.ext.LexicalHandler getLexicalHandler()
          Returns the lexical handler.
protected  boolean getNamespacePrefixes()
          Returns the http://xml.org/features/namespace-prefixes value.
 java.lang.String[] getPropertiesRecognized()
          Returns a list of properties that this parser recognizes.
 java.lang.Object getProperty(java.lang.String propertyId)
          Query the value of a property.
 void ignorableWhitespace(char[] ch, int start, int length)
          Ignorable whitespace.
 void ignorableWhitespace(int dataIndex)
          Not called.
 void internalEntityDecl(int entityName, int entityValue)
          Report an internal general entity declaration.
 void internalPEDecl(int entityName, int entityValue)
          Report an internal parameter entity declaration.
 void internalSubset(int internalSubset)
          New callback from DOM Level 2.
 void notationDecl(int notationName, int publicId, int systemId)
          Receive notification of a notation declaration event.
 void processingInstruction(int piTarget, int piData)
          Processing instruction.
 void setContentHandler(org.xml.sax.ContentHandler handler)
          Allow an application to register a content event handler.
protected  void setDeclHandler(org.xml.sax.ext.DeclHandler handler)
          Set the DTD declaration event handler.
 void setDocumentHandler(org.xml.sax.DocumentHandler handler)
          Sets the document handler.
 void setDTDHandler(org.xml.sax.DTDHandler handler)
          Allow an application to register a DTD event handler.
 void setFeature(java.lang.String featureId, boolean state)
          Set the state of any feature in a SAX2 parser.
protected  void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
          Set the lexical event handler.
protected  void setNamespacePrefixes(boolean process)
          Sets how the parser reports raw prefixed names, and whether xmlns attributes are reported.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Set the value of any property in a SAX2 parser.
 void startCDATA()
          Start CDATA section.
 void startDocument()
          Start document.
 void startDTD(QName rootElement, int publicId, int systemId)
          This function will be called when a <!DOCTYPE...> declaration is encountered.
 void startElement(QName element, XMLAttrList attrList, int attrListIndex)
          Start element
 void startEntityReference(int entityName, int entityType, int entityContext)
          Start entity reference.
 void startNamespaceDeclScope(int prefix, int uri)
          Report the start of the scope of a namespace declaration.
 void textDecl(int versionIndex, int encodingIndex)
          Text declaration.
 void unparsedEntityDecl(int entityName, int publicId, int systemId, int notationName)
          Receive notification of an unparsed entity declaration event.
 void xmlDecl(int versionIndex, int encodingIndex, int standaloneIndex)
          XML declaration.
 
Methods inherited from class weblogic.apache.xerces.framework.XMLParser
addRecognizer, getAllowJavaEncodings, getContinueAfterFatalError, getEntityResolver, getErrorHandler, getExternalGeneralEntities, getExternalParameterEntities, getfgDatatypeMessages, getfgImplementationMessages, getfgSchemaMessages, getfgXMLMessages, getfLocale, getLoadDTDGrammar, getLoadExternalDTD, getLocator, getMaxEntityRefs, getNamespaces, getNormalizeContents, getValidation, getValidationDynamic, getValidationSchema, getValidationSchemaFullChecking, getValidationWarnOnDuplicateAttdef, getValidationWarnOnUndeclaredElemdef, getXMLString, initHandlers, isFeatureRecognized, isPropertyRecognized, parse, parse, parse, parseSome, parseSomeSetup, reportError, reset, resetOrCopy, setAllowJavaEncodings, setContinueAfterFatalError, setEntityResolver, setErrorHandler, setExternalGeneralEntities, setExternalNoNamespaceSchemaLocation, setExternalParameterEntities, setExternalSchemaLocation, setLoadDTDGrammar, setLoadExternalDTD, setLocale, setMaxEntityRefs, setNamespaces, setNormalizeAttributeValues, setNormalizeContents, setReaderFactory, setUpFrontValidation, setValidation, setValidationDynamic, setValidationSchema, setValidationSchemaFullChecking, setValidationWarnOnDuplicateAttdef, setValidationWarnOnUndeclaredElemdef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXParser

public SAXParser()
Default constructor.

SAXParser

protected SAXParser(StringPool stringPool)
Method Detail

getFeaturesRecognized

public java.lang.String[] getFeaturesRecognized()
Returns a list of features that this parser recognizes. This method will never return null; if no features are recognized, this method will return a zero length array.

Overrides:
getFeaturesRecognized in class XMLParser
See Also:
XMLParser.isFeatureRecognized(java.lang.String), setFeature(java.lang.String, boolean), getFeature(java.lang.String)

getPropertiesRecognized

public java.lang.String[] getPropertiesRecognized()
Returns a list of properties that this parser recognizes. This method will never return null; if no properties are recognized, this method will return a zero length array.

Overrides:
getPropertiesRecognized in class XMLParser
See Also:
XMLParser.isPropertyRecognized(java.lang.String), setProperty(java.lang.String, java.lang.Object), getProperty(java.lang.String)

setDeclHandler

protected void setDeclHandler(org.xml.sax.ext.DeclHandler handler)
                       throws org.xml.sax.SAXNotRecognizedException,
                              org.xml.sax.SAXNotSupportedException
Set the DTD declaration event handler.

This method is the equivalent to the property:

 http://xml.org/sax/properties/declaration-handler
 

Parameters:
handler - The new handler.
See Also:
getDeclHandler(), setProperty(java.lang.String, java.lang.Object)

getDeclHandler

protected org.xml.sax.ext.DeclHandler getDeclHandler()
                                              throws org.xml.sax.SAXNotRecognizedException,
                                                     org.xml.sax.SAXNotSupportedException
Returns the DTD declaration event handler.

See Also:
setDeclHandler(org.xml.sax.ext.DeclHandler)

setLexicalHandler

protected void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
                          throws org.xml.sax.SAXNotRecognizedException,
                                 org.xml.sax.SAXNotSupportedException
Set the lexical event handler.

This method is the equivalent to the property:

 http://xml.org/sax/properties/lexical-handler
 

Parameters:
handler - lexical event handler
See Also:
getLexicalHandler(), setProperty(java.lang.String, java.lang.Object)

getLexicalHandler

protected org.xml.sax.ext.LexicalHandler getLexicalHandler()
                                                    throws org.xml.sax.SAXNotRecognizedException,
                                                           org.xml.sax.SAXNotSupportedException
Returns the lexical handler.

See Also:
setLexicalHandler(org.xml.sax.ext.LexicalHandler)

setDocumentHandler

public void setDocumentHandler(org.xml.sax.DocumentHandler handler)
Sets the document handler.
Specified by:
setDocumentHandler in interface org.xml.sax.Parser


setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler handler)
Allow an application to register a DTD event handler.

If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Specified by:
setDTDHandler in interface org.xml.sax.Parser

Parameters:
handler - The DTD handler.
Throws:
java.lang.NullPointerException - If the handler argument is null.
See Also:
getDTDHandler()

getDTDHandler

public org.xml.sax.DTDHandler getDTDHandler()
Return the current DTD handler.
Specified by:
getDTDHandler in interface org.xml.sax.XMLReader

Returns:
The current DTD handler, or null if none has been registered.
See Also:
setDTDHandler(org.xml.sax.DTDHandler)

setNamespacePrefixes

protected void setNamespacePrefixes(boolean process)
                             throws org.xml.sax.SAXNotRecognizedException,
                                    org.xml.sax.SAXNotSupportedException
Sets how the parser reports raw prefixed names, and whether xmlns attributes are reported.

This method is the equivalent to the feature:

 http://xml.org/sax/features/namespaces-prefixes
 

Parameters:
process - True to process namespaces; false to not process.
See Also:
XMLParser.getNamespaces(), setFeature(java.lang.String, boolean)

getNamespacePrefixes

protected boolean getNamespacePrefixes()
                                throws org.xml.sax.SAXNotRecognizedException,
                                       org.xml.sax.SAXNotSupportedException
Returns the http://xml.org/features/namespace-prefixes value.

See Also:
setNamespacePrefixes(boolean)

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.
Specified by:
setFeature in interface org.xml.sax.XMLReader

Parameters:
featureId - The unique identifier (URI) of the feature.
state - The requested state of the feature (true or false).
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested feature is not known.
org.xml.sax.SAXNotSupportedException - If the requested feature is known, but the requested state is not supported.
Overrides:
setFeature in class XMLParser

getFeature

public boolean getFeature(java.lang.String featureId)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
Query the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.
Specified by:
getFeature in interface org.xml.sax.XMLReader

Parameters:
featureId - The unique identifier (URI) of the feature being set.
Returns:
The current state of the feature.
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested feature is not known.
org.xml.sax.SAXNotSupportedException - If the requested feature is known but not supported.
Overrides:
getFeature in class XMLParser

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws org.xml.sax.SAXNotRecognizedException,
                        org.xml.sax.SAXNotSupportedException
Set the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.
Specified by:
setProperty in interface org.xml.sax.XMLReader

Parameters:
propertyId - The unique identifier (URI) of the property being set.
Object - The value to which the property is being set.
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested property is not known.
org.xml.sax.SAXNotSupportedException - If the requested property is known, but the requested value is not supported.
Overrides:
setProperty in class XMLParser

getProperty

public java.lang.Object getProperty(java.lang.String propertyId)
                             throws org.xml.sax.SAXNotRecognizedException,
                                    org.xml.sax.SAXNotSupportedException
Query the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.
Specified by:
getProperty in interface org.xml.sax.XMLReader

Parameters:
propertyId - The unique identifier (URI) of the property being set.
Returns:
The current value of the property.
Throws:
org.xml.sax.SAXNotRecognizedException - If the requested property is not known.
org.xml.sax.SAXNotSupportedException - If the requested property is known but not supported.
Overrides:
getProperty in class XMLParser

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
Allow an application to register a content event handler.

If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Specified by:
setContentHandler in interface org.xml.sax.XMLReader

Parameters:
handler - The content handler.
Throws:
java.lang.NullPointerException - If the handler argument is null.
See Also:
getContentHandler()

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
Return the current content handler.
Specified by:
getContentHandler in interface org.xml.sax.XMLReader

Returns:
The current content handler, or null if none has been registered.
See Also:
setContentHandler(org.xml.sax.ContentHandler)

startDTD

public void startDTD(QName rootElement,
                     int publicId,
                     int systemId)
              throws java.lang.Exception
This function will be called when a <!DOCTYPE...> declaration is encountered.
Specified by:
startDTD in interface XMLDocumentHandler.DTDHandler


endDTD

public void endDTD()
            throws java.lang.Exception
This function will be called at the end of the DTD.
Specified by:
endDTD in interface XMLDocumentHandler.DTDHandler


elementDecl

public void elementDecl(QName elementDecl,
                        int contentSpecType,
                        int contentSpecIndex,
                        XMLContentSpec.Provider contentSpecProvider)
                 throws java.lang.Exception
Report an element type declaration. The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all whitespace is removed.
Specified by:
elementDecl in interface XMLDocumentHandler.DTDHandler

Parameters:
name - The element type name.
model - The content model as a normalized string.
Throws:
org.xml.sax.SAXException - The application may raise an exception.

attlistDecl

public void attlistDecl(QName elementDecl,
                        QName attributeDecl,
                        int attType,
                        boolean attList,
                        java.lang.String enumString,
                        int attDefaultType,
                        int attDefaultValue)
                 throws java.lang.Exception
Report an attribute type declaration. Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION", or a parenthesized token group with the separator "|" and all whitespace removed.
Specified by:
attlistDecl in interface XMLDocumentHandler.DTDHandler

Parameters:
eName - The name of the associated element.
aName - The name of the attribute.
type - A string representing the attribute type.
valueDefault - A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
value - A string representing the attribute's default value, or null if there is none.
Throws:
org.xml.sax.SAXException - The application may raise an exception.

internalPEDecl

public void internalPEDecl(int entityName,
                           int entityValue)
                    throws java.lang.Exception
Report an internal parameter entity declaration.
Specified by:
internalPEDecl in interface XMLDocumentHandler.DTDHandler


externalPEDecl

public void externalPEDecl(int entityName,
                           int publicId,
                           int systemId)
                    throws java.lang.Exception
Report a parsed external parameter entity declaration.
Specified by:
externalPEDecl in interface XMLDocumentHandler.DTDHandler


internalEntityDecl

public void internalEntityDecl(int entityName,
                               int entityValue)
                        throws java.lang.Exception
Report an internal general entity declaration.
Specified by:
internalEntityDecl in interface XMLDocumentHandler.DTDHandler


externalEntityDecl

public void externalEntityDecl(int entityName,
                               int publicId,
                               int systemId)
                        throws java.lang.Exception
Report a parsed external general entity declaration.
Specified by:
externalEntityDecl in interface XMLDocumentHandler.DTDHandler


unparsedEntityDecl

public void unparsedEntityDecl(int entityName,
                               int publicId,
                               int systemId,
                               int notationName)
                        throws java.lang.Exception
Receive notification of an unparsed entity declaration event.
Specified by:
unparsedEntityDecl in interface XMLDocumentHandler.DTDHandler


notationDecl

public void notationDecl(int notationName,
                         int publicId,
                         int systemId)
                  throws java.lang.Exception
Receive notification of a notation declaration event.
Specified by:
notationDecl in interface XMLDocumentHandler.DTDHandler


startDocument

public void startDocument()
                   throws java.lang.Exception
Start document.
Specified by:
startDocument in interface XMLDocumentHandler


endDocument

public void endDocument()
                 throws java.lang.Exception
End document.
Specified by:
endDocument in interface XMLDocumentHandler


xmlDecl

public void xmlDecl(int versionIndex,
                    int encodingIndex,
                    int standaloneIndex)
             throws java.lang.Exception
XML declaration.
Specified by:
xmlDecl in interface XMLDocumentHandler


textDecl

public void textDecl(int versionIndex,
                     int encodingIndex)
              throws java.lang.Exception
Text declaration.
Specified by:
textDecl in interface XMLDocumentHandler


startNamespaceDeclScope

public void startNamespaceDeclScope(int prefix,
                                    int uri)
                             throws java.lang.Exception
Report the start of the scope of a namespace declaration.
Specified by:
startNamespaceDeclScope in interface XMLDocumentHandler


endNamespaceDeclScope

public void endNamespaceDeclScope(int prefix)
                           throws java.lang.Exception
Report the end of the scope of a namespace declaration.
Specified by:
endNamespaceDeclScope in interface XMLDocumentHandler


internalSubset

public void internalSubset(int internalSubset)
New callback from DOM Level 2. There is no corresponding SAX callout for this yet.
Specified by:
internalSubset in interface XMLDocumentHandler.DTDHandler


startElement

public void startElement(QName element,
                         XMLAttrList attrList,
                         int attrListIndex)
                  throws java.lang.Exception
Start element
Specified by:
startElement in interface XMLDocumentHandler


endElement

public void endElement(QName element)
                throws java.lang.Exception
End element.
Specified by:
endElement in interface XMLDocumentHandler


startEntityReference

public void startEntityReference(int entityName,
                                 int entityType,
                                 int entityContext)
                          throws java.lang.Exception
Start entity reference.
Specified by:
startEntityReference in interface XMLDocumentHandler


endEntityReference

public void endEntityReference(int entityName,
                               int entityType,
                               int entityContext)
                        throws java.lang.Exception
End entity reference.
Specified by:
endEntityReference in interface XMLDocumentHandler


startCDATA

public void startCDATA()
                throws java.lang.Exception
Start CDATA section.
Specified by:
startCDATA in interface XMLDocumentHandler


endCDATA

public void endCDATA()
              throws java.lang.Exception
End CDATA section.
Specified by:
endCDATA in interface XMLDocumentHandler


characters

public void characters(int dataIndex)
                throws java.lang.Exception
Not called.
Specified by:
characters in interface XMLDocumentHandler


ignorableWhitespace

public void ignorableWhitespace(int dataIndex)
                         throws java.lang.Exception
Not called.
Specified by:
ignorableWhitespace in interface XMLDocumentHandler


processingInstruction

public void processingInstruction(int piTarget,
                                  int piData)
                           throws java.lang.Exception
Processing instruction.
Specified by:
processingInstruction in interface XMLDocumentHandler


comment

public void comment(int dataIndex)
             throws java.lang.Exception
Comment.
Specified by:
comment in interface XMLDocumentHandler


characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws java.lang.Exception
Characters.
Specified by:
characters in interface XMLDocumentHandler


ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws java.lang.Exception
Ignorable whitespace.
Specified by:
ignorableWhitespace in interface XMLDocumentHandler


Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs70

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference