Package org.apache.uima.util
Class CasToInlineXml
java.lang.Object
org.apache.uima.util.CasToInlineXml
Generates an *approximate* inline XML representation of a CAS. Annotation types are represented
as XML tags, features are represented as attributes.
Features whose values are FeatureStructures are not represented. Feature values which are strings
longer than 64 characters are truncated. Feature values which are arrays of primitives are
represented by strings that look like [ xxx, xxx ]
The Subject of analysis is presumed to be a text string.
Some characters in the document's Subject-of-analysis are replaced by blanks, because the
characters aren't valid in xml documents.
It doesn't work for annotations which are overlapping, because these cannot be properly
represented as properly - nested XML.
To use this, make an instance of this class, and (optionally) set the formattedOutput to true or
false.
Then call one of the public methods to format or generate the Inline XML.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
This destroy method does nothing.Formats a CAS as a String.format
(CAS aCAS, FSMatchConstraint aFilter) Formats a CAS as a String.generateXML
(CAS aCAS) Generates inline XML from a CAS.generateXML
(CAS aCAS, FSMatchConstraint aFilter) Generates inline XML from a CAS.void
generateXML
(CAS aCAS, FSMatchConstraint aFilter, ContentHandler aHandler) Generates inline XML from a CAS using a passed in ContentHandlerboolean
void
setFormattedOutput
(boolean formattedOutput) Set a flag that will be used to control how the ContentHandler will be initialized - to either format or not, the generated Inline XML
-
Constructor Details
-
CasToInlineXml
public CasToInlineXml()
-
-
Method Details
-
destroy
public void destroy()This destroy method does nothing.- See Also:
-
format
Formats a CAS as a String.- Parameters:
aCAS
- the cas to format as an xml string- Returns:
- the XML representation of the CAS
- Throws:
CASException
- -
-
format
Formats a CAS as a String. Only FeatureStructures matching the given filter will be output.- Parameters:
aCAS
- CASaFilter
- a filter to limit the Feature Structures- Returns:
- the XML representation
- Throws:
CASException
- -
-
generateXML
Generates inline XML from a CAS.- Parameters:
aCAS
- CAS to generate from- Returns:
- the inline XML version of the CAS
- Throws:
CASException
- -
-
generateXML
public void generateXML(CAS aCAS, FSMatchConstraint aFilter, ContentHandler aHandler) throws CASException Generates inline XML from a CAS using a passed in ContentHandler- Parameters:
aCAS
- CAS to generate fromaFilter
- constraint that determines which annotations are included in the output. If null (or omitted), all annotations are included.aHandler
- the content handler to use- Throws:
CASException
- -
-
generateXML
Generates inline XML from a CAS.- Parameters:
aCAS
- CAS to generate fromaFilter
- constraint that determines which annotations are included in the output. If null (or ommitted), all annotations are included.- Returns:
- the inline form
- Throws:
CASException
- -
-
isFormattedOutput
public boolean isFormattedOutput()- Returns:
- true if the output will be formatted
-
setFormattedOutput
public void setFormattedOutput(boolean formattedOutput) Set a flag that will be used to control how the ContentHandler will be initialized - to either format or not, the generated Inline XML- Parameters:
formattedOutput
- true means to format the output, and is the default
-