Package org.apache.xml.resolver

Examples of org.apache.xml.resolver.CatalogManager


  }

  public File processSources(Map<String, Object> map) throws MojoExecutionException {
    final String[] included = scanIncludedFiles();
    // configure a resolver for catalog files
    final CatalogManager catalogManager = createCatalogManager();
    final CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
    // configure a resolver for urn:dockbx:stylesheet
    final URIResolver uriResolver = createStyleSheetResolver(catalogResolver);

    // configure a resolver for xml entities
View Full Code Here


   *
   * @return A <code>CatalogManager</code> to be used for resolving DTDs and other entities.
   */
  protected CatalogManager createCatalogManager() {

    CatalogManager manager = new CatalogManager();
    manager.setIgnoreMissingProperties(true);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    StringBuffer builder = new StringBuffer();
    boolean first = true;
    for (int i = 0; i < catalogs.length; i++) {
      final String catalog = catalogs[i];

      try {
        Enumeration<URL> enumeration = classLoader.getResources(catalog);
        while (enumeration.hasMoreElements()) {
          if (!first) {
            builder.append(';');
          } else {
            first = false;
          }
          URL resource = enumeration.nextElement();
          builder.append(resource.toExternalForm());
        }
      } catch (IOException ioe) {
        getLog().warn("Failed to search for catalog files: " + catalog);
        // Let's be a little tolerant here.
      }
    }
    //builder.append("jar:file:/Users/salmanqureshi/.m2/repository/net/sf/docbook/docbook-xsl/1.76.1/docbook-xsl-1.76.1-ns-resources.zip!/docbook/catalog.xml");
    String catalogFiles = builder.toString();
    if (catalogFiles.length() == 0) {
      getLog().warn("Failed to find catalog files.");
    } else {
      if (getLog().isDebugEnabled()) {
        getLog().debug("Catalogs to load: " + catalogFiles);
      }
      manager.setCatalogFiles(catalogFiles);
    }
    return manager;
  }
View Full Code Here

                }
            }
            ClassLoader cl = new URLClassLoader((URL[]) urls.toArray(new URL[] {}));
            EntityResolver entityResolver = null;
            if (catalogLocation != null) {
                CatalogManager catalogManager = CatalogManager.getStaticManager();
                catalogManager.setCatalogFiles(catalogLocation);
                entityResolver = new CatalogResolver();
            }
            URI sourceDirURI = new File(sourceDir).toURI();
            entityResolver = new PassThroughResolver(cl, entityResolver, sourceDirURI, baseSchemaLocation);
View Full Code Here

            }
        } catch (IOException e) {
            LOG.warn("Failed to open OASIS catalog", e);
        }

        CatalogManager catalogManager = new CatalogManager();
        catalogManager.setUseStaticCatalog(false);
        catalogManager.setIgnoreMissingProperties(true);
        CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
        Catalog catalog = catalogResolver.getCatalog();

        if (catalogURI != null) {
            LOG.debug("Found OASIS catalog {} ", catalogURI);
View Full Code Here

      System.out.println("Usage: ExtendedTest [ -c catalog ] xmlfile");
      System.exit(1);
    }

    System.out.println("Creating my CatalogManager (Resolver)");
    CatalogManager myManager = new CatalogManager();
    myManager.setUseStaticCatalog(false);
    myManager.setVerbosity(2);
    myManager.setCatalogClassName("org.apache.xml.resolver.Resolver");
    System.out.println("Parsing with my CatalogManager");
    ResolvingXMLReader reader = new ResolvingXMLReader(myManager);
    parse(reader);
  }
View Full Code Here

      System.out.println("Usage: JarTest [ -c catalog ] xmlfile");
      System.exit(1);
    }

    System.out.println("Creating my CatalogManager (jar catalog)");
    CatalogManager myManager = new CatalogManager();
    myManager.setUseStaticCatalog(false);
    myManager.setVerbosity(5);
    System.out.println("Parsing with my CatalogManager");
    ResolvingXMLReader reader = new ResolvingXMLReader(myManager);
    parse(reader);
  }
View Full Code Here

      System.out.println("Usage: DynamicTest [ -c catalog ] xmlfile");
      System.exit(1);
    }

    System.out.println("Creating my CatalogManager (debug messages)");
    CatalogManager myManager = new CatalogManager();
    myManager.setIgnoreMissingProperties(true);
    myManager.setVerbosity(2);
    System.out.println("Parsing with my CatalogManager");
    ResolvingXMLReader reader = new ResolvingXMLReader(myManager);
    parse(reader);
  }
View Full Code Here

  }

  protected void setUp() throws Exception {
    super.setUp();

    CatalogManager manager = new CatalogManager();

    // Just do this to make sure that the debug level gets set.
    // I could set the value explicitly, but I know that the
    // ant build file is going to set the system property, so just
    // make sure that that gets used.
    int verbosity = manager.getVerbosity();

    catalog = new Catalog(manager);
    catalog.setupReaders();
    catalog.loadSystemCatalogs();
  }
View Full Code Here

    private Catalog resolver;
    private Set<URL> loadedCatalogs = Collections.synchronizedSet(new HashSet<URL>());
    private Bus bus;

    public OASISCatalogManager() {
        CatalogManager catalogManager = new CatalogManager();
        if (DEBUG_LEVEL != null) {
            catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL));
        }
        catalogManager.setUseStaticCatalog(false);
        catalogManager.setIgnoreMissingProperties(true);
        CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
        this.resolver = catalogResolver.getCatalog();
    }
View Full Code Here

        loadContextCatalogs(DEFAULT_CATALOG_NAME);
    }
   
    private static Object getResolver() {
        try {
            CatalogManager catalogManager = new CatalogManager();
            if (DEBUG_LEVEL != null) {
                catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL));
            }
            catalogManager.setUseStaticCatalog(false);
            catalogManager.setIgnoreMissingProperties(true);
            CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
            return catalogResolver.getCatalog();
        } catch (Throwable t) {
            //ignore
        }       
View Full Code Here

TOP

Related Classes of org.apache.xml.resolver.CatalogManager

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.