public final class LoadDocument extends Object implements LoadOptions
Can automatically associate a DocumentType
to loaded document
and hence, strip ignoreable whitespace and process inclusions.
This class is thread-safe.
DocumentLoader
ADD_ANY_DOCUMENT_TYPE, ADD_AUTO_DOCUMENT_TYPE, ADD_DECLARED_PREFIXES, ADD_LINE_COLUMN, ADD_XML_DECLARATION, DONT_INCLUDE, DONT_STRIP_WHITESPACE, GUESS_IGNORABLE_WHITESPACE, XINCLUDE
Modifier and Type | Method and Description |
---|---|
static void |
addBuiltInSubDocumentType(BuiltInSubDocumentType bi)
Registers specified built-in schema with
this document loading facility.
|
static LoadDocumentStep |
createLoadDocumentStep(boolean twoPasses,
int userOptions,
Console console)
Not part of the public, documented, API: creates and returns
a possibly custom
LoadDocumentStep . |
static SubDocumentType |
getBuiltInSubDocumentType(Namespace ns)
Returns registered built-in schema having specified target namespace.
|
static int |
getDefaultOptions()
Returns the options used by convenience functions
load(File) and load(URL) . |
static DocumentTypeDetector |
getDocumentTypeDetector()
Returns the DocumentTypeDetector currently registered with
this document loading facility.
|
static DTDAccelerator |
getDTDAccelerator()
Returns the DTDAccelerator currently registered with
this document loading facility.
|
static String |
getLoadDocumentStepClassName()
Not part of the public, documented, API: returns
the class name of a custom
LoadDocumentStep . |
static SubDocumentTypeCache |
getSubDocumentTypeCache()
Returns the SubDocumentTypeCache currently registered with
this document loading facility.
|
static Document |
load(File file)
Convenience method: equivalent to
load(file, getDefaultOptions(), null, null, null) , except
that it converts a SAXException to an IOException. |
static Document |
load(File file,
int options,
Console console,
List<LoadError> loadErrors,
List<LoadError> loadWarnings)
Loads document from specified file.
|
static Document |
load(InputSource source,
int options,
Console console,
List<LoadError> loadErrors,
List<LoadError> loadWarnings)
Loads document from specified source.
|
static Document |
load(InputSource source,
URL url,
int options,
Console console,
List<LoadError> loadErrors,
List<LoadError> loadWarnings)
Not for public use.
|
static Document |
load(URL url)
Convenience method: equivalent to
load(url, getDefaultOptions(), null, null, null) , except that
it converts a SAXException to an IOException. |
static Document |
load(URL url,
int options,
Console console,
List<LoadError> loadErrors,
List<LoadError> loadWarnings)
Loads document from specified file.
|
static void |
process(Document doc,
DocumentTypeSpec docTypeSpec,
int options,
Console console,
List<LoadError> loadErrors,
List<LoadError> loadWarnings)
Not for public use.
|
static void |
setDefaultOptions(int options)
Specifies the options used by convenience functions
load(File) and load(URL) . |
static void |
setDocumentTypeDetector(DocumentTypeDetector detect)
Registers specified DocumentTypeDetector with
this document loading facility.
|
static void |
setDTDAccelerator(DTDAccelerator accel)
Registers specified DTDAccelerator with this document loading facility.
|
static void |
setLoadDocumentStepClassName(String className)
Not part of the public, documented, API: allows to specify
the class name of a custom
LoadDocumentStep . |
static void |
setSubDocumentTypeCache(SubDocumentTypeCache cache)
Registers specified SubDocumentTypeCache with
this document loading facility.
|
public static void setDTDAccelerator(DTDAccelerator accel)
May be null
, in which case the loading of DTDs
is not accelerated.
Initial value: null
.
public static DTDAccelerator getDTDAccelerator()
null
if there is no such DTDAccelerator.public static void setSubDocumentTypeCache(SubDocumentTypeCache cache)
May be null
, in which case loaded schemas
are not cached.
Initial value: null
.
public static SubDocumentTypeCache getSubDocumentTypeCache()
null
if there is no such SubDocumentTypeCache.public static void addBuiltInSubDocumentType(BuiltInSubDocumentType bi)
Initially no built-in schemas are registered.
public static SubDocumentType getBuiltInSubDocumentType(Namespace ns)
null
if there is no such built-in schema or
if this schema failed to be loaded.public static void setDocumentTypeDetector(DocumentTypeDetector detect)
May be null
, in which case an instance of
DocumentTypeDetectorImpl
will be used when needed to.
Initial value: DocumentTypeDetectorImpl.INSTANCE
.
public static DocumentTypeDetector getDocumentTypeDetector()
null
if there is no such DocumentTypeDetector.public static void setDefaultOptions(int options)
load(File)
and load(URL)
.
By default, the default options mask is 0x0
.
public static int getDefaultOptions()
load(File)
and load(URL)
.public static void setLoadDocumentStepClassName(String className)
LoadDocumentStep
.getLoadDocumentStepClassName()
public static String getLoadDocumentStepClassName()
LoadDocumentStep
.public static LoadDocumentStep createLoadDocumentStep(boolean twoPasses, int userOptions, Console console)
LoadDocumentStep
.public static Document load(File file) throws IOException
load(file, getDefaultOptions(), null, null, null)
, except
that it converts a SAXException to an IOException.IOException
getDefaultOptions()
public static Document load(File file, int options, Console console, List<LoadError> loadErrors, List<LoadError> loadWarnings) throws SAXException, IOException
file
- filename of the XML source fileoptions
- an OR-mask of options such as
LoadOptions.ADD_LINE_COLUMN
,
LoadOptions.ADD_AUTO_DOCUMENT_TYPE
, etc.
May be 0x0
.console
- Console used to report progress messages
during a lengthy operation. May be null
.loadErrors
- Schema and inclusion errors are added
to this list. May be null
.
Note that schema and inclusion errors will not prevent this method
from returning loaded document.loadWarnings
- Schema and inclusion warnings are added
to this list. May be null
.IOException
- if an I/O error occurs during this operationSAXException
- for any other problem: for example,
if the source file does not contain well-formed XMLpublic static Document load(URL url) throws IOException
load(url, getDefaultOptions(), null, null, null)
, except that
it converts a SAXException to an IOException.IOException
getDefaultOptions()
public static Document load(URL url, int options, Console console, List<LoadError> loadErrors, List<LoadError> loadWarnings) throws SAXException, IOException
url
- URL of the XML source fileoptions
- an OR-mask of options such as
LoadOptions.ADD_LINE_COLUMN
,
LoadOptions.ADD_AUTO_DOCUMENT_TYPE
, etc.
May be 0x0
.console
- Console used to report progress messages
during a lengthy operation. May be null
.loadErrors
- Schema and inclusion errors are added
to this list. May be null
.
Note that schema and inclusion errors will not prevent this method
from returning loaded document.loadWarnings
- Schema and inclusion warnings are added
to this list. May be null
.IOException
- if an I/O error occurs during this operationSAXException
- for any other problem: for example,
if the source file does not contain well-formed XMLpublic static Document load(InputSource source, int options, Console console, List<LoadError> loadErrors, List<LoadError> loadWarnings) throws SAXException, IOException
source
- the XML sourceoptions
- an OR-mask of options such as
LoadOptions.ADD_LINE_COLUMN
,
LoadOptions.ADD_AUTO_DOCUMENT_TYPE
, etc.
May be 0x0
.console
- Console used to report progress messages
during a lengthy operation. May be null
.loadErrors
- Schema and inclusion errors are added
to this list. May be null
.
Note that schema and inclusion errors will not prevent this method
from returning loaded document.loadWarnings
- Schema and inclusion warnings are added
to this list. May be null
.IOException
- if an I/O error occurs during this operationSAXException
- for any other problem: for example,
if the source file does not contain well-formed XMLpublic static Document load(InputSource source, URL url, int options, Console console, List<LoadError> loadErrors, List<LoadError> loadWarnings) throws SAXException, IOException
SAXException
IOException
public static void process(Document doc, DocumentTypeSpec docTypeSpec, int options, Console console, List<LoadError> loadErrors, List<LoadError> loadWarnings) throws IOException
IOException