Package org.apache.uima.util

Examples of org.apache.uima.util.InvalidXMLException


      // invalid - both location and name
      importXml = "<import name=\"this.is.a.test\" location=\"foo/bar/MyFile.xml\"/>";
      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes(encoding)));
      importObj = new Import_impl();
      InvalidXMLException ex = null;
      try {
        importObj.buildFromXMLElement(importDoc.getDocumentElement(), null);
      } catch (InvalidXMLException e) {
        ex = e;
      }
      assertNotNull(ex);

      // invalid - empty import
      importXml = "<import/>";
      importDoc = docBuilder.parse(new ByteArrayInputStream(importXml.getBytes(encoding)));
      importObj = new Import_impl();
      ex = null;
      try {
        importObj.buildFromXMLElement(importDoc.getDocumentElement(), null);
      } catch (InvalidXMLException e) {
        ex = e;
      }
      assertNotNull(ex);
      assertNotNull(ex.getMessage());

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


      assertEquals(expectedUrl, absUrl);

      // name not found
      importObj = new Import_impl();
      importObj.setName("this.should.not.be.found.at.least.i.hope.not");
      InvalidXMLException ex = null;
      try {
        importObj.findAbsoluteUrl(UIMAFramework.newDefaultResourceManager());
      } catch (InvalidXMLException e) {
        ex = e;
      }
      assertNotNull(ex);
      assertNotNull(ex.getMessage());
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

   */
  public void buildFromXMLElement(Element aElement, XMLParser aParser,
          XMLParser.ParsingOptions aOptions) throws InvalidXMLException {
    // check element type
    if (!aElement.getTagName().equals(getXmlizationInfo().elementTagName))
      throw new InvalidXMLException(InvalidXMLException.INVALID_ELEMENT_TYPE, new Object[] {
          getXmlizationInfo().elementTagName, aElement.getTagName() });

    if (aOptions.preserveComments) {
      infoset = aElement;
    }
View Full Code Here

            Constructor constructor = propClass.getConstructor(new Class[] { String.class });
            // construct the object
            Object val = constructor.newInstance(new Object[] { text });
            setAttributeValue(propName, val);
          } catch (Exception e) {
            throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT,
                    new Object[] { aElement.getTagName() }, e);
          }
        }
      }
    }
View Full Code Here

              }
              // construct the object and add to list
              valueList.add(primitiveElementStringConstructor
                      .newInstance(new Object[] { elemText }));
            } catch (Exception e) {
              throw new InvalidXMLException(e);
            }
          } else
            // element type does not match
            throw new InvalidXMLException(InvalidXMLException.INVALID_ELEMENT_TYPE, new Object[] {
                aPropXmlInfo.arrayElementTagName, curElem.getTagName() });
        } else {
          // array element type is not specified, try defaults
          valueList.add(aParser.buildObjectOrPrimitive(curElem, aOptions));
        }
      }
    }

    // initialize an appropriate array of the same length as the valueList,
    // and copy the values
    Class componentType = Object.class;
    if (!(aPropClass == Object.class)) {
      componentType = aPropClass.getComponentType();
      // verify that objects are of appropriate type
      Iterator i = valueList.iterator();
      while (i.hasNext()) {
        Object curObj = i.next();
        if (!componentType.isAssignableFrom(curObj.getClass())) {
          throw new InvalidXMLException(InvalidXMLException.INVALID_CLASS, new Object[] {
              componentType, curObj.getClass() });
        }
      }
    } else {
      // attribute class is generic object, so we don't know what type of
View Full Code Here

      }
    } catch (Exception e) {
      if (e instanceof InvalidXMLException) {
        throw (InvalidXMLException) e;
      } else {
        throw new InvalidXMLException(e);
      }
    }

    // throw exception if we did not succeed
    if (!success) {
      throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT, new Object[] { aElement
              .getTagName() });
    }
  }
View Full Code Here

      Node curNode = childNodes.item(i);
      if (curNode instanceof Element) {
        Element curElem = (Element) curNode;
        // check element tag name
        if (!curElem.getTagName().equals(aValueTagName)) {
          throw new InvalidXMLException(InvalidXMLException.INVALID_ELEMENT_TYPE, new Object[] {
              aValueTagName, curElem.getTagName() });
        }
        // get the key attribute
        String key = curElem.getAttribute(aKeyXmlAttribute);
        if (key.equals("")) {
          throw new InvalidXMLException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING,
                  new Object[] { "key", aValueTagName });
        }
        // build value object
        Object val = null;
        if (!aValueIsArray) {
          Element valElem = XMLUtils.getFirstChildElement(curElem);
          if (valElem == null) {
            throw new InvalidXMLException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
                "(any)", aValueTagName });
          }
          val = aParser.buildObject(valElem, aOptions);
        } else // array
        {
View Full Code Here

        URL url = aeImport.findAbsoluteUrl(aResourceManager);

        // check for resursive import
        if (aEnclosingAggregateAeUrls.contains(url.toString())) {
          String name = getMetaData() == null ? "<null>" : getMetaData().getName();
          throw new InvalidXMLException(InvalidXMLException.CIRCULAR_AE_IMPORT, new Object[] {
              name, url });
        }

        // parse import target
        XMLInputSource input;
        try {
          input = new XMLInputSource(url);
        } catch (IOException e) {
          throw new InvalidXMLException(InvalidXMLException.IMPORT_FAILED_COULD_NOT_READ_FROM_URL,
                  new Object[] { url, aeImport.getSourceUrlString() }, e);
        }
        ResourceSpecifier spec = UIMAFramework.getXMLParser().parseResourceSpecifier(input);

        // update entry in derived mDelegateAnalysisEngineSpecifiers map.
View Full Code Here

          XMLParser.ParsingOptions aOptions) throws InvalidXMLException {
    super.buildFromXMLElement(aElement, aParser, aOptions);
    try {
      validateConfigurationParameterSettings();
    } catch (ResourceConfigurationException e) {
      throw new InvalidXMLException(e);
    }
  }
View Full Code Here

        ((MetaDataObject_impl) result).setSourceUrl(urlToParse);
      }
      return result;
    } catch (Exception e) {
      String sourceFile = urlToParse != null ? urlToParse.toString() : "<unknown source>";
      throw new InvalidXMLException(InvalidXMLException.INVALID_DESCRIPTOR_FILE,
              new Object[] { sourceFile }, e);
    }
  }
View Full Code Here

TOP

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

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.