public interface XMLParser
XMLParser
parses XML documents and generates UIMA components represented by
the XML.
An application obtains a reference to the XMLParser
by calling the
UIMAFramework.getXMLParser()
method. The application then uses the
XMLParser
by passing an InputStream
to one of its
parse
methods - for example
parseAnalysisEngineDescription(XMLInputSource)
for parsing an
AnalysisEngineDescription
from its XML representation.
XML schema validation is off by default; it can be turned on by calling the method
enableSchemaValidation(boolean)
.
UIMA developers who provide new types of XMLizable components must configure the XML parser by
using the addMapping(String,String)
method to specify mappings between XML Element names
and the class names of the objects to be built from elements with those names. All objects to be
built by the XML parser must implement XMLizable
and provide an implementation of
XMLizable.buildFromXMLElement(Element, XMLParser)
.
Note that we are considering replacing this ad-hoc XML data binding interface with the java standard extension JAXB. See http://java.sun.com/xml/jaxb for details on JAXB.
Modifier and Type | Interface and Description |
---|---|
static class |
XMLParser.ParsingOptions
Option settings for the parser.
|
Modifier and Type | Field and Description |
---|---|
static String |
RESOURCE_SPECIFIER_NAMESPACE
XML namespace for ResourceSpecifiers.
|
static String |
RESOURCE_SPECIFIER_SCHEMA_NAME
Name of schema for ResourceSpecifiers.
|
Modifier and Type | Method and Description |
---|---|
void |
addMapping(String aElementName,
String aClassName)
Configures this XMLParser by registering a mapping between the name of an XML element and the
Class of object to be built from elements with that name.
|
XMLizable |
buildObject(Element aElement)
Builds an object from its XML DOM representation.
|
XMLizable |
buildObject(Element aElement,
XMLParser.ParsingOptions aOptions)
Builds an object from its XML DOM representation.
|
Object |
buildObjectOrPrimitive(Element aElement,
XMLParser.ParsingOptions aOptions)
Builds an object from its XML DOM representation.
|
void |
enableSchemaValidation(boolean aEnable)
Enables or disables XML schema validation.
|
SaxDeserializer |
newSaxDeserializer()
Creates a new
SaxDeserializer object, which implements the SAX
ContentHandler interface and can be used to deserialize an
XMLizable object from the events sent from a SAX parser. |
SaxDeserializer |
newSaxDeserializer(XMLParser.ParsingOptions aOptions)
Creates a new
SaxDeserializer . |
XMLizable |
parse(XMLInputSource aInput)
Parses an XML input stream and produces an object.
|
XMLizable |
parse(XMLInputSource aInput,
String aNamespaceForSchema,
URL aSchemaUrl)
Parses an XML input stream and produces an object.
|
XMLizable |
parse(XMLInputSource aInput,
String aNamespaceForSchema,
URL aSchemaUrl,
XMLParser.ParsingOptions aOptions)
Parses an XML input stream and produces an object.
|
XMLizable |
parse(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses an XML input stream and produces an object.
|
AnalysisEngineDescription |
parseAnalysisEngineDescription(XMLInputSource aInput)
Parses an AnalysisEngineDescription from an XML input stream.
|
AnalysisEngineDescription |
parseAnalysisEngineDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses an AnalysisEngineDescription from an XML input stream.
|
CasConsumerDescription |
parseCasConsumerDescription(XMLInputSource aInput)
Parses a CasConsumerDescription from an XML input stream.
|
CasConsumerDescription |
parseCasConsumerDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a CasConsumerDescription from an XML input stream.
|
CasInitializerDescription |
parseCasInitializerDescription(XMLInputSource aInput)
Parses a CasInitializerDescription from an XML input stream.
|
CasInitializerDescription |
parseCasInitializerDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a CasInitializerDescription from an XML input stream.
|
CollectionReaderDescription |
parseCollectionReaderDescription(XMLInputSource aInput)
Parses a CollectionReaderDescription from an XML input stream.
|
CollectionReaderDescription |
parseCollectionReaderDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a CollectionReaderDescription from an XML input stream.
|
CpeDescription |
parseCpeDescription(XMLInputSource aInput)
Parses a CpeDescription from an XML input stream.
|
CustomResourceSpecifier |
parseCustomResourceSpecifier(XMLInputSource aInput)
Parses a CustomResourceSpecifier from an XML input stream.
|
CustomResourceSpecifier |
parseCustomResourceSpecifier(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a CustomResourceSpecifier from an XML input stream.
|
FlowControllerDescription |
parseFlowControllerDescription(XMLInputSource aInput)
Parses a FlowControllerDescription from an XML input stream.
|
FlowControllerDescription |
parseFlowControllerDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a FlowControllerDescription from an XML input stream.
|
FsIndexCollection |
parseFsIndexCollection(XMLInputSource aInput)
Parses a FsIndexCollection from an XML input stream.
|
FsIndexCollection |
parseFsIndexCollection(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a FsIndexCollection from an XML input stream.
|
IndexBuildSpecification |
parseIndexBuildSpecification(XMLInputSource aInput)
Parses an IndexBuildSpecification from an XML input stream.
|
IndexBuildSpecification |
parseIndexBuildSpecification(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses an IndexBuildSpecification from an XML input stream.
|
PearSpecifier |
parsePearSpecifier(XMLInputSource aInput)
Parses a PearSpecifier from an XML input stream.
|
PearSpecifier |
parsePearSpecifier(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a PearSpecifier from an XML input stream.
|
ResourceManagerConfiguration |
parseResourceManagerConfiguration(XMLInputSource aInput)
Parses a ResourceManagerConfiguration from an XML input stream.
|
ResourceManagerConfiguration |
parseResourceManagerConfiguration(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a ResourceManagerConfiguration from an XML input stream.
|
ResourceMetaData |
parseResourceMetaData(XMLInputSource aInput)
Parses a ResourceMetaData object from an XML input stream.
|
ResourceMetaData |
parseResourceMetaData(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a ResourceMetaData object from an XML input stream.
|
ResourceSpecifier |
parseResourceSpecifier(XMLInputSource aInput)
Parses a ResourceSpecifier from an XML input stream.
|
ResourceSpecifier |
parseResourceSpecifier(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a ResourceSpecifier from an XML input stream.
|
ResultSpecification |
parseResultSpecification(XMLInputSource aInput)
Parses a ResultSpecification from an XML input stream.
|
ResultSpecification |
parseResultSpecification(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a ResultSpecification from an XML input stream.
|
TaeDescription |
parseTaeDescription(XMLInputSource aInput)
Deprecated.
As of v2.0,
parseAnalysisEngineDescription(XMLInputSource) should be used
instead. |
TaeDescription |
parseTaeDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Deprecated.
As of v2.0,
parseAnalysisEngineDescription(XMLInputSource,ParsingOptions)
should be used instead. |
TypePriorities |
parseTypePriorities(XMLInputSource aInput)
Parses a TypePriorities declaration from an XML input stream.
|
TypePriorities |
parseTypePriorities(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a TypePriorities declaration from an XML input stream.
|
TypeSystemDescription |
parseTypeSystemDescription(XMLInputSource aInput)
Parses a TypeSystemDescription from an XML input stream.
|
TypeSystemDescription |
parseTypeSystemDescription(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a TypeSystemDescription from an XML input stream.
|
URISpecifier |
parseURISpecifier(XMLInputSource aInput)
Parses a URISpecifier from an XML input stream.
|
URISpecifier |
parseURISpecifier(XMLInputSource aInput,
XMLParser.ParsingOptions aOptions)
Parses a URISpecifier from an XML input stream.
|
static final String RESOURCE_SPECIFIER_NAMESPACE
static final String RESOURCE_SPECIFIER_SCHEMA_NAME
void enableSchemaValidation(boolean aEnable)
aEnable
- true to enable validation, false to disable validationXMLizable parse(XMLInputSource aInput, String aNamespaceForSchema, URL aSchemaUrl) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaNamespaceForSchema
- XML namespace for elements to be validated against XML schema. If null, no schema will
be used (unless one is declared in the document itself). This parameter is ignored if
schema validation has not been enabled via enableSchemaValidation(boolean)
.aSchemaUrl
- URL to XML schema that will be used to validate the XML document. If null, no schema
will be used (unless one is declared in the document itself). This parameter is
ignored if schema validation has not been enabled via
enableSchemaValidation(boolean)
.XMLizable
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid objectXMLizable parse(XMLInputSource aInput, String aNamespaceForSchema, URL aSchemaUrl, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaNamespaceForSchema
- XML namespace for elements to be validated against XML schema. If null, no schema will
be used (unless one is declared in the document itself). This parameter is ignored if
schema validation has not been enabled via enableSchemaValidation(boolean)
.aSchemaUrl
- URL to XML schema that will be used to validate the XML document. If null, no schema
will be used (unless one is declared in the document itself). This parameter is
ignored if schema validation has not been enabled via
enableSchemaValidation(boolean)
.aOptions
- option settingsXMLizable
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid objectXMLizable parse(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentXMLizable
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid objectXMLizable parse(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsXMLizable
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid objectResourceSpecifier parseResourceSpecifier(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentResourceSpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid ResourceSpecifierResourceSpecifier parseResourceSpecifier(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsResourceSpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid ResourceSpecifierResourceMetaData parseResourceMetaData(XMLInputSource aInput) throws InvalidXMLException
RESOURCE_SPECIFIER_SCHEMA_NAME
if it can be found in the classpath.aInput
- the input source from which to read the XML documentResourceMetaData
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid ResourceSpecifierResourceMetaData parseResourceMetaData(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
RESOURCE_SPECIFIER_SCHEMA_NAME
if it can be found in the classpath.aInput
- the input source from which to read the XML documentaOptions
- option settingsResourceMetaData
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid ResourceSpecifierURISpecifier parseURISpecifier(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentURISpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid URISpecifierURISpecifier parseURISpecifier(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsURISpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid URISpecifierAnalysisEngineDescription parseAnalysisEngineDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsAnalysisEngineDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid AnalysisEngineDescriptionAnalysisEngineDescription parseAnalysisEngineDescription(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentAnalysisEngineDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid AnalysisEngineDescription@Deprecated TaeDescription parseTaeDescription(XMLInputSource aInput) throws InvalidXMLException
parseAnalysisEngineDescription(XMLInputSource)
should be used
instead.aInput
- the input source from which to read the XML documentTaeDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid TaeDescription@Deprecated TaeDescription parseTaeDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
parseAnalysisEngineDescription(XMLInputSource,ParsingOptions)
should be used instead.aInput
- the input source from which to read the XML documentaOptions
- option settingsTaeDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid TaeDescriptionCasConsumerDescription parseCasConsumerDescription(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentCasConsumerDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CasConsumerDescriptionCasConsumerDescription parseCasConsumerDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsCasConsumerDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CasConsumerDescriptionCasInitializerDescription parseCasInitializerDescription(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentCasInitializerDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CasInitializerDescriptionCasInitializerDescription parseCasInitializerDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsCasInitializerDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CasInitializerDescriptionCollectionReaderDescription parseCollectionReaderDescription(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentCollectionReaderDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CollectionReaderDescriptionCollectionReaderDescription parseCollectionReaderDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsCollectionReaderDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CollectionReaderDescriptionCpeDescription parseCpeDescription(XMLInputSource aInput) throws InvalidXMLException
NOTE: the option settings XMLParser.ParsingOptions
are not currently available for parsing
CpeDescriptions, because they use a different parsing mechanism than the other specifier types.
aInput
- the input source from which to read the XML documentcpeDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid IndexingSpecificationResultSpecification parseResultSpecification(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentResultSpecification
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid ResultSpecificationResultSpecification parseResultSpecification(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsResultSpecification
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid ResultSpecificationTypeSystemDescription parseTypeSystemDescription(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentTypeSystemDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid TypeSystemDescriptionTypeSystemDescription parseTypeSystemDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsTypeSystemDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid TypeSystemDescriptionTypePriorities parseTypePriorities(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentTypePriorities
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid TypePrioritiesTypePriorities parseTypePriorities(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsTypePriorities
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid TypePrioritiesFsIndexCollection parseFsIndexCollection(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentFsIndexCollection
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid FsIndexCollectionFsIndexCollection parseFsIndexCollection(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsFsIndexCollection
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid FsIndexCollectionResourceManagerConfiguration parseResourceManagerConfiguration(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentResourceManagerConfiguration
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid
ResourceManagerConfigurationResourceManagerConfiguration parseResourceManagerConfiguration(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsResourceManagerConfiguration
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid
ResourceManagerConfigurationFlowControllerDescription parseFlowControllerDescription(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentFlowControllerDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid FlowControllerDescriptionFlowControllerDescription parseFlowControllerDescription(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsFlowControllerDescription
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid FlowControllerDescriptionCustomResourceSpecifier parseCustomResourceSpecifier(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentCustomResourceSpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CustomResourceSpecifierCustomResourceSpecifier parseCustomResourceSpecifier(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsCustomResourceSpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid CustomResourceSpecifierPearSpecifier parsePearSpecifier(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentPearSpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid PearSpecifierPearSpecifier parsePearSpecifier(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsPearSpecifier
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid PearSpecifierIndexBuildSpecification parseIndexBuildSpecification(XMLInputSource aInput) throws InvalidXMLException
aInput
- the input source from which to read the XML documentIndexBuildSpecification
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid IndexBuildSpecificationIndexBuildSpecification parseIndexBuildSpecification(XMLInputSource aInput, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
aInput
- the input source from which to read the XML documentaOptions
- option settingsIndexBuildSpecification
object constructed from the XML documentInvalidXMLException
- if the input XML is not valid or does not specify a valid IndexBuildSpecificationXMLizable buildObject(Element aElement) throws InvalidXMLException
XMLizable.buildFromXMLElement(Element, XMLParser)
method to construct sub-objects.aElement
- a DOM ElementXMLizable
object constructed from the DOM elementInvalidXMLException
- if the XML element does not specify a valid objectXMLizable buildObject(Element aElement, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
XMLizable.buildFromXMLElement(Element, XMLParser)
method to construct sub-objects.aElement
- a DOM ElementaOptions
- option settingsXMLizable
object constructed from the DOM elementInvalidXMLException
- if the XML element does not specify a valid objectObject buildObjectOrPrimitive(Element aElement, XMLParser.ParsingOptions aOptions) throws InvalidXMLException
XMLizable.buildFromXMLElement(Element, XMLParser)
method to construct sub-objects.
This method is similar to buildObject(Element, XMLParser.ParsingOptions)
but can also
parse primitive-typed objects wrapped as XML elements, such as
<integer>42</integer
.
aElement
- a DOM ElementaOptions
- option settingsXMLizable
, String
, or one of the primitive type wrapper objects (e.g.
Integer
, Float
, Boolean
).InvalidXMLException
- if the XML element does not specify a valid objectSaxDeserializer newSaxDeserializer()
SaxDeserializer
object, which implements the SAX
ContentHandler
interface and can be used to deserialize an
XMLizable
object from the events sent from a SAX parser. This can be used if the
application already has a SAX parser that generates these events. In most cases, it is easier
to use one of the parse
methods on this interface.
The SAX deserializer returned my this method will expand XIncludes but will not do schema validation.
ContentHandler
and can be used to
deserialize an XMLizable
object from SAX events.SaxDeserializer newSaxDeserializer(XMLParser.ParsingOptions aOptions)
SaxDeserializer
.aOptions
- option settingsContentHandler
and can be used to
deserialize an XMLizable
object from SAX events.newSaxDeserializer()
void addMapping(String aElementName, String aClassName) throws ClassNotFoundException
aElementName
- the name of an XML elementaClassName
- the name of a Class of object to be built. This class must implement XMLizable
and have a zero-argument constructor.ClassNotFoundException
- if the class named by aClassName
could not be foundCopyright © 2006–2017 The Apache Software Foundation. All rights reserved.