Package org.apache.uima.util

Examples of org.apache.uima.util.XMLInputSource


   * (non-Javadoc)
   *
   * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
   */
  public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
    XMLInputSource input;

    if (!(editorInput instanceof IFileEditorInput))
      throw new PartInitException(Messages.getString("MultiPageEditor.invalidInputClass")); //$NON-NLS-1$
    fileNeedingContext = file = ((IFileEditorInput) editorInput).getFile();
    String filePathName = file.getLocation().toOSString();

    try {
      input = new XMLInputSource(filePathName);
    } catch (IOException e) {
      String m = Messages.getFormattedString("MultiPageEditor.IOError", //$NON-NLS-1$
              new String[] { AbstractSection.maybeShortenFileName(filePathName) })
              + Messages.getString("MultiPageEditor.10") + getMessagesToRootCause(e); //$NON-NLS-1$
      // skip showing a message because the partInitException
View Full Code Here


            // the act of finding the right editor calls that editors init() method
            // which could install another parse target result, which would make this
            // exception go away - so try reparsing.
                       
            try {
              parseSourceInner(new XMLInputSource(input.getURL()), filePathName, preserveComments);
            } catch (IOException e1) {
              Utility.popMessage(
                  "Internal Error",
                  "While parsing input for extension editor: " + getMessagesToRootCause(e1),
                  Utility.ERROR);
View Full Code Here

      super.setActivePage(sourceIndex);
      return false;
    }

    String filePathName = getFile().getLocation().toString();
    XMLInputSource input = new XMLInputSource(is, new File(filePathName));

    AnalysisEngineDescription oldAe = aeDescription;
    TypeSystemDescription oldTsdWithResolvedImports = mergedTypeSystemDescription;

    try {
View Full Code Here

  private void loadContext(XMLizable thing) {
    // try to load a context that has the types
    if (isContextLoaded)
      return;
    String contextFile = null;
    XMLInputSource input = null;
    aeDescription = null;
    openingContext = true;
    try {
      try {
        contextFile = fileNeedingContext.getPersistentProperty(new QualifiedName(
                AbstractSection.PLUGIN_ID, AbstractSection.IMPORTABLE_PART_CONTEXT));
      } catch (CoreException e) {
        throw new InternalErrorCDE("unexpected exception", e);
      }
      ContextForPartDialog dialog = new ContextForPartDialog(PlatformUI.getWorkbench().getDisplay()
              .getShells()[0], // ok in Eclipse 3.0
              getFile().getProject().getParent(), thing, getFile().getLocation(), this, contextFile);
      dialog.setTitle("File specifying context for editing importable part");
      if (dialog.open() == Window.CANCEL)
        throw new MultilevelCancel();

      contextFile = dialog.contextPath;

      if (null == contextFile) {
        Utility
                .popMessage(
                        "Context Info",
                        "A context is required to edit this part.  However no context was supplied.  Editing will be cancelled",
                        Utility.INFORMATION);
        throw new MultilevelCancel();
      } else {
        try {
          input = new XMLInputSource(contextFile);
        } catch (IOException e) {
          showContextLoadFailureMessage(e, contextFile);
          throw new MultilevelCancel();
        }
        if (null != input)
View Full Code Here

      if (i == (componentHeaders.length - 1))
        return null;
    }

    try {
      XMLInputSource input = new XMLInputSource(iFile.getLocation().toFile());
      XMLizable inputDescription = AbstractSection.parseDescriptor(input);
      if (inputDescription instanceof AnalysisEngineDescription
              || inputDescription instanceof CasConsumerDescription
              || inputDescription instanceof FlowControllerDescription)
        return (ResourceCreationSpecifier) inputDescription;
View Full Code Here

      // System.out.println(aggregateDescXml);

      // parse objects from XML
      InputStream is = new ByteArrayInputStream(primitiveDescXml.getBytes(encoding));
      AnalysisEngineDescription newPrimitiveDesc = (AnalysisEngineDescription) UIMAFramework
              .getXMLParser().parse(new XMLInputSource(is, null));
      is = new ByteArrayInputStream(aggregateDescXml.getBytes(encoding));
      AnalysisEngineDescription newAggregateDesc = (AnalysisEngineDescription) UIMAFramework
              .getXMLParser().parse(new XMLInputSource(is, null));

      Assert.assertEquals(primitiveDesc, newPrimitiveDesc);
      Assert.assertEquals(aggregateDesc, newAggregateDesc);

      // test a complex descriptor
      XMLInputSource in = new XMLInputSource(JUnitExtension
              .getFile("AnnotatorContextTest/AnnotatorWithGroupsAndNonGroupParams.xml"));
      AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
      OperationalProperties opProps = desc.getAnalysisEngineMetaData().getOperationalProperties();
      assertNotNull(opProps);
      assertEquals(true, opProps.getModifiesCas());
      assertEquals(true, opProps.isMultipleDeploymentAllowed());
      writer = new StringWriter();
      desc.toXML(writer);
      String descXml = writer.getBuffer().toString();
      is = new ByteArrayInputStream(descXml.getBytes(encoding));
      AnalysisEngineDescription newDesc = (AnalysisEngineDescription) UIMAFramework.getXMLParser()
              .parse(new XMLInputSource(is, null));
      Assert.assertEquals(desc, newDesc);

      // test a descriptor that includes a CasConsumer
      in = new XMLInputSource(JUnitExtension
              .getFile("TextAnalysisEngineImplTest/AggregateTaeWithCasConsumer.xml"));
      desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
      writer = new StringWriter();
      desc.toXML(writer);
      descXml = writer.getBuffer().toString();
      is = new ByteArrayInputStream(descXml.getBytes(encoding));
      newDesc = (AnalysisEngineDescription) UIMAFramework.getXMLParser().parse(
              new XMLInputSource(is, null));
      Assert.assertEquals(desc, newDesc);

    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
View Full Code Here

      JUnitExtension.handleException(e);
    }
  }
  public void testDefaultingOperationalParameters() throws Exception {
    XMLInputSource in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/TestPrimitiveOperationalParmsDefaults.xml"));
    AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    OperationalProperties opProps = desc.getAnalysisEngineMetaData().getOperationalProperties();
    assertNotNull(opProps);
    assertEquals(true, opProps.getModifiesCas());
View Full Code Here

    // circular import
    _testInvalidDescriptor(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AggregateThatImportsItself.xml"));

    // try some that should work
    XMLInputSource in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AggregateTaeWithConfigParamOverrides.xml"));
    AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();
    in = new XMLInputSource(JUnitExtension
            .getFile("AnnotatorContextTest/AnnotatorWithGroupsAndNonGroupParams.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();

    // try aggregate containing remote service - should work even if can't connect
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AggregateWithUnknownRemoteComponent.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();

    // try aggregate with sofas
    in = new XMLInputSource(JUnitExtension.getFile("CpeSofaTest/TransAnnotatorAggregate.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();

    // try another aggregate with sofas
    in = new XMLInputSource(JUnitExtension
            .getFile("CpeSofaTest/TransAnnotatorAndTestAnnotatorAggregate.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();

    // try primitive with duplicate configuration group definitions
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AnnotatorWithDuplicateConfigurationGroups.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();

    // try aggregate with duplicate configuration group definitions
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AggregateWithDuplicateGroupOverrides.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();
   
    //test aggregate with import by name and configuration parameter overrides
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AeWithConfigParamOverridesAndImportByName.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    File dataPathDir = JUnitExtension.getFile("TextAnalysisEngineImplTest/dataPathDir");
    resMgr.setDataPath(dataPathDir.getCanonicalPath());
    desc.doFullValidation(resMgr);
   
    //test UIMA C++ descriptor (should succeed even though annotator library doesn't exist)
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/TestUimaCppAe.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();
   
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/TestAggregateContainingCppAnnotator.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    desc.doFullValidation();   
  }
View Full Code Here

    desc.doFullValidation();   
  }
 
  public void testValidate() throws Exception {
    //test aggregate with import by name and configuration parameter overrides
    XMLInputSource in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AeWithConfigParamOverridesAndImportByName.xml"));
    AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    File dataPathDir = JUnitExtension.getFile("TextAnalysisEngineImplTest/dataPathDir");
    resMgr.setDataPath(dataPathDir.getCanonicalPath());
    desc.validate(resMgr);
   
    //test invalid aggregate with undefined key in flow
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/InvalidAggregate_UndefinedKeyInFlow.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    try {
      desc.validate()
      fail();
View Full Code Here

      "org/apache/uima/analysis_engine/impl/documentAnnotationRedefinitionTS.xml";
    File file = JUnitExtension.getFile(tsDescriptor);
    XMLParser parser = UIMAFramework.getXMLParser();
    boolean resourceInitExc = false;
    try {
      TypeSystemDescription tsd = (TypeSystemDescription) parser.parse(new XMLInputSource(file));
      CasCreationUtils.createCas(tsd, null, new FsIndexDescription[0]);
    } catch (InvalidXMLException e) {
      e.printStackTrace();
      assertTrue(false);
    } catch (IOException e) {
View Full Code Here

TOP

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

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.