com.sun.xml.stream
Class XMLNSDocumentScannerImpl

java.lang.Object
  extended by com.sun.xml.stream.XMLScanner
      extended by com.sun.xml.stream.XMLDocumentFragmentScannerImpl
          extended by com.sun.xml.stream.XMLDocumentScannerImpl
              extended by com.sun.xml.stream.XMLNSDocumentScannerImpl
All Implemented Interfaces:
XMLEntityHandler, org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLDocumentScanner, org.apache.xerces.xni.parser.XMLDocumentSource

public class XMLNSDocumentScannerImpl
extends XMLDocumentScannerImpl

This class adds the functionality of namespace processing. This class has been modified as per the new design which is more suited to efficiently build pull parser. Lot of improvements have been done and the code has been added to support stax functionality/features. This class scans an XML document, checks if document has a DTD, and if DTD is not found the scanner will remove the DTD Validator from the pipeline and perform namespace binding.

Version:
$Id: XMLNSDocumentScannerImpl.java,v 1.8 2009-11-20 21:07:25 joehw Exp $
Author:
Neeraj Bajaj, Sun Microsystems, Venugopal Rao K, Sun Microsystems, Elena Litani, IBM

Nested Class Summary
protected  class XMLNSDocumentScannerImpl.NSContentDriver
          Driver to handle content scanning.
 
Nested classes/interfaces inherited from class com.sun.xml.stream.XMLDocumentScannerImpl
XMLDocumentScannerImpl.ContentDriver, XMLDocumentScannerImpl.DTDDriver, XMLDocumentScannerImpl.PrologDriver, XMLDocumentScannerImpl.TrailingMiscDriver, XMLDocumentScannerImpl.XMLBufferListenerImpl, XMLDocumentScannerImpl.XMLDeclDriver
 
Nested classes/interfaces inherited from class com.sun.xml.stream.XMLDocumentFragmentScannerImpl
XMLDocumentFragmentScannerImpl.Driver, XMLDocumentFragmentScannerImpl.Element, XMLDocumentFragmentScannerImpl.ElementStack, XMLDocumentFragmentScannerImpl.ElementStack2, XMLDocumentFragmentScannerImpl.FragmentContentDriver
 
Field Summary
protected  boolean fPerformValidation
          If validating parser, make sure we report an error in the scanner if DTD grammar is missing.
 
Fields inherited from class com.sun.xml.stream.XMLDocumentScannerImpl
COMMENTSTRING, DISALLOW_DOCTYPE_DECL_FEATURE, DOCTYPE, DTD_SCANNER, fBindNamespaces, fDoctypeName, fDoctypePublicId, fDoctypeSystemId, fDTDDecl, fDTDDriver, fDTDScanner, fEndOfDocument, fEndPos, fLoadExternalDTD, fNamespaceContext, fPrologDriver, fReadingAttributes, fReadingDTD, fScanEndElement, fScannerBufferlistener, fScannerLastState, fSeenDoctypeDecl, fSeenInternalSubset, fStartPos, fTrailingMiscDriver, fXMLDeclDriver, LOAD_EXTERNAL_DTD, SCANNER_STATE_DTD_EXTERNAL, SCANNER_STATE_DTD_EXTERNAL_DECLS, SCANNER_STATE_DTD_INTERNAL_DECLS, SCANNER_STATE_NO_SUCH_ELEMENT_EXCEPTION, SCANNER_STATE_PROLOG, SCANNER_STATE_TRAILING_MISC, SCANNER_STATE_XML_DECL, VALIDATION_MANAGER
 
