Package org.bremersee.xml
Interface XmlDocumentBuilder
public interface XmlDocumentBuilder
The xml document builder wraps the functionality of
DocumentBuilderFactory
. Checked
exceptions will be wrapped into XmlRuntimeException
.- Author:
- Christian Bremer
-
Method Summary
Modifier and TypeMethodDescriptionBuilds an empty document.buildDocument
(File file) Builds document from file.Builds document from input stream.buildDocument
(InputStream is, String systemId) Builds document from input stream and system ID.buildDocument
(Object jaxbElement, jakarta.xml.bind.JAXBContext jaxbContext) Builds document from an object (POJO) that can be processed withJAXBContext
.buildDocument
(Object jaxbElement, jakarta.xml.bind.Marshaller marshaller) Builds document from an object (POJO) that can be processed withMarshaller
.buildDocument
(String uri) Builds document from uri.Builds document from input source.Creates a new document builder.configureEntityResolver
(EntityResolver entityResolver) Sets the entity resolver to the createdDocumentBuilder
.configureErrorHandler
(ErrorHandler errorHandler) Sets error handler to the createdDocumentBuilder
.configureFactory
(Boolean coalescing, Boolean expandEntityReferences, Boolean ignoringComments, Boolean ignoringElementContentWhitespace, Boolean namespaceAware, Boolean validating, Boolean xIncludeAware) Configures theDocumentBuilderFactory
.configureFactory
(XmlDocumentBuilderFactoryConfigurator configurator) Configures theDocumentBuilderFactory
.configureFactoryAttribute
(String name, Object value) Sets the given attribute to the underlyingDocumentBuilderFactory
.configureFactoryFeature
(String name, boolean value) Sets the given feature to the underlyingDocumentBuilderFactory
.configureFactorySchema
(Schema schema) Sets the given schema to the underlyingDocumentBuilderFactory
.static XmlDocumentBuilder
Creates default builder instance.
-
Method Details
-
newInstance
Creates default builder instance.- Returns:
- the default builder instance
-
configureFactory
Configures theDocumentBuilderFactory
. The default xml document builder has the same default values as the underlying factory except thatDocumentBuilderFactory.setNamespaceAware(boolean)
is set totrue
.- Parameters:
configurator
- the configurator- Returns:
- the xml document builder
-
configureFactory
XmlDocumentBuilder configureFactory(Boolean coalescing, Boolean expandEntityReferences, Boolean ignoringComments, Boolean ignoringElementContentWhitespace, Boolean namespaceAware, Boolean validating, Boolean xIncludeAware) Configures theDocumentBuilderFactory
. The default xml document builder has the same default values as the underlying factory except thatDocumentBuilderFactory.setNamespaceAware(boolean)
is set totrue
.A value with
null
will be ignored and the default will be used.The default values are:
coalescing = false expandEntityReferences = true ignoringComments = false ignoringElementContentWhitespace = false namespaceAware = true validating = false xIncludeAware = false
- Parameters:
coalescing
- the coalescingexpandEntityReferences
- the expanded entity referencesignoringComments
- the ignoring commentsignoringElementContentWhitespace
- the ignoring element content whitespacenamespaceAware
- the namespace awarevalidating
- the validatingxIncludeAware
- the x include aware- Returns:
- the xml document builder
-
configureFactoryAttribute
Sets the given attribute to the underlyingDocumentBuilderFactory
.- Parameters:
name
- the namevalue
- the value- Returns:
- the xml document builder
- See Also:
-
configureFactoryFeature
Sets the given feature to the underlyingDocumentBuilderFactory
.- Parameters:
name
- the namevalue
- the value- Returns:
- the xml document builder
- See Also:
-
configureFactorySchema
Sets the given schema to the underlyingDocumentBuilderFactory
.- Parameters:
schema
- the schema- Returns:
- the xml document builder
- See Also:
-
configureEntityResolver
Sets the entity resolver to the createdDocumentBuilder
.- Parameters:
entityResolver
- the entity resolver- Returns:
- the xml document builder
- See Also:
-
configureErrorHandler
Sets error handler to the createdDocumentBuilder
.- Parameters:
errorHandler
- the error handler- Returns:
- the xml document builder
- See Also:
-
buildDocumentBuilder
DocumentBuilder buildDocumentBuilder()Creates a new document builder.- Returns:
- the document builder
-
buildDocument
Document buildDocument()Builds an empty document.- Returns:
- the document
-
buildDocument
Builds document from file.- Parameters:
file
- the file- Returns:
- the document
-
buildDocument
Builds document from uri.- Parameters:
uri
- the uri- Returns:
- the document
-
buildDocument
Builds document from input source.- Parameters:
is
- the input source- Returns:
- the document
-
buildDocument
Builds document from input stream.- Parameters:
is
- the input stream- Returns:
- the document
-
buildDocument
Builds document from input stream and system ID.- Parameters:
is
- the input streamsystemId
- the system id- Returns:
- the document
-
buildDocument
Builds document from an object (POJO) that can be processed withJAXBContext
.- Parameters:
jaxbElement
- the jaxb elementjaxbContext
- the jaxb context- Returns:
- the document
-
buildDocument
Builds document from an object (POJO) that can be processed withMarshaller
.- Parameters:
jaxbElement
- the jaxb elementmarshaller
- the marshaller- Returns:
- the document
-