Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Static Public Member Functions | Static Private Member Functions | List of all members
org.sleuthkit.autopsy.coreutils.XMLUtil Class Reference

Static Public Member Functions

static Document createDocument () throws ParserConfigurationException
 
static< T > Document loadDoc (Class< T > clazz, String xmlPath)
 
static< T > Document loadDoc (Class< T > clazz, String xmlPath, String xsdPath)
 
static< T > Document loadDocument (String docPath, Class< T > clazz, String schemaResourceName) throws IOException, ParserConfigurationException, SAXException
 
static Document loadDocument (String docPath) throws ParserConfigurationException, SAXException, IOException
 
static< T > boolean saveDoc (Class< T > clazz, String xmlPath, String encoding, final Document doc)
 
static void saveDocument (final Document doc, String encoding, String docPath) throws TransformerConfigurationException, FileNotFoundException, UnsupportedEncodingException, TransformerException, IOException
 
static< T > void validateDocument (final Document doc, Class< T > clazz, String schemaResourceName) throws SAXException, IOException
 
static< T > boolean xmlIsValid (DOMSource xmlfile, Class< T > clazz, String schemaFile)
 
static< T > boolean xmlIsValid (Document doc, Class< T > clazz, String type)
 

Static Private Member Functions

static DocumentBuilder getDocumentBuilder () throws ParserConfigurationException
 
static SchemaFactory getSchemaFactory (String schemaLanguage)
 
static TransformerFactory getTransformerFactory ()
 

Detailed Description

XML Utilities

This class provides basic utilities for working with XML files, such as -Validating XML files against a given schema -Saving documents to disk -Loading documents from disk

Definition at line 56 of file XMLUtil.java.

Member Function Documentation

static Document org.sleuthkit.autopsy.coreutils.XMLUtil.createDocument ( ) throws ParserConfigurationException
static

Creates a W3C DOM.

Returns
The document object.
Exceptions
ParserConfigurationException

Definition at line 99 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.getDocumentBuilder().

static DocumentBuilder org.sleuthkit.autopsy.coreutils.XMLUtil.getDocumentBuilder ( ) throws ParserConfigurationException
staticprivate
static SchemaFactory org.sleuthkit.autopsy.coreutils.XMLUtil.getSchemaFactory ( String  schemaLanguage)
staticprivate
static TransformerFactory org.sleuthkit.autopsy.coreutils.XMLUtil.getTransformerFactory ( )
staticprivate
static <T> Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc ( Class< T >  clazz,
String  xmlPath 
)
static

Loads XML files from disk

Parameters
clazzthe class this method is invoked from
xmlPaththe full path to the file to load

Definition at line 259 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.getDocumentBuilder(), and org.sleuthkit.autopsy.coreutils.Logger.getLogger().

Referenced by org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc().

static <T> Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc ( Class< T >  clazz,
String  xmlPath,
String  xsdPath 
)
static

Loads XML files from disk

Parameters
clazzthe class this method is invoked from
xmlPaththe full path to the file to load
xsdPaththe full path to the file to validate against

Definition at line 283 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.Logger.getLogger(), org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc(), and org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid().

static <T> Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDocument ( String  docPath,
Class< T >  clazz,
String  schemaResourceName 
) throws IOException, ParserConfigurationException, SAXException
static

Loads an XML document into a WC3 DOM and validates it using a schema packaged as a class resource.

Parameters
docPathThe full path to the XML document.
clazzThe class associated with the schema resource.
schemaResourceNameThe name of the schema resource.
Returns
The WC3 DOM document object.
Exceptions
IOException
ParserConfigurationException
SAXException

Definition at line 117 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.validateDocument().

static Document org.sleuthkit.autopsy.coreutils.XMLUtil.loadDocument ( String  docPath) throws ParserConfigurationException, SAXException, IOException
static

Loads an XML document into a WC3 DOM.

Parameters
docPathThe full path to the XML document.
Returns
The WC3 DOM document object.
Exceptions
ParserConfigurationException
SAXException
IOException

Definition at line 134 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.getDocumentBuilder().

static <T> boolean org.sleuthkit.autopsy.coreutils.XMLUtil.saveDoc ( Class< T >  clazz,
String  xmlPath,
String  encoding,
final Document  doc 
)
static

Saves XML files to disk

Parameters
clazzthe class this method is invoked from
xmlPaththe full path to save the XML to
encodingto encoding, such as "UTF-8", to encode the file with
docthe document to save

Definition at line 300 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.Logger.getLogger(), and org.sleuthkit.autopsy.coreutils.XMLUtil.getTransformerFactory().

static void org.sleuthkit.autopsy.coreutils.XMLUtil.saveDocument ( final Document  doc,
String  encoding,
String  docPath 
) throws TransformerConfigurationException, FileNotFoundException, UnsupportedEncodingException, TransformerException, IOException
static

Saves a WC3 DOM by writing it to an XML document.

Parameters
docThe WC3 DOM document object.
docPathThe full path to the XML document.
encodingEncoding scheme to use for the XML document, e.g., "UTF-8."
Exceptions
TransformerConfigurationException
FileNotFoundException
UnsupportedEncodingException
TransformerException
IOException

Definition at line 173 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.getTransformerFactory().

static <T> void org.sleuthkit.autopsy.coreutils.XMLUtil.validateDocument ( final Document  doc,
Class< T >  clazz,
String  schemaResourceName 
) throws SAXException, IOException
static

Validates a WC3 DOM using a schema packaged as a class resource.

Parameters
doc
clazz
schemaResourceName
Exceptions
SAXException
IOException

Definition at line 150 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.PlatformUtil.extractResourceToUserConfigDir(), org.sleuthkit.autopsy.coreutils.XMLUtil.getSchemaFactory(), and org.sleuthkit.autopsy.coreutils.PlatformUtil.getUserConfigDirectory().

Referenced by org.sleuthkit.autopsy.coreutils.XMLUtil.loadDocument().

static <T> boolean org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid ( DOMSource  xmlfile,
Class< T >  clazz,
String  schemaFile 
)
static

Utility to validate XML files against pre-defined schema files.

The schema files are extracted automatically when this function is called, the XML being validated is not. Be sure the XML file is already extracted otherwise it will return false.

Parameters
xmlfileThe XML file to validate, in DOMSource format
clazzclass frm package to extract schema file from
schemaFileThe file name of the schema to validate against, must exist as a resource in the same package as where this function is being called.

For example usages, please see KeywordSearchListsXML, HashDbXML, or IngestModuleLoader.

Definition at line 208 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.PlatformUtil.extractResourceToUserConfigDir(), org.sleuthkit.autopsy.coreutils.Logger.getLogger(), org.sleuthkit.autopsy.coreutils.XMLUtil.getSchemaFactory(), and org.sleuthkit.autopsy.coreutils.PlatformUtil.getUserConfigDirectory().

Referenced by org.sleuthkit.autopsy.coreutils.XMLUtil.loadDoc(), and org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid().

static <T> boolean org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid ( Document  doc,
Class< T >  clazz,
String  type 
)
static

Evaluates XML files against an XSD.

The schema files are extracted automatically when this function is called, the XML being validated is not. Be sure the XML file is already extracted otherwise it will return false.

Parameters
docThe XML DOM to validate
clazzclass from package to extract schema from
typeThe file name of the schema to validate against, must exist as a resource in the same package as where this function is being called

For example usages, please see KeywordSearchListsXML, HashDbXML, or IngestModuleLoader.

Definition at line 247 of file XMLUtil.java.

References org.sleuthkit.autopsy.coreutils.XMLUtil.xmlIsValid().


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

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.