Package javax.xml.parsers

Examples of javax.xml.parsers.SAXParserFactory.newSAXParser()


                               URL baseUrl) throws IOException {
    try {
      SceneBase scene = new SceneBase();
      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setValidating(false);
      SAXParser saxParser = factory.newSAXParser();
      saxParser.parse(in, new DAEHandler(scene, baseUrl));
      return scene;
    } catch (ParserConfigurationException ex) {
      IOException ex2 = new IOException("Can't parse XML stream");
      ex2.initCause(ex);
View Full Code Here


        try {
            SAXParserFactory parserFactory = SAXParserFactory.newInstance();
            parserFactory.setValidating(false);
            parserFactory.setNamespaceAware(false);

            SAXParser parser = parserFactory.newSAXParser();

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

            log.info("XML parsed in " + (System.currentTimeMillis() - startTime) + "ms.");
View Full Code Here

                    catch (Exception e)
                    {
                        NucleusLogger.METADATA.info(e.getMessage());
                    }
                }
                parser = factory.newSAXParser();
            }

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

            +"<root />"
            ;

        SAXParserFactory spf = new WstxSAXParserFactory();
        spf.setNamespaceAware(true);
        SAXParser sp = spf.newSAXParser();
        DefaultHandler h = new DefaultHandler();

        /* First: let's verify that we get an exception for
         * unresolved reference...
         */
 
View Full Code Here

        } catch (SAXException e) {
            verifyException(e, "No such file or directory");
        }

        // And then with dummy resolver; should work ok now
        sp = spf.newSAXParser();
        sp.getXMLReader().setEntityResolver(new MyResolver("   "));
        h = new DefaultHandler();
        try {
            sp.parse(new InputSource(new StringReader(XML)), h);
        } catch (SAXException e) {
View Full Code Here

        throws Exception
    {
        // no need to test JAXP introspection...
        SAXParserFactory spf = new WstxSAXParserFactory();
        spf.setNamespaceAware(ns);
        SAXParser sp = spf.newSAXParser();
        MyHandler h = new MyHandler();

        InputSource src;

        if (useReader) {
View Full Code Here

        throws Exception
    {
        //SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParserFactory spf = new WstxSAXParserFactory();
        spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
        SAXParser sp = spf.newSAXParser();
        MyContentHandler h = new MyContentHandler();
        sp.setProperty(SAXProperty.LEXICAL_HANDLER.toString(), /*DeclHandler*/h);
        // This shouldn't be needed -- nor seems to work for Xerces?
        //sp.getXMLReader().setEntityResolver(h);
        InputStream in = new FileInputStream(file);
View Full Code Here

            if ( this.isValidating == true )
            {
                factory.setValidating( true );
                try
                {
                    localParser = factory.newSAXParser( );
                }
                catch ( ParserConfigurationException e )
                {
                    throw new RuntimeException( e.getMessage( ) );
                }
View Full Code Here

                // not jaxp1.2 compliant so turn off validation
                try
                {
                    this.isValidating = false;
                    factory.setValidating( this.isValidating );
                    localParser = factory.newSAXParser( );
                }
                catch ( ParserConfigurationException e )
                {
                    throw new RuntimeException( e.getMessage( ) );
                }
View Full Code Here

    SAXParser saxParser;

    // Use the default (non-validating) parser
    final SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
      saxParser = factory.newSAXParser();
    } catch (final ParserConfigurationException ex) {
      throw new SAXException(ex);
    }

    // Parse the XML
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.