Top Description Fields Constructors Methods
org.springframework.beans.factory.xml

public Class DefaultDocumentLoader

extends Object
implements DocumentLoader
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.xml.DocumentLoader
Imports
javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, .ParserConfigurationException, org.apache.commons.logging.Log, .LogFactory, org.w3c.dom.Document, org.xml.sax.EntityResolver, .ErrorHandler, .InputSource, org.springframework.lang.Nullable, org.springframework.util.xml.XmlValidationModeDetector

Spring's default DocumentLoader implementation.

Simply loads documents using the standard JAXP-configured XML parser. If you want to change the DocumentBuilder that is used to load documents, then one strategy is to define a corresponding Java system property when starting your JVM. For example, to use the Oracle DocumentBuilder, you might start your application like as follows:

java -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory MyMainClass
Authors
Rob Harrop, Juergen Hoeller
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final Log
private static final String
SCHEMA_LANGUAGE_ATTRIBUTE

JAXP attribute used to configure the schema language for validation.

private static final String
XSD_SCHEMA_LANGUAGE

JAXP attribute value indicating the XSD schema language.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected DocumentBuilder

Returns:

the JAXP DocumentBuilder
createDocumentBuilder
(DocumentBuilderFactory
the JAXP DocumentBuilderFactory that the DocumentBuilder should be created with
factory
,
EntityResolver
the SAX EntityResolver to use
entityResolver
,
ErrorHandler
the SAX ErrorHandler to use
errorHandler
)

Create a JAXP DocumentBuilder that this bean definition reader will use for parsing XML documents.

protected DocumentBuilderFactory

Returns:

the JAXP DocumentBuilderFactory
createDocumentBuilderFactory
(int
the type of validation: DTD or XSD)
validationMode
,
boolean
whether the returned factory is to provide support for XML namespaces
namespaceAware
)

Create the DocumentBuilderFactory instance.

public Document
loadDocument(InputSource
the source of the document that is to be loaded
inputSource
,
EntityResolver
the resolver that is to be used to resolve any entities
entityResolver
,
ErrorHandler
used to report any errors during document loading
errorHandler
,
int
the type of validation DTD or XSD)
validationMode
,
boolean
true if support for XML namespaces is to be provided
namespaceAware
)

Implements org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

Load the Document at the supplied InputSource using the standard JAXP-configured XML parser.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private static final Log logger
SCHEMA_LANGUAGE_ATTRIBUTEback to summary
private static final String SCHEMA_LANGUAGE_ATTRIBUTE

JAXP attribute used to configure the schema language for validation.

XSD_SCHEMA_LANGUAGEback to summary
private static final String XSD_SCHEMA_LANGUAGE

JAXP attribute value indicating the XSD schema language.

Constructor Detail

DefaultDocumentLoaderback to summary
public DefaultDocumentLoader()

Method Detail

createDocumentBuilderback to summary
protected DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory, EntityResolver entityResolver, ErrorHandler errorHandler) throws ParserConfigurationException

Create a JAXP DocumentBuilder that this bean definition reader will use for parsing XML documents. Can be overridden in subclasses, adding further initialization of the builder.

Parameters
factory:DocumentBuilderFactory

the JAXP DocumentBuilderFactory that the DocumentBuilder should be created with

entityResolver:EntityResolver

the SAX EntityResolver to use

errorHandler:ErrorHandler

the SAX ErrorHandler to use

Returns:DocumentBuilder

the JAXP DocumentBuilder

Exceptions
ParserConfigurationException:
if thrown by JAXP methods
createDocumentBuilderFactoryback to summary
protected DocumentBuilderFactory createDocumentBuilderFactory(int validationMode, boolean namespaceAware) throws ParserConfigurationException

Create the DocumentBuilderFactory instance.

Parameters
validationMode:int

the type of validation: DTD or XSD)

namespaceAware:boolean

whether the returned factory is to provide support for XML namespaces

Returns:DocumentBuilderFactory

the JAXP DocumentBuilderFactory

Exceptions
ParserConfigurationException:
if we failed to build a proper DocumentBuilderFactory
loadDocumentback to summary
public Document loadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception

Implements org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

Load the Document at the supplied InputSource using the standard JAXP-configured XML parser.

Parameters
inputSource:InputSource

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

the source of the document that is to be loaded

entityResolver:EntityResolver

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

the resolver that is to be used to resolve any entities

errorHandler:ErrorHandler

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

used to report any errors during document loading

validationMode:int

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

the type of validation DTD or XSD)

namespaceAware:boolean

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

true if support for XML namespaces is to be provided

Returns:Document

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

the loaded document

Annotations
@Override
Exceptions
Exception:

Doc from org.springframework.beans.factory.xml.DocumentLoader.loadDocument.

if an error occurs