Package javax.xml.parsers

Examples of javax.xml.parsers.SAXParser


            connection.setRequestProperty("Authorization", "Basic " + encoded);

            connection.setConnectTimeout(10);
            InputStream stream = connection.getInputStream();

            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

            DreamboxHandler handler = new DreamboxHandler();

            saxParser.parse(stream, handler);

            return handler.getData();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {


            connection.setRequestProperty("Authorization", "Basic " + encoded);

            connection.setConnectTimeout(10);
            InputStream stream = connection.getInputStream();

            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

            DreamboxHandler handler = new DreamboxHandler();

            saxParser.parse(stream, handler);

            return handler.getData();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {

            connection.setRequestProperty("Authorization", "Basic " + encoded);

            connection.setConnectTimeout(60);
            InputStream stream = connection.getInputStream();

            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

            DreamboxChannelHandler handler = new DreamboxChannelHandler(updateManager, ch);

            saxParser.parse(stream, handler);
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {

   */
  public void parse(Reader cfgReader, String cfgName) throws Exception {
    this.joramAdmName = cfgName;

    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();
    parser.parse(new InputSource(cfgReader), this);
  }

    this.configName = cfgName;

    a3cmlConfig = new A3CMLConfig();

    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();
    parser.parse(new InputSource(cfgReader), this);

    return a3cmlConfig;
  }

        spf.setValidating(true);
        XMLReader reader = null;

    // set the features on the parser
    try{
          SAXParser parser = spf.newSAXParser();
          parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$ //$NON-NLS-2$
          parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", nameSpaceMap.keySet().toArray())//$NON-NLS-1$
          reader = parser.getXMLReader();
    } catch (SAXException err) {
            throw new TeiidComponentException(err);
        } catch (ParserConfigurationException err) {
            throw new TeiidComponentException(err);
        }

     */
     private HashMap getTargetNameSpaces(Collection<SQLXML> schemas) throws TeiidException {
       HashMap nameSpaceMap = new HashMap();
       SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);
        SAXParser parser;
        try {
            parser = spf.newSAXParser();
        } catch (ParserConfigurationException err) {
            throw new TeiidException(err);
        } catch (SAXException err) {
            throw new TeiidException(err);
        }
       PeekContentHandler pch = new PeekContentHandler();
       
       for (SQLXML schema : schemas) {
         InputStream is;
      try {
        is = schema.getBinaryStream();
      } catch (SQLException e) {
        throw new TeiidComponentException(e);
      }
      InputSource source = new InputSource(is);
             pch.targetNameSpace = null;
         try {
                parser.parse(source, pch);
            } catch (SAXException err) {
                throw new TeiidException(err);
            } catch (IOException err) {
                throw new TeiidComponentException(err);
            } finally {

    public void parse(ServletContext servletContext)
        throws Exception {
      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setNamespaceAware(false);
      factory.setValidating(false);
      SAXParser parser = factory.newSAXParser();
      servletContext.getContextPath();
      InputStream resourceAsStream = null;
      try {
        resourceAsStream = new FileInputStream(servletContext
            .getRealPath("WEB-INF/web.xml"));
        parser.parse(resourceAsStream, this);
      }finally{
        if(resourceAsStream != null)
          resourceAsStream.close();
      }
     

    public Set<String> doParse() throws Exception {
      XmlHandler handler = new XmlHandler();
      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setNamespaceAware(false);
      factory.setValidating(false);
      SAXParser parser = factory.newSAXParser();
      URL confURL = EntityManagerFactoryHolder.class.getClassLoader()
          .getResource("META-INF/persistence.xml");
      parser.parse(confURL.toString(), handler);
     
      return handler.getUnits();
    }

                    factory = ObjectUtils.instantiate("com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl", null);
                } else {
                    factory = SAXParserFactory.newInstance();
                }
                factory.setNamespaceAware(true);
                SAXParser parser = factory.newSAXParser();
                myReader = parser.getXMLReader();
            }
        } catch (Exception e) {
            throw new XQRTException("Creating SAX XMLReader failed", e);
        }
        // setup handlers (requires saxHandler)

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.