Beispiel #1
0
  @Override
  public boolean hasAttribute(Entity entity, String attribute)
      throws EntityNotFoundException, SchemeException {

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder;
    try {
      dBuilder = dbFactory.newDocumentBuilder();
      Document doc;
      doc = dBuilder.parse(getURL().openStream());
      NodeList nodes = doc.getElementsByTagName("xs:element");
      for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        if (element.getAttribute("name").equals(entity.getName())) {
          NodeList childNodes = element.getElementsByTagName("xs:attribute");
          for (int j = 0; j < childNodes.getLength(); j++) {
            element = (Element) childNodes.item(j);
            if (element.getAttribute("name").equals(attribute)) {
              return true;
            }
          }
        }
      }
    } catch (Exception e) {
      throw new SchemeException(e);
    }

    throw new EntityNotFoundException(entity.getName());
  }
Beispiel #2
0
  @Override
  public boolean hasEntity(Entity entity) throws SchemeException {

    try {
      DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

      InputStream is = getURL().openStream();
      Document doc = dBuilder.parse(is);
      NodeList nodes = doc.getElementsByTagName("xs:element");
      for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        if (element.getAttribute("name").equals(entity.getName())) {
          return true;
        }
      }
    } catch (Exception e) {
      throw new SchemeException(e);
    }

    return false;
  }