|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.xml.XMLConversionService
public final class XMLConversionService
Manages the conversion of XML files from one format to another using XSL or
Java classes. Caches the converted XML to disc and provides rapid access to
the converted format. Conversions may be accomplished using XSL stylesheets
or Java classes that implement one of either the XMLFormatConverter
or XMLDocumentFormatConverter
interfaces.
XMLFormatConverter
,
XMLDocumentFormatConverter
Constructor Summary | |
---|---|
XMLConversionService(File cacheDir,
boolean filterDeclarations)
Constructor for the XMLConversionService. |
Method Summary | |
---|---|
void |
addJavaConverterClass(String fromFormat,
String toFormat,
String className,
ServletContext servletContext)
Adds a concrete implementation of the XMLFormatConverter interface
that can convert XML from one format to another. |
boolean |
addJavaConverterHelper(String paramVal,
ServletContext servletContext)
Adds an Java class XML converter by parsing a String of the form [ fromFormat | toFormat | className ]. |
boolean |
addXslConverterHelper(String paramVal,
File xslFilesDirecoryPath)
Adds an XSL converter by parsing a String of the form [ fromFormat | toFormat | xslFileName ]. |
void |
addXslStylesheet(String fromFormat,
String toFormat,
String xslFilePath)
Adds a XSL stylesheet that can convert from one XML format to another. |
boolean |
canConvert(String fromFormat,
String toFormat)
Determines whether this XMLConversionService can perform the given converstion. |
String |
convertXml(String fromFormat,
String toFormat,
String originalXML)
Converts XML from one format to another, without the use of a cache to store or save results. |
ArrayList |
getAvailableFormats(String fromFormat)
Gets the metadata format conversions that are available for the given format, including the given format. |
static String |
getContentFromXML(String input)
Gets the content from XML by stripping all XML tags. |
StringBuffer |
getConvertedXml(String fromFormat,
String toFormat,
File originalXMLFile)
Converts XML from one format to another, saving and retrieving the converted content to and from a file cache. |
StringBuffer |
getConvertedXml(String fromFormat,
String toFormat,
File originalXMLFile,
XMLDocReader luceneDoc)
Converts XML from one format to another, saving and retrieving the converted content to and from a file cache. |
static String |
getDateStamp()
Gets a datestamp of the current time formatted for display with logs and output. |
static void |
setDebug(boolean db)
Sets the debug attribute of the SimpleLuceneIndex object |
static StringBuffer |
stripXmlDeclaration(BufferedReader rdr)
Strips the XML declaration and DTD declaration from the given XML. |
static XMLConversionService |
xmlConversionServiceFactoryForServlets(ServletContext servletContext,
File xslFilesDirecory,
File xmlCachDirecory,
boolean filterDeclarations)
Factory for use in Servlets to create an XMLConversionService using configurations found in the Servlet context parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLConversionService(File cacheDir, boolean filterDeclarations) throws IOException
cacheDir
- The directory where converted files will be
cached and stored for later retrieval by ID.filterDeclarations
- Set to true to filter out the XML and DTD
declarations in the converted XML.
IOException
- If the directory is not valid or does not have
read/write access.Method Detail |
---|
public StringBuffer getConvertedXml(String fromFormat, String toFormat, File originalXMLFile)
fromFormat
- The XML format to convert from. Example:
'dlese_ims.'toFormat
- The format to convert to. Example: 'adn.'originalXMLFile
- The original XML file, in the 'from' format.
public String convertXml(String fromFormat, String toFormat, String originalXML)
fromFormat
- The XML format to convert from. Example: 'dlese_ims.'toFormat
- The format to convert to. Example: 'adn.'originalXML
- The original XML as a String, in the 'from' format.
Should not be null.
public StringBuffer getConvertedXml(String fromFormat, String toFormat, File originalXMLFile, XMLDocReader luceneDoc)
fromFormat
- The XML format to convert from. Example:
'dlese_ims.'toFormat
- The format to convert to. Example: 'adn.'originalXMLFile
- The original XML file, in the 'from' format. Should
not be null.luceneDoc
- A Lucene Document
that holds content that may be used by the conversion class, or null.
public boolean canConvert(String fromFormat, String toFormat)
fromFormat
- The format to convert from.toFormat
- The format to convert to.
public ArrayList getAvailableFormats(String fromFormat)
fromFormat
- The format to convert from.
public void addXslStylesheet(String fromFormat, String toFormat, String xslFilePath)
fromFormat
- The XML format from which the stylesheet will convert.toFormat
- The XML format to which the stylesheet will convert.xslFilePath
- The absolute path to the stylesheet.public void addJavaConverterClass(String fromFormat, String toFormat, String className, ServletContext servletContext)
XMLFormatConverter
interface
that can convert XML from one format to another. The class must be
available in the classpath for Tomcat or the running JVM that is using this
broker.
fromFormat
- The XML format from which the class will convert.toFormat
- The XML format to which the class will convert.className
- The fully-qualified class that will perform the
conversion.servletContext
- The feature to be added to the JavaConverterClass
attributepublic boolean addXslConverterHelper(String paramVal, File xslFilesDirecoryPath)
paramVal
- A String of the form [ fromFormat | toFormat |
xslFileName ].xslFilesDirecoryPath
- The full path to the directory where the xsl
file exists.
public boolean addJavaConverterHelper(String paramVal, ServletContext servletContext)
paramVal
- A String of the form [ fromFormat | toFormat |
xslFileName ].servletContext
- The ServletContext that will be available to the
class when it executes.
public static XMLConversionService xmlConversionServiceFactoryForServlets(ServletContext servletContext, File xslFilesDirecory, File xmlCachDirecory, boolean filterDeclarations) throws Exception
To configure a format converter that uses an XSL style sheet or Java class, the context param-name must begin with the either 'xslconverter' or 'javaconverter' and must be unique. The param-value must be of the form 'xslfile.xsl|[from format]\[to format]' or '[fully qualified Java class]|[from format]\[to format]'.
servletContext
- The ServletContextxslFilesDirecory
- The base directory where the XSL files are
locatedxmlCachDirecory
- The directory where the service will cache the
converted XML filesfilterDeclarations
- Set to true to filter out the XML and DTD
declarations in the converted XML
Exception
- If errorpublic static final StringBuffer stripXmlDeclaration(BufferedReader rdr) throws IOException
rdr
- A BufferedReader containing XML.
IOException
- If errorpublic static final String getContentFromXML(String input)
input
- A valid XML string.
public static final String getDateStamp()
public static final void setDebug(boolean db)
db
- The new debug value
|
DLESE Tools v1.6.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |