Package javax.xml.parsers

Examples of javax.xml.parsers.SAXParserFactory


    public ArrayList load() throws ParserConfigurationException, SAXException, IOException {
        ArrayList tasks = null;
        PreviousStateTasksTagHandler handler = new PreviousStateTasksTagHandler(
                null);
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser saxParser = factory.newSAXParser();
        saxParser.parse(myFile, handler);
        tasks = handler.getTasks();
        return tasks;
    }
View Full Code Here


    public boolean load() {
        // Use an instance of ourselves as the SAX event handler
        DefaultHandler handler = new GanttXMLOptionsParser();

        // Use the default (non-validating) parser
        SAXParserFactory factory = SAXParserFactory.newInstance();
        try {
            String sFileName = ".ganttproject";
            /*
             * if(System.getProperty("os.name").startsWith("Windows") ||
             * System.getProperty("os.name").startsWith("Mac")) sFileName =
             * "ganttproject.ini";
             */

            File file = new File(System.getProperty("user.home")
                    + System.getProperty("file.separator") + sFileName);
            if (!file.exists()) {
                return false;
            }

            documentsMRU.clear();

            // Parse the input
            SAXParser saxParser = factory.newSAXParser();
            saxParser.parse(file, handler);

            GanttLookAndFeelInfo info = GanttLookAndFeels
                    .getGanttLookAndFeels().getInfoByClass(styleClass);
            if (null == info)
View Full Code Here

  {
    try
    {
      log("Building grammar from "+grammarFile, Project.MSG_INFO);

      SAXParserFactory factory = getParserFactory();

      factory.setNamespaceAware(true);

      XMLReader parser = factory.newSAXParser().getXMLReader();
      parser.setEntityResolver(xmlCatalog);

      Mapping mapping = new Mapping();
      mapping.loadMapping(new InputSource(ExtendedGrammar.class.getResource("mapping.xml")
                                                               .openStream()));
View Full Code Here

    }
  }

  private void pushXMLFile(File inFile) throws Exception
  {
    SAXParserFactory parserfactory = getParserFactory();

    parserfactory.setNamespaceAware(true);

    XMLReader parser = parserfactory.newSAXParser().getXMLReader();

    parser.setEntityResolver(xmlCatalog);

    parser.setContentHandler(this.parser);
    try
View Full Code Here

      }
      else
      {
        log("Building lexicon from "+lexiconFile, Project.MSG_INFO);

        SAXParserFactory factory = getParserFactory();

        factory.setNamespaceAware(true);

        XMLReader parser = factory.newSAXParser().getXMLReader();

        parser.setEntityResolver(xmlCatalog);

        LexiconFactory lexiconfactory = new LexiconFactory();
        parser.setContentHandler(lexiconfactory);
        try
        {
          parser.parse(lexiconFile.toString());
        }
        catch (SAXParseException se)
        {
          throw new BuildException("Couldn't parse file "+lexiconFile, se);
        }

        Lexicon lexicon = lexiconfactory.getLexicon();

        this.lexicalautomaton = (new LexicalAutomatonBuilder(lexicon, log)).getLexicalAutomaton();

        if (cacheFile!=null)
        {
          ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(cacheFile));
          out.writeObject(this.lexicalautomaton);
          out.flush();
          out.close();
        }
      }

      if (grammarFile!=null)
      {
        // Grammar
        filename = grammarFile.getName();

        cacheFile = null;
        if (cacheDir!=null)
          cacheFile = new File(cacheDir, filename+".obj");

        if ((cacheFile!=null) && (cacheFile.exists()) &&
            (cacheFile.lastModified()>grammarFile.lastModified()))
        {
          log("Reading grammar from cache "+cacheFile, Project.MSG_DEBUG);

          ObjectInputStream in = new ObjectInputStream(new FileInputStream(cacheFile));
          this.parserautomaton = (ParserAutomaton)in.readObject();
          in.close();
        }
        else
        {
          log("Building grammar from "+grammarFile, Project.MSG_INFO);

          SAXParserFactory factory = getParserFactory();

          factory.setNamespaceAware(true);

          XMLReader parser = factory.newSAXParser().getXMLReader();
          parser.setEntityResolver(xmlCatalog);

          GrammarFactory grammarfactory = new GrammarFactory();
          parser.setContentHandler(grammarfactory);
          try
View Full Code Here

    }
  }

  private void pushXMLFile(File inFile) throws Exception
  {
    SAXParserFactory parserfactory = getParserFactory();

    parserfactory.setNamespaceAware(true);

    XMLReader parser = parserfactory.newSAXParser().getXMLReader();

    parser.setEntityResolver(xmlCatalog);

    parser.setContentHandler(this.lexer);
    try
View Full Code Here

      }
      else
      {*/
      System.out.println("Building grammar from "+grammarFile)//info

      SAXParserFactory factory = getParserFactory();

      factory.setNamespaceAware(true);

      XMLReader parser = factory.newSAXParser().getXMLReader();

      //NamespacedSAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler();
      GrammarFactory grammarfactory = new GrammarFactory();
      parser.setContentHandler(grammarfactory);
      try
View Full Code Here

    }

  }*/
  private void pushXMLFile(File inFile) throws Exception
  {
    SAXParserFactory parserfactory = getParserFactory();

    parserfactory.setNamespaceAware(true);

    XMLReader parser = parserfactory.newSAXParser().getXMLReader();

    /*LexicalProcessorAdapter handler = new LexicalProcessorAdapter();

    handler.setLexicalProcessor(this.lexer);
    handler.setContentHandler(serializer);
View Full Code Here

    }
   
    public RSSReader(int maxsize, final InputStream stream, Type type) throws IOException {
        this(maxsize);
        this.type = type;
        final SAXParserFactory factory = SAXParserFactory.newInstance();
        try {
            final SAXParser saxParser = factory.newSAXParser();
            saxParser.parse(stream, this);
        } catch (SAXException e) {
            throw new IOException (e.getMessage());
        } catch (ParserConfigurationException e) {
            throw new IOException (e.getMessage());
View Full Code Here

    int lineNumber, columnNumber;
    private Exception exception;

    public boolean parse(InputSource in) {
        try {
            SAXParserFactory parserFactory = SAXParserFactory.newInstance();
            parserFactory.setValidating(false);
            parserFactory.setNamespaceAware(false);

            SAXParser parser = parserFactory.newSAXParser();

            // call parsing
            parser.parse(in, this);

            this.exception = null;
View Full Code Here

TOP

Related Classes of javax.xml.parsers.SAXParserFactory

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.