Esempio n. 1
0
  private void tidyUnicode(String filename) {
    FileInputStream in = null;
    FileOutputStream out = null;
    InputStreamReader reader = null;
    OutputStreamWriter writer = null;
    File f0 = new File(filename + "0");
    File f1 = new File(filename);
    f1.renameTo(f0);
    try {
      in = new FileInputStream(f0);
      reader = new InputStreamReader(in);
      out = new FileOutputStream(f1);
      writer = new OutputStreamWriter(out);
      UTF8Tidy u = new UTF8Tidy(reader, writer);
      u.execute();
    } catch (Exception e) {
      {
      } // System.out.println("e: " + e ); }

    } finally {
      try {
        reader.close();
        writer.close();
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      f0.delete();
    }
  }
Esempio n. 2
0
  /** Writes the data provenance into xml formatted file */
  public void writeXML() throws IOException {
    FileWriter fw;
    if (file.exists() == true) {
      file.delete();
      file = new File(fileDir + File.separator + fileName);
    }

    try {

      fw = new FileWriter(file);
      bw = new BufferedWriter(fw);

      Vector<XMLAttributes> atVector = new Vector<XMLAttributes>();

      bw.write(XML_HEADER);
      bw.newLine();
      bw.write(DATA_PROVENANCE);
      bw.newLine();

      openTag("provenance", true);

      int numEntries = pHolder.size();

      ProvenanceEntry entry;

      for (int i = 0; i < numEntries; i++) {
        entry = pHolder.elementAt(i);

        openTag("processStep", true);

        atVector.add(new XMLAttributes("version", entry.getMipavVersion()));
        this.closedTag("program", entry.getProgramName(), atVector);

        atVector.add(new XMLAttributes("inputs", entry.getProgramInputs()));
        closedTag("programArguments", entry.getAction(), atVector);

        closedTag("timeStamp", entry.getTimeStamp());

        closedTag("user", entry.getUser());

        closedTag("hostName", entry.getHostName());

        closedTag("architecture", entry.getArchitecture());

        atVector.add(new XMLAttributes("version", entry.getPlatformVersion()));
        closedTag("platform", entry.getPlatform(), atVector);

        atVector.add(new XMLAttributes("version", entry.getJavaVersion()));
        closedTag("compiler", "java", atVector);

        openTag("processStep", false);
      }

      openTag("provenance", false);
      bw.close();
    } catch (Exception e) {
      System.err.println("CAUGHT EXCEPTION WITHIN writeXML() of FileDataProvenance");
      e.printStackTrace();
    }
  }
Esempio n. 3
0
  private void updateRecord(DataRecord r, ArrayList<String> fieldsInInport) {
    try {
      DataRecord rorig =
          (versionized ? dataAccess.getValidAt(r.getKey(), validAt) : dataAccess.get(r.getKey()));
      if (rorig == null) {
        logImportFailed(
            r, International.getString("Keine gültige Version des Datensatzes gefunden."), null);
        return;
      }

      // has the import record an InvalidFrom field?
      long invalidFrom = (versionized ? getInvalidFrom(r) : -1);
      if (invalidFrom <= rorig.getValidFrom()) {
        invalidFrom = -1;
      }
      boolean changed = false;

      for (int i = 0; i < fields.length; i++) {
        Object o = r.get(fields[i]);
        if ((o != null || fieldsInInport.contains(fields[i]))
            && !r.isKeyField(fields[i])
            && !fields[i].equals(DataRecord.LASTMODIFIED)
            && !fields[i].equals(DataRecord.VALIDFROM)
            && !fields[i].equals(DataRecord.INVALIDFROM)
            && !fields[i].equals(DataRecord.INVISIBLE)
            && !fields[i].equals(DataRecord.DELETED)) {
          Object obefore = rorig.get(fields[i]);
          rorig.set(fields[i], o);
          if ((o != null && !o.equals(obefore)) || (o == null && obefore != null)) {
            changed = true;
          }
        }
      }

      if (invalidFrom <= 0) {
        long myValidAt = getValidFrom(r);
        if (!versionized
            || updMode.equals(UPDMODE_UPDATEVALIDVERSION)
            || rorig.getValidFrom() == myValidAt) {
          if (changed) {
            dataAccess.update(rorig);
          }
          setCurrentWorkDone(++importCount);
        }
        if (versionized
            && updMode.equals(UPPMODE_CREATENEWVERSION)
            && rorig.getValidFrom() != myValidAt) {
          if (changed) {
            dataAccess.addValidAt(rorig, myValidAt);
          }
          setCurrentWorkDone(++importCount);
        }
      } else {
        dataAccess.changeValidity(rorig, rorig.getValidFrom(), invalidFrom);
        setCurrentWorkDone(++importCount);
      }
    } catch (Exception e) {
      logImportFailed(r, e.toString(), e);
    }
  }
  private void validateDTD() throws InvalidWorkflowDescriptorException {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);

    StringWriter sw = new StringWriter();
    PrintWriter writer = new PrintWriter(sw);
    writer.println(XML_HEADER);
    writer.println(DOCTYPE_DECL);
    writeXML(writer, 0);

    WorkflowLoader.AllExceptionsErrorHandler errorHandler =
        new WorkflowLoader.AllExceptionsErrorHandler();

    try {
      DocumentBuilder db = dbf.newDocumentBuilder();
      db.setEntityResolver(new DTDEntityResolver());

      db.setErrorHandler(errorHandler);
      db.parse(new InputSource(new StringReader(sw.toString())));

      if (errorHandler.getExceptions().size() > 0) {
        throw new InvalidWorkflowDescriptorException(errorHandler.getExceptions().toString());
      }
    } catch (InvalidWorkflowDescriptorException e) {
      throw e;
    } catch (Exception e) {
      throw new InvalidWorkflowDescriptorException(e.toString());
    }
  }
Esempio n. 5
0
  private static SAXParserFactory createFastSAXParserFactory()
      throws ParserConfigurationException, SAXException {
    if (fastParserFactoryClass == null) {
      try {
        fastParserFactoryClass =
            Class.forName("org.apache.crimson.jaxp.SAXParserFactoryImpl"); // NOI18N
      } catch (Exception ex) {
        useFastSAXParserFactory = false;
        if (System.getProperty("java.version").startsWith("1.4")) { // NOI18N
          ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
        }
      }
    }
    if (fastParserFactoryClass != null) {
      try {
        SAXParserFactory factory = (SAXParserFactory) fastParserFactoryClass.newInstance();

        return factory;
      } catch (Exception ex) {
        useFastSAXParserFactory = false;
        throw new ParserConfigurationException(ex.getMessage());
      }
    }

    return SAXParserFactory.newInstance();
  }
Esempio n. 6
0
 /**
  * This creates an empty <code>Document</code> object based on a specific parser implementation.
  *
  * @return <code>Document</code> - created DOM Document.
  * @throws JDOMException when errors occur.
  */
 public Document createDocument() throws JDOMException {
   try {
     return (Document) Class.forName("org.apache.xerces.dom.DocumentImpl").newInstance();
   } catch (Exception e) {
     throw new JDOMException(
         e.getClass().getName() + ": " + e.getMessage() + " when creating document", e);
   }
 }
 public void parseCPIMString(String body) {
   try {
     StringReader stringReader = new StringReader(body);
     InputSource inputSource = new InputSource(stringReader);
     saxParser.parse(inputSource);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 8
0
 public static void main(String[] pArgs) {
   try {
     AppConfig appConfig = new AppConfig(new File(pArgs[0]));
     System.out.println("version: " + appConfig.getAppVersion());
     System.out.println("appname: " + appConfig.getAppName());
   } catch (Exception e) {
     e.printStackTrace(System.err);
   }
 }
 public TrackDatabase(InputStream is) throws IOException {
   try {
     createDOM();
     load(is);
   } catch (Exception e) {
     e.printStackTrace();
     if (!(e instanceof IOException)) throw new IOException(e.toString());
     create();
   }
 }
Esempio n. 10
0
 /**
  * Creates an AppConfig using class <code>pAppClass</code> to search for the config file resource.
  * That class must have a resource file <code>AppConfig.xml</code>.
  */
 private AppConfig(InputSource pInputSource) throws InvalidInputException, DataNotFoundException {
   try {
     DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
     Document document = builder.parse(pInputSource);
     mConfigFileDocument = document;
   } catch (Exception e) {
     e.printStackTrace(System.err);
     throw new InvalidInputException("unable to load XML configuration file", e);
   }
 }
Esempio n. 11
0
 public void endElement(String namespaceURI, String localName, String qName)
     throws ParserException {
   {
   } // System.out.println("end Element");
   Caller targeting = (Caller) stack.pop();
   try {
     targeting.process();
   } catch (Exception e) {
     throw new ParserException("Could not place " + qName + " into system!\n" + e.getMessage());
   }
 }
  /**
   * start the parsing
   *
   * @param file to parse
   * @return Vector containing the test cases
   */
  public XMLcpimParser() {
    try {
      SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
      saxParser = saxParserFactory.newSAXParser().getXMLReader();
      saxParser.setContentHandler(this);
      saxParser.setFeature("http://xml.org/sax/features/validation", true);
      // parse the xml specification for the event tags.

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 13
0
     /**
     * Creates Java Source code (Object model) for the given XML Schema
     * @param InputSource - the InputSource representing the XML schema.
     * @param packageName the package for the generated source files
    **/
    public void generateSource(InputSource source, String packageName) {

        //-- get default parser from Configuration
        Parser parser = null;
        try {
	    parser = Configuration.getParser();
        }
        catch(RuntimeException rte) {}
        if (parser == null) {
            System.out.println("fatal error: unable to create SAX parser.");
            return;
        }

        SchemaUnmarshaller schemaUnmarshaller = null;
        try {
           schemaUnmarshaller = new SchemaUnmarshaller();
        } catch (SAXException e) {
          // can never happen since a SAXException is thrown
          // when we are dealing with an included schema
          e.printStackTrace();
        }

        parser.setDocumentHandler(schemaUnmarshaller);
        parser.setErrorHandler(schemaUnmarshaller);

        try {
            parser.parse(source);
        }
        catch(java.io.IOException ioe) {
            System.out.println("error reading XML Schema file");
            return;
        }
        catch(org.xml.sax.SAXException sx) {

            Exception except = sx.getException();
            if (except == null) except = sx;

            if (except instanceof SAXParseException) {
                SAXParseException spe = (SAXParseException)except;
                System.out.println("SAXParseException: " + spe);
                System.out.print(" - occured at line ");
                System.out.print(spe.getLineNumber());
                System.out.print(", column ");
                System.out.println(spe.getColumnNumber());
            }
            else except.printStackTrace();
            return;
        }

        Schema schema = schemaUnmarshaller.getSchema();
        generateSource(schema, packageName);

    } //-- generateSource
Esempio n. 14
0
  /**
   * This creates a new <code>{@link Document}</code> from an existing <code>InputStream</code> by
   * letting a DOM parser handle parsing using the supplied stream.
   *
   * @param in <code>InputStream</code> to parse.
   * @param validate <code>boolean</code> to indicate if validation should occur.
   * @return <code>Document</code> - instance ready for use.
   * @throws IOException when I/O error occurs.
   * @throws JDOMException when errors occur in parsing.
   */
  public Document getDocument(InputStream in, boolean validate) throws IOException, JDOMException {

    try {
      // Load the parser class
      Class parserClass = Class.forName("org.apache.xerces.parsers.DOMParser");
      Object parser = parserClass.newInstance();

      // Set validation
      Method setFeature =
          parserClass.getMethod("setFeature", new Class[] {java.lang.String.class, boolean.class});
      setFeature.invoke(
          parser, new Object[] {"http://xml.org/sax/features/validation", new Boolean(validate)});

      // Set namespaces true
      setFeature.invoke(
          parser, new Object[] {"http://xml.org/sax/features/namespaces", new Boolean(true)});

      // Set the error handler
      if (validate) {
        Method setErrorHandler =
            parserClass.getMethod("setErrorHandler", new Class[] {ErrorHandler.class});
        setErrorHandler.invoke(parser, new Object[] {new BuilderErrorHandler()});
      }

      // Parse the document
      Method parse = parserClass.getMethod("parse", new Class[] {org.xml.sax.InputSource.class});
      parse.invoke(parser, new Object[] {new InputSource(in)});

      // Get the Document object
      Method getDocument = parserClass.getMethod("getDocument", null);
      Document doc = (Document) getDocument.invoke(parser, null);

      return doc;
    } catch (InvocationTargetException e) {
      Throwable targetException = e.getTargetException();
      if (targetException instanceof org.xml.sax.SAXParseException) {
        SAXParseException parseException = (SAXParseException) targetException;
        throw new JDOMException(
            "Error on line "
                + parseException.getLineNumber()
                + " of XML document: "
                + parseException.getMessage(),
            e);
      } else if (targetException instanceof IOException) {
        IOException ioException = (IOException) targetException;
        throw ioException;
      } else {
        throw new JDOMException(targetException.getMessage(), e);
      }
    } catch (Exception e) {
      throw new JDOMException(e.getClass().getName() + ": " + e.getMessage(), e);
    }
  }
 private void create() {
   try {
     tracks = new Vector();
     hash = new Hashtable();
     createDOM();
     doc = db.newDocument();
     docElt = doc.createElement(docElementName);
     doc.appendChild(docElt);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public void parse() {
   try {
     // Create SAX Parser factory
     SAXParserFactory spfactory = SAXParserFactory.newInstance();
     // Create SAX Parser
     SAXParser parser = spfactory.newSAXParser();
     // Process XML file by given default handler
     parser.parse(new ByteArrayInputStream(data.getBytes()), new XMLParseContent(result, data));
     // parser.parse(new File("tmp.xml"), new XMLParseRevId(userName,result,data));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 17
0
  @Override
  public VPackage parse() {

    logger.debug("Starting parsing package: " + xmlFile.getAbsolutePath());

    long startParsing = System.currentTimeMillis();

    try {
      Document document = getDocument();
      Element root = document.getDocumentElement();

      _package = new VPackage(xmlFile);

      Node name = root.getElementsByTagName(EL_NAME).item(0);
      _package.setName(name.getTextContent());
      Node descr = root.getElementsByTagName(EL_DESCRIPTION).item(0);
      _package.setDescription(descr.getTextContent());

      NodeList list = root.getElementsByTagName(EL_CLASS);

      boolean initPainters = false;
      for (int i = 0; i < list.getLength(); i++) {
        PackageClass pc = parseClass((Element) list.item(i));
        if (pc.getPainterName() != null) {
          initPainters = true;
        }
      }

      if (initPainters) {
        _package.initPainters();
      }

      logger.info(
          "Parsing the package '{}' finished in {}ms.\n",
          _package.getName(),
          (System.currentTimeMillis() - startParsing));
    } catch (Exception e) {
      collector.collectDiagnostic(e.getMessage(), true);
      if (RuntimeProperties.isLogDebugEnabled()) {
        e.printStackTrace();
      }
    }

    try {
      checkProblems("Error parsing package file " + xmlFile.getName());
    } catch (Exception e) {
      return null;
    }

    return _package;
  }
Esempio n. 18
0
 private void addRecord(DataRecord r) {
   try {
     if (versionized) {
       long myValidAt = getValidFrom(r);
       dataAccess.addValidAt(r, myValidAt);
       setCurrentWorkDone(++importCount);
     } else {
       dataAccess.add(r);
       setCurrentWorkDone(++importCount);
     }
   } catch (Exception e) {
     logImportFailed(r, e.toString(), e);
   }
 }
  public static void runScript(Script script, int scriptType) {
    if (scriptType == SHUTDOWN_SCRIPT) {
      try {
        script.process();
      } catch (Exception e) {
        System.out.println(e.getMessage());
      }
    } else {
      // Create a new Thread
      ScriptThread scriptThread = new ScriptThread(script, scriptType);

      // Run the Thread
      scriptThread.start();
    }
  }
  /**
   * Main entry point. Expects two arguments: the schema document, and the source document.
   *
   * @param args
   */
  public static void main(String[] args) {
    try {
      if (args.length != 2) {
        printUsage();
        return;
      }

      SchemaFactory schemaFactory;

      // Set a system property to force selection of the Saxon SchemaFactory implementation

      System.setProperty(
          "javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema",
          "com.saxonica.schema.SchemaFactoryImpl");

      schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

      schemaFactory.setErrorHandler(new LocalErrorHandler());
      // create a grammar object.
      Schema schemaGrammar = schemaFactory.newSchema(new File(args[0]));

      System.err.println("Created Grammar object for schema : " + args[0]);

      Resolver resolver = new Resolver();

      // create a validator to validate against the schema.
      ValidatorHandler schemaValidator = schemaGrammar.newValidatorHandler();
      schemaValidator.setResourceResolver(resolver);
      schemaValidator.setErrorHandler(new LocalErrorHandler());
      schemaValidator.setContentHandler(
          new LocalContentHandler(schemaValidator.getTypeInfoProvider()));

      System.err.println("Validating " + args[1] + " against grammar " + args[0]);
      SAXParserFactory parserFactory = SAXParserFactory.newInstance();
      parserFactory.setNamespaceAware(true);
      SAXParser parser = parserFactory.newSAXParser();
      XMLReader reader = parser.getXMLReader();
      reader.setContentHandler(schemaValidator);
      reader.parse(new InputSource(new File(args[1]).toURI().toString()));

      System.err.println("Validation successful");
    } catch (SAXException saxe) {
      exit(1, "Error: " + saxe.getMessage());
    } catch (Exception e) {
      e.printStackTrace();
      exit(2, "Fatal Error: " + e);
    }
  }
Esempio n. 21
0
    public void endElement(String uri, String localName, String qname) {
      super.endElement(uri, localName, qname);

      if (record != null && localName.equals(DataRecord.ENCODING_RECORD)) {
        // end of record
        if (dataImport.importRecord(record, fieldsInImport)) {
          count++;
        }
        record = null;
        fieldsInImport = null;
      }
      String fieldValue = getFieldValue();
      if (record != null && fieldValue != null) {
        // end of field
        try {
          if (textImport) {
            if (!record.setFromText(fieldName, fieldValue.trim())) {
              dataImport.logImportWarning(
                  record,
                  "Value '"
                      + fieldValue
                      + "' for Field '"
                      + fieldName
                      + "' corrected to '"
                      + record.getAsText(fieldName)
                      + "'");
            }
          } else {
            record.set(fieldName, fieldValue.trim());
          }
          String[] equivFields = record.getEquivalentFields(fieldName);
          for (String f : equivFields) {
            fieldsInImport.add(f);
          }
        } catch (Exception esetvalue) {
          dataImport.logImportWarning(
              record,
              "Cannot set value '"
                  + fieldValue
                  + "' for Field '"
                  + fieldName
                  + "': "
                  + esetvalue.toString());
        }
      }
    }
Esempio n. 22
0
 public int runXmlImport() {
   DataImportXmlParser responseHandler = null;
   try {
     XMLReader parser = EfaUtil.getXMLReader();
     responseHandler = new DataImportXmlParser(this, dataAccess);
     parser.setContentHandler(responseHandler);
     parser.parse(new InputSource(new FileInputStream(filename)));
   } catch (Exception e) {
     logInfo(e.toString());
     errorCount++;
     Logger.log(e);
     if (Daten.isGuiAppl()) {
       Dialog.error(e.toString());
     }
   }
   return (responseHandler != null ? responseHandler.getImportedRecordsCount() : 0);
 }
 private int countResults(InputStream s) throws SocketTimeoutException {
   ResultHandler handler = new ResultHandler();
   int count = 0;
   try {
     SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
     //		  ByteArrayInputStream bis = new ByteArrayInputStream(s.getBytes("UTF-8"));
     saxParser.parse(s, handler);
     count = handler.getCount();
   } catch (SocketTimeoutException e) {
     throw new SocketTimeoutException();
   } catch (Exception e) {
     System.err.println("SAX Error");
     e.printStackTrace();
     return -1;
   }
   return count;
 }
Esempio n. 24
0
  /**
   * EPML2PNML
   *
   * @param args String[]
   */
  private static void EPML2PNML(String[] args) {
    if (args.length != 2) {
      System.out.println("���ṩEPML�ļ�·����PNML���Ŀ¼!");
      System.exit(-1);
    }
    epmlImport epml = new epmlImport();
    // load the single epml file
    String filename = args[0];
    try {
      EPCResult epcRes = (EPCResult) epml.importFile(new FileInputStream(filename));
      // convert all epc models to pnml files
      ArrayList<ConfigurableEPC> alEPCs = epcRes.getAllEPCs();
      PnmlExport export = new PnmlExport();
      for (ConfigurableEPC epc : alEPCs) {
        String id = epc.getIdentifier();
        if (id.equals("1An_klol")
            || id.equals("1An_l1y8")
            || id.equals("1Ex_dzq9")
            || id.equals("1Ex_e6dx")
            || id.equals("1Ku_9soy")
            || id.equals("1Ku_a4cg")
            || id.equals("1Or_lojl")
            || id.equals("1Pr_d1ur")
            || id.equals("1Pr_djki")
            || id.equals("1Pr_dkfa")
            || id.equals("1Pr_dl73")
            || id.equals("1Ve_musj")
            || id.equals("1Ve_mvwz")) continue;
        // save pnml files to the same folder
        File outFile = new File(args[1] + "/" + id + ".pnml");
        if (outFile.exists()) continue;
        FileOutputStream fos = new FileOutputStream(outFile);
        PetriNet petri = AMLtoPNML.convert(epc);
        try {
          export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos);
        } catch (Exception ex1) {
          ex1.printStackTrace(System.out);
        }
      }
    } catch (IOException ex) {
      ex.printStackTrace(System.out);
    }

    System.out.println("EPML Conversion Done");
  }
Esempio n. 25
0
  public static void main(String[] argv) {
    try {
      // SAXパーサーファクトリを生成
      SAXParserFactory spfactory = SAXParserFactory.newInstance();

      // SAXパーサーを生成
      SAXParser parser = spfactory.newSAXParser();

      // XMLファイルを指定されたデフォルトハンドラーで処理します
      String fileName = "dos2unix.mm";

      //      parser.parse(new File("helloworld.xml"), new HelloWorldSax());
      parser.parse(new File(fileName), new HelloWorldSax());

    } catch (Exception e) {

      e.printStackTrace();
    }
  }
Esempio n. 26
0
 private File getWorkingDirectory(File f) {
   try {
     File workingDir =
         new File(
             Properties.get(Names.WORKING_DIR)
                 + Names.PATH_SEPARATOR
                 + getOpType()
                 + Names.PATH_SEPARATOR
                 + "work"
                 + getNewCount());
     if (!workingDir.exists()) workingDir.mkdirs();
     FileUtil.deleteContents(workingDir);
     return workingDir;
   } catch (Exception ignore) {
     // ++ notify of error - maybe out of disk space
     ignore.printStackTrace();
     return null;
   }
 }
Esempio n. 27
0
  public void execute() {
    try {
      execExtractor();
      tidyUnicode(outputFile); // eliminate invalid unicode Chars

      XMLReader xr = new SAXParser();
      // todo: parameterize the handler
      DrawingHandler handler = new DrawingHandler();
      handler.setGeneratePDFs(getGeneratePDFs());
      xr.setContentHandler(handler);
      xr.setErrorHandler(handler);
      File xml = new File(outputFile);
      FileReader r = new FileReader(xml);
      xr.parse(new InputSource(r));
      results = handler.getResults();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 28
0
  /** used for cut and paste. */
  public void addObjectFromClipboard(String a_value) throws CircularIncludeException {
    Reader reader = new StringReader(a_value);
    Document document = null;
    try {
      document = UJAXP.getDocument(reader);
    } catch (Exception e) {
      e.printStackTrace();
      return;
    } // try-catch

    Element root = document.getDocumentElement();
    if (!root.getNodeName().equals("clipboard")) {
      return;
    } // if

    Node child;
    for (child = root.getFirstChild(); child != null; child = child.getNextSibling()) {
      if (!(child instanceof Element)) {
        continue;
      } // if
      Element element = (Element) child;

      IGlyphFactory factory = GlyphFactory.getFactory();

      if (XModule.isMatch(element)) {
        EModuleInvoke module = (EModuleInvoke) factory.createXModule(element);
        addModule(module);
        continue;
      } // if

      if (XContour.isMatch(element)) {
        EContour contour = (EContour) factory.createXContour(element);
        addContour(contour);
        continue;
      } // if

      if (XInclude.isMatch(element)) {
        EIncludeInvoke include = (EIncludeInvoke) factory.createXInclude(element);
        addInclude(include);
        continue;
      } // if
    } // while
  }
 public void startElement(
     String namespaceURI,
     String lName, // local name
     String qName, // qualified name
     Attributes attrs)
     throws SAXException {
   element = qName;
   if (element.compareToIgnoreCase("presence") == 0) {
     presenceTag = new PresenceTag();
     String entity = attrs.getValue("entity").trim();
     presenceTag.setEntity(entity);
   }
   if (element.compareToIgnoreCase("presentity") == 0) {
     presentityTag = new PresentityTag();
     String id = attrs.getValue("id").trim();
     presentityTag.setId(id);
   }
   if (element.compareToIgnoreCase("tuple") == 0) {
     tupleTag = new TupleTag();
     String id = attrs.getValue("id").trim();
     tupleTag.setId(id);
   }
   if (element.compareToIgnoreCase("status") == 0) {
     statusTag = new StatusTag();
   }
   if (element.compareToIgnoreCase("basic") == 0) {
     basicTag = new BasicTag();
   }
   if (element.compareToIgnoreCase("contact") == 0) {
     contactTag = new ContactTag();
     String priority = attrs.getValue("priority").trim();
     if (priority != null) {
       try {
         contactTag.setPriority(Float.parseFloat(priority));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   if (element.compareToIgnoreCase("note") == 0) {
     noteTag = new NoteTag();
   }
 }
  /**
   * start the parsing
   *
   * @param file to parse
   * @return Vector containing the test cases
   */
  public XMLcpimParser(String fileLocation) {
    try {
      SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
      saxParser = saxParserFactory.newSAXParser().getXMLReader();
      saxParser.setContentHandler(this);
      saxParser.setFeature("http://xml.org/sax/features/validation", true);
      // parse the xml specification for the event tags.
      saxParser.parse(fileLocation);

    } catch (SAXParseException spe) {
      spe.printStackTrace();
    } catch (SAXException sxe) {
      sxe.printStackTrace();
    } catch (IOException ioe) {
      // I/O error
      ioe.printStackTrace();
    } catch (Exception pce) {
      // Parser with specified options can't be built
      pce.printStackTrace();
    }
  }