Class DefaultDocumentLoader
- java.lang.Object
- org.springframework.beans.factory.xml.DefaultDocumentLoader
- All Implemented Interfaces:
DocumentLoader
public class DefaultDocumentLoader extends Object implements DocumentLoader
Spring's defaultDocumentLoaderimplementation.Simply loads
documentsusing the standard JAXP-configured XML parser. If you want to change theDocumentBuilderthat 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 OracleDocumentBuilder, you might start your application like as follows:java -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory MyMainClass
- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
Constructor Summary
Constructors Constructor Description DefaultDocumentLoader()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DocumentBuildercreateDocumentBuilder(DocumentBuilderFactory factory, EntityResolver entityResolver, ErrorHandler errorHandler)Create a JAXP DocumentBuilder that this bean definition reader will use for parsing XML documents.protected DocumentBuilderFactorycreateDocumentBuilderFactory(int validationMode, boolean namespaceAware)Create theDocumentBuilderFactoryinstance.DocumentloadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware)Load theDocumentat the suppliedInputSourceusing the standard JAXP-configured XML parser.
Constructor Detail
DefaultDocumentLoader
public DefaultDocumentLoader()
Method Detail
loadDocument
public Document loadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception
Load theDocumentat the suppliedInputSourceusing the standard JAXP-configured XML parser.- Specified by:
loadDocumentin interfaceDocumentLoader- Parameters:
inputSource- the source of the document that is to be loadedentityResolver- the resolver that is to be used to resolve any entitieserrorHandler- used to report any errors during document loadingvalidationMode- the type of validationDTDorXSD)namespaceAware-trueif support for XML namespaces is to be provided- Returns:
- the loaded
document - Throws:
Exception- if an error occurs
createDocumentBuilderFactory
protected DocumentBuilderFactory createDocumentBuilderFactory(int validationMode, boolean namespaceAware) throws ParserConfigurationException
Create theDocumentBuilderFactoryinstance.- Parameters:
validationMode- the type of validation:DTDorXSD)namespaceAware- whether the returned factory is to provide support for XML namespaces- Returns:
- the JAXP DocumentBuilderFactory
- Throws:
ParserConfigurationException- if we failed to build a proper DocumentBuilderFactory
createDocumentBuilder
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- the JAXP DocumentBuilderFactory that the DocumentBuilder should be created withentityResolver- the SAX EntityResolver to useerrorHandler- the SAX ErrorHandler to use- Returns:
- the JAXP DocumentBuilder
- Throws:
ParserConfigurationException- if thrown by JAXP methods