Package org.apache.uima.util

Examples of org.apache.uima.util.XMLParser


    String xmlDescUri = (xmlDescFile != null) ? xmlDescFile.getAbsolutePath() : xmlDescUrl.toString();
    try {
      // clean error message
      __errTableByUri.remove(xmlDescUri);
      // get XMLParser
      XMLParser xmlParser = UIMAFramework.getXMLParser();
      // create XML source
      xmlSource = (xmlDescFile != null) ? new XMLInputSource(xmlDescFile) : new XMLInputSource(
              xmlDescUrl);
      // parse XML source and create resource specifier
      ResourceSpecifier resourceSpec = null;
      try {
        resourceSpec = xmlParser.parseResourceSpecifier(xmlSource);
      } catch (UIMAException err) {
        __errTableByUri.put( xmlDescUri, err );
      } catch (UIMARuntimeException exc) {
        __errTableByUri.put( xmlDescUri, exc );
      }
      if (resourceSpec != null) { // AE | CR | CI | CC ?
        // identify UIMA resource category
        if (resourceSpec instanceof AnalysisEngineDescription) {
          uimaCompCtg = ANALYSIS_ENGINE_CTG;
        } else if (resourceSpec instanceof CollectionReaderDescription) {
          uimaCompCtg = COLLECTION_READER_CTG;
        } else if (resourceSpec instanceof CasInitializerDescription) {
          uimaCompCtg = CAS_INITIALIZER_CTG;
        } else if (resourceSpec instanceof CasConsumerDescription) {
          uimaCompCtg = CAS_CONSUMER_CTG;
        }
      }
      if (uimaCompCtg == null) { // CPE ?
        // refresh XML source object
        try {
          xmlSource.getInputStream().close();
        } catch (Exception e) {
        }
        xmlSource = (xmlDescFile != null) ? new XMLInputSource(xmlDescFile) : new XMLInputSource(xmlDescUrl);
        try {
          // try parsing CPE configuration
          xmlParser.parseCpeDescription(xmlSource);
          uimaCompCtg = CPE_CONFIGURATION_CTG;
          __errTableByUri.remove( xmlDescUri );
        } catch (UIMAException err) {
          __errTableByUri.put( xmlDescUri, err );
        } catch (UIMARuntimeException exc) {
          __errTableByUri.put( xmlDescUri, exc );
        }
      }
      if (uimaCompCtg == null) { // TS ?
        // refresh XML source object
        try {
          xmlSource.getInputStream().close();
        } catch (Exception e) {
        }
        xmlSource = (xmlDescFile != null) ? new XMLInputSource(xmlDescFile) : new XMLInputSource(xmlDescUrl);
        try {
          // try parsing TS description
          xmlParser.parseTypeSystemDescription(xmlSource);
          uimaCompCtg = TYPE_SYSTEM_CTG;
          __errTableByUri.remove( xmlDescUri );
        } catch (UIMAException err) {
          __errTableByUri.put( xmlDescUri, err );
        } catch (UIMARuntimeException exc) {
          __errTableByUri.put( xmlDescUri, exc );
        }
      }
      if (uimaCompCtg == null) { // RR ?
        // refresh XML source object
        try {
          xmlSource.getInputStream().close();
        } catch (Exception e) {
        }
        xmlSource = (xmlDescFile != null) ? new XMLInputSource(xmlDescFile) : new XMLInputSource(xmlDescUrl);
        try {
          // try parsing RES manager configuration
          xmlParser.parseResourceManagerConfiguration(xmlSource);
          uimaCompCtg = REUSABLE_RESOURCE_CTG;
          __errTableByUri.remove( xmlDescUri );
        } catch (UIMAException err) {
          __errTableByUri.put( xmlDescUri, err );
        } catch (UIMARuntimeException exc) {
View Full Code Here


  }

  public static XMLizable parseDescriptor(XMLInputSource input) throws InvalidXMLException {
    // turn off environment variable expansion
    XMLParser.ParsingOptions parsingOptions = new XMLParser.ParsingOptions(false);
    XMLParser parser = UIMAFramework.getXMLParser();
    // disabled - error messages from XML validation not very helpful
    // parser.enableSchemaValidation(true);
    return parser.parse(input, "http://uima.apache.org/resourceSpecifier",
            urlForResourceSpecifierSchema, parsingOptions);
  }
View Full Code Here

import java.io.IOException;

public class ConvertXMIAssertionsToi2b2Format {

  private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException {
    XMLParser xmlParser = UIMAFramework.getXMLParser();
    AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor));
    return CasCreationUtils.createCas(tsDesc);
  }
View Full Code Here

*/

public class Converti2b2AnnotationsToCTAKES {
 
  private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException {
    XMLParser xmlParser = UIMAFramework.getXMLParser();
    AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor));
    return CasCreationUtils.createCas(tsDesc);
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.util.XMLParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.