Package javax.xml.parsers

Examples of javax.xml.parsers.SAXParser


    public static Configuration buildFromXML( final InputSource input )
        throws Exception
    {
        final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        saxParserFactory.setNamespaceAware( false );
        final SAXParser saxParser = saxParserFactory.newSAXParser();
        final SAXConfigurationHandler handler = new SAXConfigurationHandler();
        saxParser.parse( input, handler );
        return handler.getConfiguration();
    }


     * @throws Exception if there's other problem
     */
    public static JxpProcessor getProcessor(InputStream config) throws SAXException, IOException, Exception
    {
        SaxDigesterHandler handler = new SaxDigesterHandler();
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        JxpConfigDigester dig = new JxpConfigDigester();
        handler.addDigester(dig);
        parser.parse(config, handler);
        return dig.getProcessor();
    }

                                          boolean namespaceAware) throws Exception {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(validating);
    factory.setNamespaceAware(namespaceAware);

    SAXParser parser = factory.newSAXParser();

    return parser.getXMLReader();
  }

         SAXParserFactory spf = glob.getSAXParserFactory();
         boolean validate = glob.getProperty().get("javax.xml.parsers.validation", false);
         spf.setValidating(validate);
         //if (log.isLoggable(Level.FINE)) log.trace(ME, "XML-Validation 'javax.xml.parsers.validation' set to " + validate);

         SAXParser sp = spf.newSAXParser();
         XMLReader parser = sp.getXMLReader();

         //parser.setEntityResolver(EntityResolver resolver);
         //parser.setFeature("http://xml.org/sax/features/validation", true);
         //parser.setFeature("http://apache.org/xml/features/validation/schema", true);
         //parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);

    if (null != primIS) {

      // get a SAX parser from JAXP layer
      SAXParserFactory factory = SAXParserFactory.newInstance();
      try {
        SAXParser saxParser = factory.newSAXParser();
        MySaxHandler handler = new MySaxHandler( objIS);

        // the work is done here
        saxParser.parse(primIS, handler);

      } catch (ParserConfigurationException e) {
        e.printStackTrace();

      } catch (SAXException se) {

  public SAXParser createParser()
  {
    try
    {
      SAXParserFactory parserFactory = createSAXParserFactory();
      SAXParser parser = parserFactory.newSAXParser();
      configureParser(parser);
      return parser;
    }
    catch (SAXException e)
    {

                    pfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
                }
                catch (SAXException e) {}
            }
           
            SAXParser saxparser = pfactory.newSAXParser();
            parent = saxparser.getXMLReader();
        }
        catch (ParserConfigurationException e) {
            throw new SAXException(e);
        }
        catch (FactoryConfigurationError e) {

     */
    private ObjectHandler getHandler() {
        if ( handler == null ) {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            try {
                SAXParser parser = factory.newSAXParser();
                handler = new ObjectHandler( this, getClassLoader() );
                parser.parse( in, handler );
            }
            catch ( ParserConfigurationException e ) {
                getExceptionListener().exceptionThrown( e );
            }
            catch ( SAXException se ) {

    private Map<String, Method> attributesMap = new HashMap<String, Method>();
   
    boolean isTest = false;
   
    public static void main(String[] args) throws Exception {
        SAXParser p = SAXParserFactory.newInstance().newSAXParser();
        String input = "../html-codegen/html4-doc.xml";
        CanvasMethodsGenerator gen = new CanvasMethodsGenerator();
        if (args.length > 0) {
            gen.isTest = args[0].equals("t");
        }
        p.parse(new File(input), gen);
        gen.exportMethods();
    }

        }
        gen.exportMethods();
    }
   
    protected void parse(String inputFilename) throws Exception {
        SAXParser p = SAXParserFactory.newInstance().newSAXParser();
        p.parse(new File(inputFilename), this);
    }

TOP

Related Classes of javax.xml.parsers.SAXParser

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.