Examples of SAXParserFactory


Examples of javax.xml.parsers.SAXParserFactory

    public List<BibtexEntry> importEntries(InputStream stream) throws IOException {

  ArrayList<BibtexEntry> bibItems = new ArrayList<BibtexEntry>();

  // Obtain a factory object for creating SAX parsers
  SAXParserFactory parserFactory = SAXParserFactory.newInstance();
  // Configure the factory object to specify attributes of the parsers it
  // creates
  // parserFactory.setValidating(true);
  parserFactory.setNamespaceAware(true)
  // Now create a SAXParser object


  try{
      SAXParser parser = parserFactory.newSAXParser(); //May throw exceptions
      BibTeXMLHandler handler = new BibTeXMLHandler();
      // Start the parser. It reads the file and calls methods of the handler.
      parser.parse(stream, handler);
      // When you're done, report the results stored by your handler object
      bibItems = handler.getItems();
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

        try
        {
            if (parser == null)
            {
                // Create a SAXParser (use JDK parser for now)
                SAXParserFactory factory = SAXParserFactory.newInstance();
                factory.setValidating(validate);
                factory.setNamespaceAware(validate);
                if (validate)
                {
                    // Xerces (if in CLASSPATH) needs this for validation (of XSD)
                    try
                    {
                        factory.setFeature("http://apache.org/xml/features/validation/schema", true );
                    }
                    catch (Exception e)
                    {
                    }
                }

                parser = factory.newSAXParser();
            }

            // Generate the default handler to process the metadata
           
            DefaultHandler handler = null;
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

  public static TypedTableModel performParse(final InputStream postResult) throws IOException, ReportDataFactoryException
  {
    try
    {
      final CdaResponseParser contentHandler = new CdaResponseParser();
      final SAXParserFactory factory = SAXParserFactory.newInstance();
      final SAXParser parser = factory.newSAXParser();
      final XMLReader reader = parser.getXMLReader();

      try
      {
        reader.setFeature("http://xml.org/sax/features/xmlns-uris", false);
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

    }
   
    public opensearchdescriptionReader(final String path) {
        this();
        try {
            final SAXParserFactory factory = SAXParserFactory.newInstance();
            final SAXParser saxParser = factory.newSAXParser();
            saxParser.parse(path, this);
        } catch (final Exception e) {
            Log.logException(e);
        }
    }
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

    }
   
    public opensearchdescriptionReader(final InputStream stream) {
        this();
        try {
            final SAXParserFactory factory = SAXParserFactory.newInstance();
            final SAXParser saxParser = factory.newSAXParser();
            saxParser.parse(stream, this);
        } catch (final Exception e) {
            Log.logException(e);
        }
    }
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

  {
    // Create log
    Log log = new SimpleLog("log");

    // Create factory for SAX parser
    SAXParserFactory parserFactoryImpl = SAXParserFactory.newInstance();
    parserFactoryImpl.setNamespaceAware(true);

    // Get a SAX parser
    XMLReader xmlparser = parserFactoryImpl.newSAXParser().getXMLReader();

    // Create a lexicon model for a given lexicon file
    LexiconFactory lexiconfactory = new LexiconFactory();
    xmlparser.setContentHandler(lexiconfactory);
    xmlparser.parse(lexiconFile.toString());

    Lexicon lexicon = lexiconfactory.getLexicon();

    // Build a automaton from the lexicon model
    LexicalAutomaton lexicalautomaton =
      (new LexicalAutomatonBuilder(lexicon, log)).getLexicalAutomaton();

    // Create a processor for the lexicon
    LexicalProcessor lexer = new LexicalProcessor();
    lexer.setLog(log);
    lexer.setLexicalAutomaton(lexicalautomaton);

    // Get a SAX parser
    xmlparser = parserFactoryImpl.newSAXParser().getXMLReader();

    // Create a grammar model for a given grammar file
    GrammarFactory grammarfactory = new GrammarFactory();
    xmlparser.setContentHandler(grammarfactory);
    xmlparser.parse(grammarFile.toString());
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

    System.out.println(collection);
  }

  public void testBigGrammar() throws Exception
  {
    SAXParserFactory factory = SAXParserFactory.newInstance();

    factory.setNamespaceAware(true);

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

    GrammarFactory handler = new GrammarFactory();
    parser.setContentHandler(handler);
    parser.parse(new InputSource(getClass().getResourceAsStream("java.xgrm")));
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

  }

  private Document process(GeneralParserProcessor processor, String in)
    throws Exception
  {
    SAXParserFactory parserfactory = SAXParserFactory.newInstance();
    parserfactory.setNamespaceAware(true);

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

    SAXTransformerFactory transformerfactory =
      (SAXTransformerFactory)SAXTransformerFactory.newInstance();
    TransformerHandler handler = transformerfactory.newTransformerHandler();
    DOMResult result = new DOMResult();
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

    return (Document)result.getNode();
  }

  private Grammar getGrammar(String in) throws Exception
  {
    SAXParserFactory parserfactory = SAXParserFactory.newInstance();
    parserfactory.setNamespaceAware(true);

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

    GrammarFactory grammarfactory = new GrammarFactory();
    parser.setContentHandler(grammarfactory);
    parser.parse(new InputSource(getClass().getClassLoader().getResourceAsStream(in)));
View Full Code Here

Examples of javax.xml.parsers.SAXParserFactory

    return grammarfactory.getGrammar();
  }

  private Document getDocument(String in) throws Exception
  {
    SAXParserFactory parserfactory = SAXParserFactory.newInstance();
    parserfactory.setNamespaceAware(true);

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

    SAXTransformerFactory transformerfactory =
      (SAXTransformerFactory)SAXTransformerFactory.newInstance();
    TransformerHandler handler = transformerfactory.newTransformerHandler();
    DOMResult result = new DOMResult();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.