Class DefaultdocumentLoader
java.lang.Object
org.springframework.beans.factory.xml.DefaultdocumentLoader
- All Implemented Interfaces:
documentLoader
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
- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected documentBuildercreatedocumentBuilder(documentBuilderFactory factory, @Nullable EntityResolver entityResolver, @Nullable 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.loaddocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) Load thedocumentat the suppliedInputSourceusing the standard JAXP-configured XML parser.
-
Constructor Details
-
DefaultdocumentLoader
public DefaultdocumentLoader()
-
-
Method Details
-
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, @Nullable EntityResolver entityResolver, @Nullable 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
-