OSFI-Java  3.9.3
OpenSF Integration Library
esa.opensf.osfi.xmlutils.XmlFiles Class Reference

Static Public Member Functions

static LoadResult< Document > load (final File file) throws FileNotFoundException
 
static LoadResult< Document > load (final File file, final boolean stopOnFirstError) throws FileNotFoundException
 
static LoadResult< Document > loadAndValidate (final File file, final File schema, final String schemaLang, final boolean stopOnFirstError) throws FileNotFoundException
 
static LoadResult< Void > validate (final File xmlFile, final File schemaFile, final String schemaLanguage, final boolean stopOnFirstError)
 

Static Public Attributes

static final String W3C_NS_URI_XSD10 = XMLConstants.W3C_XML_SCHEMA_NS_URI
 
static final String W3C_NS_URI_XSD11 = "http://www.w3.org/XML/XMLSchema/v1.1"
 

Member Function Documentation

◆ load() [1/2]

static LoadResult<Document> esa.opensf.osfi.xmlutils.XmlFiles.load ( final File  file) throws FileNotFoundException
static

Read and parse a XML document, without validation. Equivalent to calling the other overload with

true

as the second argument

Parameters
filePath to the XML document
Exceptions
FileNotFoundExceptionif the file cannot be read.
Returns
Object containing the result (if successful) and the list of parsing errors (if not).
See also
loadAndValidate(File, File, String, boolean) to validate at the same time as parsing
DomUtils::validateAgainst(org.w3c.dom.Node, String) to validate after parsing
DomUtils::validateAgainstInternalSchema(org.w3c.dom.Node) to validate after parsing

◆ load() [2/2]

static LoadResult<Document> esa.opensf.osfi.xmlutils.XmlFiles.load ( final File  file,
final boolean  stopOnFirstError 
) throws FileNotFoundException
static

Read and parse a XML document, without validation.

Parameters
filePath to the XML document
stopOnFirstErrorIf true, parsing will stop once any error is found. Otherwise, only a fatal error will stop the process and all errors will be logged.
Exceptions
FileNotFoundExceptionif the file cannot be read.
Returns
Object containing the result (if successful) and the list of parsing errors (if not).
See also
loadAndValidate(File, File, String, boolean) to validate at the same time as parsing
DomUtils::validateAgainst(org.w3c.dom.Node, String) to validate after parsing
DomUtils::validateAgainstInternalSchema(org.w3c.dom.Node) to validate after parsing

◆ loadAndValidate()

static LoadResult<Document> esa.opensf.osfi.xmlutils.XmlFiles.loadAndValidate ( final File  file,
final File  schema,
final String  schemaLang,
final boolean  stopOnFirstError 
) throws FileNotFoundException
static

Read and parse a XML document, validating against an internal or external schema.

Parameters
filePath to the XML document
schemaPath to the schema
schemaLangOne of the constants in this class denoting a schema language.
stopOnFirstErrorIf true, validation will stop once any error is found. Otherwise, only a fatal error will stop the process and all errors will be logged.
Exceptions
FileNotFoundExceptionif the file cannot be loaded.
Returns
An object containing the result (if successful) and the list of parsing/validation warnings and errors.
See also
load(File, boolean) to parse without validation
validate(File, File, String, boolean) to validate a file without retrieving the data
DomUtils::validateAgainst(org.w3c.dom.Node, String) to validate after parsing
DomUtils::validateAgainstInternalSchema(org.w3c.dom.Node) to validate after parsing

◆ validate()

static LoadResult<Void> esa.opensf.osfi.xmlutils.XmlFiles.validate ( final File  xmlFile,
final File  schemaFile,
final String  schemaLanguage,
final boolean  stopOnFirstError 
)
static

Validates an XML file against a schema. This function never throws.

Parameters
xmlFileXML file location, must not be null.
schemaFileSchema 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.
schemaLanguageConstant for the schema language to use.
stopOnFirstErrorIf true, processing will be interrupted on the first error issued.
Returns
An instance of LoadResult with the parse+validation events. The result field itself is always
null
.
See also
loadAndValidate(File, File, String, boolean) to also get the DOM document
DomUtils::validateAgainst(org.w3c.dom.Node, String) to validate a loaded DOM tree
DomUtils::validateAgainstInternalSchema(org.w3c.dom.Node) to validate a loaded DOM tree

References esa.opensf.osfi.LoadResult< R >.SEV_ERROR, esa.opensf.osfi.LoadResult< R >.SEV_FATAL, and esa.opensf.osfi.LoadResult< R >.SEV_WARNING.

Member Data Documentation

◆ W3C_NS_URI_XSD10

final String esa.opensf.osfi.xmlutils.XmlFiles.W3C_NS_URI_XSD10 = XMLConstants.W3C_XML_SCHEMA_NS_URI
static

Default version of the XSD standard; Java 8 states that at least XSD 1.0 is supported.

◆ W3C_NS_URI_XSD11

final String esa.opensf.osfi.xmlutils.XmlFiles.W3C_NS_URI_XSD11 = "http://www.w3.org/XML/XMLSchema/v1.1"
static

XSD standard version 1.1 (specifically). It may not be supported if not using a specific library e.g. Xerces-J 2.11 or later.


The documentation for this class was generated from the following file: