public final class XmlFiles
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
W3C_NS_URI_XSD10
Default version of the XSD standard; Java 8 states that at least XSD 1.0 is supported.
|
static java.lang.String |
W3C_NS_URI_XSD11
XSD standard version 1.1 (specifically).
|
Modifier and Type | Method and Description |
---|---|
static LoadResult<org.w3c.dom.Document> |
load(java.io.File file)
Read and parse a XML document, without validation.
|
static LoadResult<org.w3c.dom.Document> |
load(java.io.File file,
boolean stopOnFirstError)
Read and parse a XML document, without validation.
|
static LoadResult<org.w3c.dom.Document> |
loadAndValidate(java.io.File file,
java.io.File schema,
java.lang.String schemaLang,
boolean stopOnFirstError)
Read and parse a XML document, validating against an internal or external schema.
|
static LoadResult<java.lang.Void> |
validate(java.io.File xmlFile,
java.io.File schemaFile,
java.lang.String schemaLanguage,
boolean stopOnFirstError)
Validates an XML file against a schema.
|
public static final java.lang.String W3C_NS_URI_XSD10
public static final java.lang.String W3C_NS_URI_XSD11
public static LoadResult<org.w3c.dom.Document> load(java.io.File file) throws java.io.FileNotFoundException
true
as the second argumentfile
- Path to the XML documentjava.io.FileNotFoundException
- if the file cannot be read.to validate at the same time as parsing
,
to validate after parsing
,
to validate after parsing
public static LoadResult<org.w3c.dom.Document> load(java.io.File file, boolean stopOnFirstError) throws java.io.FileNotFoundException
file
- Path to the XML documentstopOnFirstError
- If true, parsing will stop once any error is found. Otherwise, only
a fatal error will stop the process and all errors will be logged.java.io.FileNotFoundException
- if the file cannot be read.to validate at the same time as parsing
,
to validate after parsing
,
to validate after parsing
public static LoadResult<org.w3c.dom.Document> loadAndValidate(java.io.File file, java.io.File schema, java.lang.String schemaLang, boolean stopOnFirstError) throws java.io.FileNotFoundException
file
- Path to the XML documentschema
- Path to the schemaschemaLang
- One of the constants in this class denoting a schema language.stopOnFirstError
- If true, validation will stop once any error is found. Otherwise,
only a fatal error will stop the process and all errors will be logged.java.io.FileNotFoundException
- if the file cannot be loaded.to parse without validation
,
to validate a file without retrieving the data
,
to validate after parsing
,
to validate after parsing
public static LoadResult<java.lang.Void> validate(java.io.File xmlFile, java.io.File schemaFile, java.lang.String schemaLanguage, boolean stopOnFirstError)
xmlFile
- XML file location, must not be null.schemaFile
- Schema file location. If null, the result depends on the schema language.
For XSD, a schema linked by the XML file ("internal schema") will be used.schemaLanguage
- Constant for the schema language to use.stopOnFirstError
- If true, processing will be interrupted on the first error issued.LoadResult
with the parse+validation events. The result field
itself is always null
.to also get the DOM document
,
to validate a loaded DOM tree
,
to validate a loaded DOM tree