Fields inherited from class com.sun.xml.stream.XMLDocumentFragmentScannerImpl
cdata, DEBUG, DEBUG_COALESCE, DEBUG_CONTENT_SCANNING, DEBUG_NEXT, dtdGrammarUtil, endTag, fAdd, fAddDefaultAttr, fAttributeQName, fAttributes, fContentBuffer, fContentDriver, fCurrentElement, fDeclaredEncoding, fDisallowDoctype, fDocumentHandler, fDriver, fElementQName, fElementRawname, fElementStack, fElementStack2, fEntityStack, fEntityStore, fHasExternalDTD, fInScanContent, fIsCoalesce, fLastSectionWasCData, fLastSectionWasCharacterData, fLastSectionWasEntityReference, fMarkupDepth, fNamespaces, fNotifyBuiltInRefs, foundBuiltInRefs, fPIData, fPITarget, fReplaceEntityReferences, fReportCdataEvent, fScannerState, fScanToEnd, fShouldSkip, fSkip, fStandalone, fStandaloneSet, fStringBuffer, fStringBuffer2, fSupportExternalEntities, fTempString, fTempString2, fVersion, NAMESPACES, NOTIFY_BUILTIN_REFS, SCANNER_STATE_ATTRIBUTE, SCANNER_STATE_ATTRIBUTE_VALUE, SCANNER_STATE_BUILT_IN_REFS, SCANNER_STATE_CDATA, SCANNER_STATE_CHAR_REFERENCE, SCANNER_STATE_CHARACTER_DATA, SCANNER_STATE_COMMENT, SCANNER_STATE_CONTENT, SCANNER_STATE_DOCTYPE, SCANNER_STATE_END_ELEMENT_TAG, SCANNER_STATE_END_OF_INPUT, SCANNER_STATE_PI, SCANNER_STATE_REFERENCE, SCANNER_STATE_ROOT_ELEMENT, SCANNER_STATE_START_ELEMENT_TAG, SCANNER_STATE_START_OF_MARKUP, SCANNER_STATE_TERMINATED, SCANNER_STATE_TEXT_DECL, xmlDecl
 
Fields inherited from class com.sun.xml.stream.XMLScanner
attributeValueCache, DEBUG_ATTR_NORMALIZATION, ENTITY_MANAGER, ERROR_REPORTER, fAmpSymbol, fAposSymbol, fAttributeCacheInitDone, fAttributeCacheUsedCount, fCharRefLiteral, fEncodingSymbol, fEntityDepth, fEntityManager, fEntityScanner, fErrorReporter, fEvent, fGtSymbol, fLtSymbol, fNotifyCharRefs, fPropertyManager, fQuotSymbol, fReportEntity, fResourceIdentifier, fScanningAttribute, fStandaloneSymbol, fStringBufferIndex, fSymbolTable, fValidation, fVersionSymbol, NOTIFY_CHAR_REFS, stringBufferCache, SYMBOL_TABLE, VALIDATION
 
Constructor Summary
XMLNSDocumentScannerImpl()
           
 
Method Summary
protected  XMLDocumentFragmentScannerImpl.Driver createContentDriver()
          Creates a content driver.
 java.lang.String getCharacterEncodingScheme()
           
 org.apache.xerces.util.XMLStringBuffer getDTDDecl()
           
 org.apache.xerces.xni.QName getElementQName()
          Return the information about the element -- If it is EndELement, QName values are computed dynamically.
 org.apache.xerces.xni.NamespaceContext getNamespaceContext()
           
 void reset(PropertyManager propertyManager)
          Resets the fields of this scanner.
 void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
          Resets the component.
protected  void scanAttribute(org.apache.xerces.util.XMLAttributesImpl attributes)
          Scans an attribute.
protected  int scanEndElement()
          Scans an end element.
protected  boolean scanStartElement()
          Scans a start element.
 
Methods inherited from class com.sun.xml.stream.XMLDocumentScannerImpl
endEntity, getFeatureDefault, getPropertyDefault, getRecognizedFeatures, getRecognizedProperties, getScannerStateName, getScannetState, next, scanDoctypeDecl, setEndDTDScanState, setFeature, setInputSource, setProperty, startEntity
 
