Package org.xml.sax

Examples of org.xml.sax.XMLReader


                // with handler
                ClassReader cr = new ClassReader(readEntry(zis, ze));
                cr.accept(new SAXClassAdapter(handler, singleInputDocument), 0);

            } else { // read XML and process it with handler
                XMLReader reader = XMLReaderFactory.createXMLReader();
                reader.setContentHandler(handler);
                reader.parse(new InputSource(singleInputDocument
                        ? (InputStream) new ProtectedInputStream(zis)
                        : new ByteArrayInputStream(readEntry(zis, ze))));

            }
        } catch (Exception ex) {
View Full Code Here


     * @throws java.io.IOException if input can't be read
     * @throws org.xml.sax.SAXException if XML can't be parsed
     */
    public synchronized ListAccumulator parse(InputSource input) throws IOException, SAXException {

        XMLReader reader = new SAXParser();
        reader.setContentHandler(this);
        reader.parse(input);

        return ba;
    }
View Full Code Here

      SAXParserFactory factory = getParserFactory();

      factory.setNamespaceAware(true);

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

      //NamespacedSAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler();
      GrammarFactory grammarfactory = new GrammarFactory();
      parser.setContentHandler(grammarfactory);
      try
      {
        parser.parse(grammarFile.toString());
      }
      catch (SAXParseException se)
      {
        throw new Exception("Couldn't parse file "+lexiconFile+": "+se.getMessage());
      }
View Full Code Here

  {
    SAXParserFactory parserfactory = getParserFactory();

    parserfactory.setNamespaceAware(true);

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

    /*LexicalProcessorAdapter handler = new LexicalProcessorAdapter();

    handler.setLexicalProcessor(this.lexer);
    handler.setContentHandler(serializer);

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

   * @return DOCUMENT ME!
   * @throws SAXException DOCUMENT ME!
   */
  public static XMLReader createXMLReader(boolean validating)
      throws SAXException {
    XMLReader reader = null;

    if (reader == null) {
      reader = createXMLReaderViaJAXP(validating, true);
    }

View Full Code Here

    return dh.getContent();
  }
 
  private void parse(InputStream stream, DefaultHandler handler) throws DocumentException {
    try {
      XMLReader parser = XMLReaderFactory.createXMLReader();
      parser.setContentHandler(handler);
      parser.setEntityResolver(handler);
      try {
      parser.setFeature("http://xml.org/sax/features/validation", false);
      } catch(Exception e) {
        e.printStackTrace();
        //cannot desactivate validation
      }
      parser.parse(new InputSource(stream));
    } catch (Exception e) {
      throw new DocumentException("XML parser configuration error", e);
    }
  }
View Full Code Here

    } catch (IOException e) {
      log.error("Could not convert xsl to string!", e);
    }
    String replacedOutput = evaluateValue(xslAsString, vcContext);
    TransformerFactory tfactory = TransformerFactory.newInstance();
    XMLReader reader;
    try {
      reader = XMLReaderFactory.createXMLReader();
      reader.setEntityResolver(er);
      Source xsltsource = new SAXSource(reader, new InputSource(new StringReader(replacedOutput)));
      this.transformer = tfactory.newTransformer(xsltsource);
    } catch (SAXException e) {
      throw new OLATRuntimeException("Could not initialize transformer!", e);
    } catch (TransformerConfigurationException e) {
View Full Code Here

      try {
         SAXParserFactory factory = SAXParserFactory.newInstance();
         factory.setValidating(true);
         factory.setNamespaceAware(true);
         SAXParser parser = factory.newSAXParser();
         XMLReader reader = parser.getXMLReader();

         reader.setContentHandler(this);
         reader.setErrorHandler(new Frame2ParseErrorHandler());
         reader.setEntityResolver(new Frame2EntityResolver());

         InputSource is = new InputSource(io);

         reader.parse(is);
      } catch (ParserConfigurationException ex) {
         throw new ParserException(ex);
      } catch (SAXException ex) {
         throw new ParserException(ex);
      } catch (IOException ex) {
View Full Code Here

    // Set the schema source.
    saxParser.setProperty(JAXP_SCHEMA_SOURCE, schemaSource);

    // Get the SAX XMLReader
    XMLReader xmlReader = saxParser.getXMLReader();

    // Set the ErrorHandler
    xmlReader.setErrorHandler(new MyErrorHandler(System.err));

    // Parse the XML source
    // This will throw a SAXException if the file is not valid.
    xmlReader.parse(xmlSource);
  }
View Full Code Here

    static XMLReader findParser(boolean validate) {
       
        // first look for Xerces; we only trust Xerces if
        // we set it up; and we need to configure it specially
        // so we can't load it with the XMLReaderFactory
        XMLReader parser;
        try {
            parser = new XML1_0Parser();
            setupParser(parser, validate);
            return parser;
        }
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.