Package org.xml.sax

Examples of org.xml.sax.XMLReader


        is.setByteStream(in);
        is.setSystemId(url);
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(false);
        factory.setValidating(false);
        XMLReader reader = factory.newSAXParser().getXMLReader();
        reader.setEntityResolver(new LocalTaglibDtds());
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.parse(is);
    }
View Full Code Here


      // Get resource
      URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
      // The input source
      InputSource input = new InputSource(url.openStream());
      input.setSystemId(url.toURI().toString());
      XMLReader reader = XMLReaderFactory.createXMLReader();
      reader.setEntityResolver(new JBossEntityResolver());
      SAXSource source = new SAXSource(reader, input);
      // New JAXB context
      JAXBContext context = JAXBContext.newInstance(ManagedConnectionFactoryDeploymentGroup.class);
      Unmarshaller um = context.createUnmarshaller();
      // Unmarshal
View Full Code Here

      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

  {
    SAXParserFactory parserfactory = getParserFactory();

    parserfactory.setNamespaceAware(true);

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

    parser.setEntityResolver(xmlCatalog);

    parser.setContentHandler(this.parser);
    try
    {
      parser.parse(inFile.toString());
    }
    catch (SAXParseException se)
    {
      throw new BuildException("Exception occurs during parsing file "+inFile+" at line "+
                               se.getLineNumber()+" column "+se.getColumnNumber(), se);
View Full Code Here

    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);
      }
      catch (SAXException e)
      {
        // ignored
      }
      try
      {
        reader.setFeature("http://xml.org/sax/features/namespaces", false);
        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
      }
      catch (final SAXException e)
      {
        logger.warn("No Namespace features will be available. (Yes, this is serious)", e);
      }

      reader.setContentHandler(contentHandler);
      reader.parse(new InputSource(postResult));

      return (contentHandler.getResult());
    }
    catch (final ParserConfigurationException e)
    {
View Full Code Here

    // 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());

    Grammar grammar = grammarfactory.getGrammar();

    // Build a automaton from the grammar model
    ParserAutomaton parserautomaton =
View Full Code Here

        } else if (validate.equals("relaxng")) {
          if (schema == null) throw new UsageException(
              "Missing required argument --schema");
          return builderPool.getMSVBuilder(schema.toURI());
        } else if (validate.equals("html")) {
          XMLReader parser;
          try {
            parser = (XMLReader) Class.forName("org.ccil.cowan.tagsoup.Parser").newInstance();
          } catch (Exception e) {
            throw new UsageException(e);
          }
View Full Code Here

  {
    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")));

    Grammar grammar = handler.getGrammar();

    Automaton collection = new Automaton(grammar,  /*firstsets,*/
                                         null);
View Full Code Here

    fiSerializer = null;
    fiMethod = null;
    if (mode.startsWith("fi")) {
      NodeFactory factory = null;
      if (mode.indexOf("NNF") >= 0) factory = XOMUtil.getNullNodeFactory();
      XMLReader parser = (XMLReader) Class.forName("com.sun.xml.fastinfoset.sax.SAXDocumentParser").newInstance();
      fiBuilder = new Builder(parser, false, factory);
     
      if (mode.indexOf("stax") >= 0) {
        fiSerializer = (XMLStreamWriter) Class.forName("com.sun.xml.fastinfoset.stax.StAXDocumentSerializer").newInstance();       
      } else {
View Full Code Here

    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();
    handler.setResult(result);

    processor.setContentHandler(new WhitespaceFilter(handler));

    parser.setContentHandler(processor);
    parser.parse(new InputSource(getClass().getClassLoader().getResourceAsStream(in)));

    return (Document)result.getNode();
  }
View Full Code Here

TOP

Related Classes of org.xml.sax.XMLReader

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.