Methods inherited from class com.sun.xml.stream.XMLDocumentFragmentScannerImpl
getAttributeIterator, getCharacterData, getComment, getDocumentHandler, getDriverName, getEntityName, getPIData, getPITarget, hasAttributes, isStandAlone, scanAttribute, scanCDATASection, scanCharReference, scanComment, scanContent, scanDocument, scanEntityReference, scanPIData, scanXMLDeclOrTextDecl, setDocumentHandler, setDriver, setScannerState, skipElement, standaloneSet
 
Methods inherited from class com.sun.xml.stream.XMLScanner
getFeature, isInvalid, isInvalidLiteral, isValidNameChar, isValidNameStartChar, isValidNCName, normalizeWhitespace, reportFatalError, scanAttributeValue, scanCharReferenceValue, scanComment, scanExternalID, scanPI, scanPseudoAttribute, scanPubidLiteral, scanSurrogates, scanXMLDeclOrTextDecl, setPropertyManager, versionSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fPerformValidation

protected boolean fPerformValidation
If validating parser, make sure we report an error in the scanner if DTD grammar is missing.

Constructor Detail

XMLNSDocumentScannerImpl

public XMLNSDocumentScannerImpl()
Method Detail

reset

public void reset(PropertyManager propertyManager)
Resets the fields of this scanner.

Overrides:
reset in class XMLDocumentScannerImpl

getElementQName

public org.apache.xerces.xni.QName getElementQName()
Return the information about the element -- If it is EndELement, QName values are computed dynamically.


scanStartElement

protected boolean scanStartElement()
                            throws java.io.IOException,
                                   org.apache.xerces.xni.XNIException
Scans a start element. This method will handle the binding of namespace information and notifying the handler of the start of the element.

 [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
 [40] STag ::= '<' Name (S Attribute)* S? '>'
 

Note: This method assumes that the leading '<' character has been consumed.

Note: This method uses the fElementQName and fAttributes variables. The contents of these variables will be destroyed. The caller should copy important information out of these variables before calling this method.

Overrides:
scanStartElement in class XMLDocumentFragmentScannerImpl
Returns:
True if element is empty. (i.e. It matches production [44].
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanAttribute

protected void scanAttribute(org.apache.xerces.util.XMLAttributesImpl attributes)
                      throws java.io.IOException,
                             org.apache.xerces.xni.XNIException
Scans an attribute.

 [41] Attribute ::= Name Eq AttValue
 

Note: This method assumes that the next character on the stream is the first character of the attribute name.

Note: This method uses the fAttributeQName and fQName variables. The contents of these variables will be destroyed.

Parameters:
attributes - The attributes list for the scanned attribute.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

scanEndElement

protected int scanEndElement()
                      throws java.io.IOException,
                             org.apache.xerces.xni.XNIException
Scans an end element.

 [42] ETag ::= '</' Name S? '>'
 

Note: This method uses the fElementQName variable. The contents of this variable will be destroyed. The caller should copy the needed information out of this variable before calling this method.

Overrides:
scanEndElement in class XMLDocumentFragmentScannerImpl
Returns:
The element depth.
Throws:
java.io.IOException
org.apache.xerces.xni.XNIException

getNamespaceContext

public org.apache.xerces.xni.NamespaceContext getNamespaceContext()

reset

public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
           throws org.apache.xerces.xni.parser.XMLConfigurationException
Description copied from class: XMLDocumentScannerImpl
Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Specified by:
reset in interface org.apache.xerces.xni.parser.XMLComponent
Overrides:
reset in class XMLDocumentScannerImpl
Parameters:
componentManager - The component manager.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException

createContentDriver

protected XMLDocumentFragmentScannerImpl.Driver createContentDriver()
Creates a content driver.

Overrides:
createContentDriver in class XMLDocumentScannerImpl

getDTDDecl

public org.apache.xerces.util.XMLStringBuffer getDTDDecl()

getCharacterEncodingScheme

public java.lang.String getCharacterEncodingScheme()


Copyright ? 2002-2003 Apache XML Project. All Rights Reserved.