Class AnnotationViewGenerator
- java.lang.Object
-
- org.apache.uima.tools.util.htmlview.AnnotationViewGenerator
-
public class AnnotationViewGenerator extends java.lang.ObjectUtility that uses XSL stylesheets to produce an HTML view (w/ Javascript) of an annotated document.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilemOutputDirDirectory in which this program will write its output files.private javax.xml.transform.TemplatesmStyleMapToCssXSL transform used to translate a style map XML file into the CSS stylesheet used in the annotation viewer.private javax.xml.transform.TemplatesmStyleMapToDocFrameXslXSL transform used to translate a style map XML file into ANOTHER XSL file, which can then be applied to an annotated document to produce the main document HTML view.private javax.xml.transform.TemplatesmStyleMapToLegendXSL transform used to translate a style map XML file into the HTML legend used in the annotation viewer.private javax.xml.transform.TransformerFactorymTFactoryTransformer factory for doing XSL transformations.
-
Constructor Summary
Constructors Constructor Description AnnotationViewGenerator(java.io.File aOutputDir)Creates a new AnnotationViewGenerator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringautoGenerateStyleMap(AnalysisEngineMetaData aTaeMetaData)Automatically generates a style map for the given text analysis engine.static java.lang.StringautoGenerateStyleMap(TypeSystemDescription aTypeSystem)Automatically generates a style map for the given type system.voidautoGenerateStyleMapFile(AnalysisEngine aAE, java.io.File aStyleMapFile)Automatically generates a style map file for the given analysis engine.voidautoGenerateStyleMapFile(AnalysisEngineMetaData aMetaData, java.io.File aStyleMapFile)Automatically generates a style map file for the given analysis engine metadata.voidautoGenerateStyleMapFile(TypeSystemDescription aTypeSystem, java.io.File aStyleMapFile)Automatically generates a style map file for the given type system.private javax.xml.transform.TemplatesgetTemplates(java.lang.String filename)Parses an XML file and produces a Templates object.voidprocessDocument(java.io.File aInlineXmlDoc)Processes an annotated document using the docFrame.xsl stylsheet generated by a previous call toprocessStyleMap(File).voidprocessStyleMap(java.io.File aStyleMap)Processes a user-specified file map and produces three outputs: annotations.css - A CSS stylesheet for the annotation viewer legend.html - HTML document for legend (bottom pane of viewer) docFrame.xsl - An XSL stylesheet to be applied to annotated documents during calls toprocessDocument(File).private voidwriteToFile(java.lang.String filename, java.io.File outputDir)Writes a resource file to disk.
-
-
-
Field Detail
-
mTFactory
private javax.xml.transform.TransformerFactory mTFactory
Transformer factory for doing XSL transformations.
-
mStyleMapToCss
private javax.xml.transform.Templates mStyleMapToCss
XSL transform used to translate a style map XML file into the CSS stylesheet used in the annotation viewer.
-
mStyleMapToLegend
private javax.xml.transform.Templates mStyleMapToLegend
XSL transform used to translate a style map XML file into the HTML legend used in the annotation viewer.
-
mStyleMapToDocFrameXsl
private javax.xml.transform.Templates mStyleMapToDocFrameXsl
XSL transform used to translate a style map XML file into ANOTHER XSL file, which can then be applied to an annotated document to produce the main document HTML view.
-
mOutputDir
private java.io.File mOutputDir
Directory in which this program will write its output files.
-
-
Method Detail
-
getTemplates
private javax.xml.transform.Templates getTemplates(java.lang.String filename)
Parses an XML file and produces a Templates object.- Parameters:
filename- name of .xsl file, to be looked up in the classpath, under the same package as this class.- Returns:
- Templates object usable for XSL transformation
-
writeToFile
private void writeToFile(java.lang.String filename, java.io.File outputDir)Writes a resource file to disk. The resource file is looked up in the classpath- Parameters:
filename- name of the file, to be looked up in the classpath, under the same package as this class.outputDir- the output dir
-
processStyleMap
public void processStyleMap(java.io.File aStyleMap) throws javax.xml.transform.TransformerExceptionProcesses a user-specified file map and produces three outputs:- annotations.css - A CSS stylesheet for the annotation viewer
- legend.html - HTML document for legend (bottom pane of viewer)
- docFrame.xsl - An XSL stylesheet to be applied to annotated documents during calls to
processDocument(File).
- Parameters:
aStyleMap- path to style map to be processed- Throws:
javax.xml.transform.TransformerException- the transformer exception
-
processDocument
public void processDocument(java.io.File aInlineXmlDoc) throws javax.xml.transform.TransformerExceptionProcesses an annotated document using the docFrame.xsl stylsheet generated by a previous call toprocessStyleMap(File). Generates a file named docView.html, which represents the HTML view of the annotated document.- Parameters:
aInlineXmlDoc- path to annotated document to be processed- Throws:
javax.xml.transform.TransformerException- the transformer exception
-
autoGenerateStyleMap
public static java.lang.String autoGenerateStyleMap(AnalysisEngineMetaData aTaeMetaData)
Automatically generates a style map for the given text analysis engine. The style map will be returned as an XML string.- Parameters:
aTaeMetaData- Metadata of the Text Analysis Engine whose outputs will be viewed using the generated style map.- Returns:
- a String containing the XML style map
-
autoGenerateStyleMap
public static java.lang.String autoGenerateStyleMap(TypeSystemDescription aTypeSystem)
Automatically generates a style map for the given type system. The style map will be returned as an XML string.- Parameters:
aTypeSystem- the type system for which a style map will be generated- Returns:
- a String containing the XML style map
-
autoGenerateStyleMapFile
public void autoGenerateStyleMapFile(AnalysisEngine aAE, java.io.File aStyleMapFile) throws java.io.IOException
Automatically generates a style map file for the given analysis engine. The style map will be written to the fileaStyleMapFile.- Parameters:
aAE- the Analysis Engine whose outputs will be viewed using the generated style map.aStyleMapFile- file to which autogenerated style map will be written- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
autoGenerateStyleMapFile
public void autoGenerateStyleMapFile(AnalysisEngineMetaData aMetaData, java.io.File aStyleMapFile) throws java.io.IOException
Automatically generates a style map file for the given analysis engine metadata. The style map will be written to the fileaStyleMapFile.- Parameters:
aMetaData- Metadata of the Analysis Engine whose outputs will be viewed using the generated style map.aStyleMapFile- file to which autogenerated style map will be written- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
autoGenerateStyleMapFile
public void autoGenerateStyleMapFile(TypeSystemDescription aTypeSystem, java.io.File aStyleMapFile) throws java.io.IOException
Automatically generates a style map file for the given type system. The style map will be written to the fileaStyleMapFile.- Parameters:
aTypeSystem- the type system for which a style map will be generatedaStyleMapFile- file to which autogenerated style map will be written- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
-