Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.impl

public Class XMLNSDocumentScannerImpl

extends XMLDocumentScannerImpl
Class Inheritance
Imports
java.io.IOException, com.sun.org.apache.xerces.internal.xni.XMLString, .NamespaceContext, .QName, .XNIException, .XMLDocumentHandler, com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidatorFilter, com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter, com.sun.org.apache.xerces.internal.util.XMLAttributesImpl, .XMLSymbols, com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager, .XMLConfigurationException, .XMLDocumentSource, javax.xml.stream.events.XMLEvent, jdk.xml.internal.XMLSecurityManager

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.
Authors
Neeraj Bajaj, Sun Microsystems, Venugopal Rao K, Sun Microsystems, Elena Litani, IBM

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
XMLNSDocumentScannerImpl.NSContentDriver

Driver to handle content scanning.

Field Summary

Modifier and TypeField and Description
protected boolean
fBindNamespaces

If is true, the dtd validator is no longer in the pipeline and the scanner should bind namespaces

private XMLDTDValidatorFilter
fDTDValidator

DTD validator

protected boolean
fNotAddNSDeclAsAttribute

Default value of this feature is false, when in Stax mode this should be true

protected boolean
fPerformValidation

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

private boolean
fXmlnsDeclared

xmlns, default Namespace, declared

Inherited from com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl:
DISALLOW_DOCTYPE_DECL_FEATUREDOCUMENT_SCANNERDTD_SCANNERfAddedListenerfDoctypeNamefDoctypePublicIdfDoctypeSystemIdfDTDDeclfDTDDriverfDTDScannerfEndPosfLoadExternalDTDfNamespaceContextfPrologDriverfReadingDTDfScanEndElementfSeenDoctypeDeclfSeenInternalSubsetfStartPosfTrailingMiscDriverfValidationManagerfXMLDeclDriverLOAD_EXTERNAL_DTDNAMESPACE_CONTEXTSCANNER_STATE_DTD_EXTERNALSCANNER_STATE_DTD_EXTERNAL_DECLSSCANNER_STATE_DTD_INTERNAL_DECLSSCANNER_STATE_NO_SUCH_ELEMENT_EXCEPTIONSCANNER_STATE_PROLOGSCANNER_STATE_TRAILING_MISCSCANNER_STATE_XML_DECLVALIDATION_MANAGER

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected XMLDocumentFragmentScannerImpl.Driver
public int
public void
reset(PropertyManager propertyManager)

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.reset.

Resets the fields of this scanner.

public void
protected void
scanAttribute(XMLAttributesImpl
The attributes list for the scanned attribute.
attributes
)

Scans an attribute.

protected boolean

Returns:

True if element is empty. (i.e. It matches production [44].
scanStartElement
()

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement.

Scans a start element.

public void
setDTDValidator(XMLDTDValidatorFilter
The filter component before DTDValidator
dtd
)

The scanner is responsible for removing DTD validator from the pipeline if it is not needed.

Inherited from com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl:
endEntitygetCharacterEncodingSchemegetDTDDeclgetFeatureDefaultgetNamespaceContextgetPropertyDefaultgetRecognizedFeaturesgetRecognizedPropertiesgetScannerStateNamegetScannetStaterefreshscanDoctypeDeclsetEndDTDScanStatesetFeaturesetInputSourcesetPropertystartEntity

Field Detail

fBindNamespacesback to summary
protected boolean fBindNamespaces

If is true, the dtd validator is no longer in the pipeline and the scanner should bind namespaces

fDTDValidatorback to summary
private XMLDTDValidatorFilter fDTDValidator

DTD validator

fNotAddNSDeclAsAttributeback to summary
protected boolean fNotAddNSDeclAsAttribute

Default value of this feature is false, when in Stax mode this should be true

fPerformValidationback to summary
protected boolean fPerformValidation

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

fXmlnsDeclaredback to summary
private boolean fXmlnsDeclared

xmlns, default Namespace, declared

Constructor Detail

XMLNSDocumentScannerImplback to summary
public XMLNSDocumentScannerImpl()

Method Detail

createContentDriverback to summary
protected XMLDocumentFragmentScannerImpl.Driver createContentDriver()

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.createContentDriver.

Creates a content driver.

nextback to summary
public int next() throws IOException, XNIException

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next.

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner.next.

return the next state on the input

Returns:int

int

resetback to summary
public void reset(PropertyManager propertyManager)

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.reset.

Resets the fields of this scanner.

resetback to summary
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.reset.

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.reset.

Doc from com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.reset.

Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.

Parameters
componentManager:XMLComponentManager

The component manager.

scanAttributeback to summary
protected void scanAttribute(XMLAttributesImpl attributes) throws IOException, 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:XMLAttributesImpl

The attributes list for the scanned attribute.

scanStartElementback to summary
protected boolean scanStartElement() throws IOException, XNIException

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement.

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.

Returns:boolean

True if element is empty. (i.e. It matches production [44].

setDTDValidatorback to summary
public void setDTDValidator(XMLDTDValidatorFilter dtd)

The scanner is responsible for removing DTD validator from the pipeline if it is not needed.

Parameters
dtd:XMLDTDValidatorFilter

The filter component before DTDValidator

com.sun.org.apache.xerces.internal.impl back to summary

protected final Class XMLNSDocumentScannerImpl.NSContentDriver

extends ContentDriver
Class Inheritance

Driver to handle content scanning.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private void
reconfigurePipeline()

Re-configures pipeline by removing the DTD validator if no DTD grammar exists.

protected boolean

Returns:

True if the caller should stop and return true which allows the scanner to switch to a new scanning driver. A return value of false indicates that the content driver should continue as normal.
scanRootElementHook
()

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.ContentDriver.scanRootElementHook.

Scan for root element hook.

Inherited from com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.ContentDriver:
elementDepthIsZeroHookendOfFileHookresolveExternalSubsetAndReadscanForDoctypeHook

Constructor Detail

NSContentDriverback to summary
protected NSContentDriver()

Method Detail

reconfigurePipelineback to summary
private void reconfigurePipeline()

Re-configures pipeline by removing the DTD validator if no DTD grammar exists. If no validator exists in the pipeline or there is no DTD grammar, namespace binding is performed by the scanner in the enclosing class.

scanRootElementHookback to summary
protected boolean scanRootElementHook() throws IOException, XNIException

Overrides com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.ContentDriver.scanRootElementHook.

Scan for root element hook. This method is a hook for subclasses to add code that handles scanning for the root element. This method will also attempt to remove DTD validator from the pipeline, if there is no DTD grammar. If DTD validator is no longer in the pipeline bind namespaces in the scanner.

Returns:boolean

True if the caller should stop and return true which allows the scanner to switch to a new scanning driver. A return value of false indicates that the content driver should continue as normal.