public final class XMLConversionService
extends java.lang.Object
XMLFormatConverter
or XMLDocumentFormatConverter
interfaces.XMLFormatConverter
,
XMLDocumentFormatConverter
Constructor and Description |
---|
XMLConversionService(java.io.File cacheDir,
boolean filterDeclarations)
Constructor for the XMLConversionService.
|
Modifier and Type | Method and Description |
---|---|
void |
addJavaConverterClass(java.lang.String fromFormat,
java.lang.String toFormat,
java.lang.String className,
javax.servlet.ServletContext servletContext)
Adds a concrete implementation of the
XMLFormatConverter interface
that can convert XML from one format to another. |
boolean |
addJavaConverterHelper(java.lang.String paramVal,
javax.servlet.ServletContext servletContext)
Adds an Java class XML converter by parsing a String of the form [
fromFormat | toFormat | className ].
|
boolean |
addXslConverterHelper(java.lang.String paramVal,
java.io.File xslFilesDirecoryPath)
Adds an XSL converter by parsing a String of the form [ fromFormat |
toFormat | xslFileName ].
|
void |
addXslStylesheet(java.lang.String fromFormat,
java.lang.String toFormat,
java.lang.String xslFilePath)
Adds a XSL stylesheet that can convert from one XML format to another.
|
boolean |
canConvert(java.lang.String fromFormat,
java.lang.String toFormat)
Determines whether this XMLConversionService can perform the given
converstion.
|
java.lang.String |
convertXml(java.lang.String fromFormat,
java.lang.String toFormat,
java.lang.String originalXML)
Converts XML from one format to another, without the use of a cache to
store or save results.
|
java.util.ArrayList |
getAvailableFormats(java.lang.String fromFormat)
Gets the metadata format conversions that are available for the given
format, including the given format.
|
static java.lang.String |
getContentFromXML(java.lang.String input)
Gets the content from XML by stripping all XML tags.
|
java.lang.StringBuffer |
getConvertedXml(java.lang.String fromFormat,
java.lang.String toFormat,
java.io.File originalXMLFile)
Converts XML from one format to another, saving and retrieving the
converted content to and from a file cache.
|
java.lang.StringBuffer |
getConvertedXml(java.lang.String fromFormat,
java.lang.String toFormat,
java.io.File originalXMLFile,
XMLDocReader luceneDoc)
Converts XML from one format to another, saving and retrieving the
converted content to and from a file cache.
|
static java.lang.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 java.lang.StringBuffer |
stripXmlDeclaration(java.io.BufferedReader rdr)
Strips the XML declaration and DTD declaration from the given XML.
|
static XMLConversionService |
xmlConversionServiceFactoryForServlets(javax.servlet.ServletContext servletContext,
java.io.File xslFilesDirecory,
java.io.File xmlCachDirecory,
boolean filterDeclarations)
Factory for use in Servlets to create an XMLConversionService using
configurations found in the Servlet context parameters.
|
public XMLConversionService(java.io.File cacheDir, boolean filterDeclarations) throws java.io.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.java.io.IOException
- If the directory is not valid or does not have
read/write access.public java.lang.StringBuffer getConvertedXml(java.lang.String fromFormat, java.lang.String toFormat, java.io.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 java.lang.String convertXml(java.lang.String fromFormat, java.lang.String toFormat, java.lang.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 java.lang.StringBuffer getConvertedXml(java.lang.String fromFormat, java.lang.String toFormat, java.io.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(java.lang.String fromFormat, java.lang.String toFormat)
fromFormat
- The format to convert from.toFormat
- The format to convert to.public java.util.ArrayList getAvailableFormats(java.lang.String fromFormat)
fromFormat
- The format to convert from.public void addXslStylesheet(java.lang.String fromFormat, java.lang.String toFormat, java.lang.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(java.lang.String fromFormat, java.lang.String toFormat, java.lang.String className, javax.servlet.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(java.lang.String paramVal, java.io.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(java.lang.String paramVal, javax.servlet.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(javax.servlet.ServletContext servletContext, java.io.File xslFilesDirecory, java.io.File xmlCachDirecory, boolean filterDeclarations) throws java.lang.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 XMLjava.lang.Exception
- If errorpublic static final java.lang.StringBuffer stripXmlDeclaration(java.io.BufferedReader rdr) throws java.io.IOException
rdr
- A BufferedReader containing XML.java.io.IOException
- If errorpublic static final java.lang.String getContentFromXML(java.lang.String input)
input
- A valid XML string.public static final java.lang.String getDateStamp()
public static final void setDebug(boolean db)
db
- The new debug value