Package org.apache.avalon.excalibur.xml

Examples of org.apache.avalon.excalibur.xml.Parser


        contextData = XMLUtil.createDocument();
        contextData.appendChild(contextData.createElementNS(null, "context"));

        Element root = contextData.getDocumentElement();

        Parser parser = null;
        try {
            parser = (Parser) manager.lookup( Parser.ROLE );
            this.buildParameterXML(root, parser);
        } catch (ComponentException ce) {
            throw new ProcessingException("Unable to lookup parser.", ce);
View Full Code Here


     * @throws ResourceNotFoundException if file not found or
     *         HTTP location does not exist.
     * @throws SAXException if failed to parse source document.
     */
    public void toSAX(ContentHandler handler) throws SAXException, ProcessingException {
        Parser parser = null;
        try {
            parser = (Parser)this.manager.lookup(Parser.ROLE);

            parser.parse( this.getInputSource(), handler);
        } catch (SAXException e) {
            // Preserve original exception
            throw e;
        } catch (Exception e){
            throw new ProcessingException("Exception during processing of "
View Full Code Here

  /* The Source interface methods. */

  public void toSAX(ContentHandler handler) throws SAXException
  {
    Parser parser = null;
    try {
      parser = (Parser)componentManager.lookup(Parser.ROLE);
      InputSource source = getInputSource();
      parser.parse(source, handler);
    } catch (SAXException e) {
      throw e;
    } catch (Exception e) {
      throw new SAXException(e);
    } finally {
View Full Code Here

     * @return a <code>Configuration</code> value
     * @exception ConfigurationException if an error occurs
     * @exception ContextException if an error occurs
     */
    public Configuration configure(ExcaliburComponentManager startupManager) throws ConfigurationException, ContextException {
        Parser p = null;
        Configuration roleConfig = null;

        try {
            this.configurationFile.refresh();
            p = (Parser)startupManager.lookup(Parser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/cocoon.roles").openStream();
            InputSource is = new InputSource(inputStream);
            is.setSystemId(this.configurationFile.getSystemId());
            p.parse(is, b);
            roleConfig = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
            if (p != null) startupManager.release(p);
        }

        DefaultRoleManager drm = new DefaultRoleManager();
        drm.setLogger(getLogger().getChildLogger("roles"));
        drm.configure(roleConfig);
        roleConfig = null;

        try {
            p = (Parser)startupManager.lookup(Parser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputSource is = this.configurationFile.getInputSource();
            p.parse(is, b);
            this.configuration = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations",e);
        } finally {
            if (p != null) startupManager.release(p);
        }

        Configuration conf = this.configuration;
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Root configuration: " + conf.getName());
        }
        if (! "cocoon".equals(conf.getName())) {
            throw new ConfigurationException("Invalid configuration file\n" + conf.toString());
        }
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Configuration version: " + conf.getAttribute("version"));
        }
        if (!Constants.CONF_VERSION.equals(conf.getAttribute("version"))) {
            throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
        }

        String userRoles = conf.getAttribute("user-roles", "");
        if (!"".equals(userRoles)) {
            try {
                p = (Parser)startupManager.lookup(Parser.ROLE);
                SAXConfigurationHandler b = new SAXConfigurationHandler();
                org.apache.cocoon.environment.Context context =
                    (org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
                URL url = context.getResource(userRoles);
                InputSource is = new InputSource(new BufferedInputStream(url.openStream()));
                is.setSystemId(this.configurationFile.getSystemId());
                p.parse(is, b);
                roleConfig = b.getConfiguration();
            } catch (Exception e) {
                getLogger().error("Could not configure Cocoon environment with user roles file", e);
                throw new ConfigurationException("Error trying to load user-roles configuration", e);
            } finally {
View Full Code Here

        contextData = XMLUtil.createDocument();
        contextData.appendChild(contextData.createElementNS(null, "context"));

        Element root = contextData.getDocumentElement();

        Parser parser = null;
        try {
            parser = (Parser) manager.lookup( Parser.ROLE );
            this.buildParameterXML(root, parser);
        } catch (ComponentException ce) {
            throw new ProcessingException("Unable to lookup parser.", ce);
View Full Code Here

   */
  public LibreConfig createConfig(InputStream fromStream, HierarchyConfig parentCfg){
    LibreConfigBuilder lcb = new LibreConfigBuilder(parentCfg, this);
    if (this.manager != null) {
      try {
        Parser parser = getExcaliburParser();
        parser.parse(new InputSource(fromStream), lcb);
      } catch(SAXException e) {
        e.printStackTrace();
      } catch(IOException e) {
        e.printStackTrace();
      }
View Full Code Here

  }

  public Document getDOMDocument(InputStream inXML)  {

    Document doc = null;
    Parser excaliburParser = this.helper.getExcaliburParser();
    if (excaliburParser != null) {
      try {
        doc = excaliburParser.parseDocument(new InputSource(inXML));
      } catch(SAXException e) {
        e.printStackTrace();;
      } catch(IOException e) {
        e.printStackTrace();
      }
View Full Code Here

            getLogger().debug("Reloading sitemap asynchron = " + reloadAsynchron);
            getLogger().debug("Sitemap check delay = " + checkDelay + " sec");
        }

        // Read sitemap roles
        Parser p = null;
        Configuration rolesConfig;
        try {
            p = (Parser)this.manager.lookup(Parser.ROLE);
            SAXConfigurationHandler b = new SAXConfigurationHandler();
            InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/sitemap/sitemap.roles").openStream();
            InputSource is = new InputSource(inputStream);
            is.setSystemId("org/apache/cocoon/sitemap/sitemap.roles");
            p.parse(is, b);
            rolesConfig = b.getConfiguration();
        } catch (Exception e) {
            getLogger().error("Could not configure Cocoon environment", e);
            throw new ConfigurationException("Error trying to load configurations", e);
        } finally {
View Full Code Here

        contextData = XMLUtil.createDocument();
        contextData.appendChild(contextData.createElementNS(null, "context"));

        Element root = contextData.getDocumentElement();

        Parser parser = null;
        try {
            parser = (Parser) manager.lookup( Parser.ROLE );
            this.buildParameterXML(root, parser);
        } catch (ComponentException ce) {
            throw new ProcessingException("Unable to lookup parser.", ce);
View Full Code Here

     * @throws ResourceNotFoundException if file not found or
     *         HTTP location does not exist.
     * @throws SAXException if failed to parse source document.
     */
    public void toSAX(ContentHandler handler) throws SAXException, ProcessingException {
        Parser parser = null;
        try {
            parser = (Parser)this.manager.lookup(Parser.ROLE);

            parser.parse( this.getInputSource(), handler);
        } catch (SAXException e) {
            // Preserve original exception
            throw e;
        } catch (ProcessingException e){
            // Preserve original exception
View Full Code Here

TOP

Related Classes of org.apache.avalon.excalibur.xml.Parser

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.