本文整理汇总了Java中org.apache.xml.resolver.Catalog类的典型用法代码示例。如果您正苦于以下问题:Java Catalog类的具体用法?Java Catalog怎么用?Java Catalog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Catalog类属于org.apache.xml.resolver包,在下文中一共展示了Catalog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* XMLCatalog calls this to add an external catalog file for each
* file within a <code><catalogfiles></code> fileset.
* @param file the external catalog file.
*/
public void parseCatalog(final String file) {
final Catalog catalog = getCatalog();
if (!(catalog instanceof ApacheCatalog)) {
throw new BuildException("Wrong catalog type found: %s", catalog.getClass().getName());
}
final ApacheCatalog apacheCatalog = (ApacheCatalog) catalog;
// Pass in reference to ourselves so we can be called back.
apacheCatalog.setResolver(this);
try {
apacheCatalog.parseCatalog(file);
} catch (IOException ex) {
throw new BuildException(ex);
}
}
示例2: parseCatalogs
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* Instruct the <code>Catalog</code> to parse each of the
* catalogs in the list. Only the first catalog will actually be
* parsed immediately. The others will be queued and read if
* they are needed later.
*/
private void parseCatalogs () throws IOException {
if (fCatalogsList != null) {
fCatalog = new Catalog(fResolverCatalogManager);
attachReaderToCatalog(fCatalog);
for (int i = 0; i < fCatalogsList.length; ++i) {
String catalog = fCatalogsList[i];
if (catalog != null && catalog.length() > 0) {
fCatalog.parseCatalog(catalog);
}
}
}
else {
fCatalog = null;
}
}
示例3: initResolver
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
private void initResolver() throws IOException {
CatalogManager catalogManager = new CatalogManager();
catalogManager.setUseStaticCatalog(true);
catalogManager.setIgnoreMissingProperties(true);
catalogManager.setVerbosity(1);
catalogManager.setPreferPublic(true);
CatalogResolver catalogResolver = new CatalogResolver(catalogManager);
Catalog catalog = catalogResolver.getCatalog();
if (catalogFiles != null && catalogFiles.length > 0) {
for (File catalogFile : catalogFiles) {
LOGGER.trace("Using catalog file {}", catalogFile);
catalog.parseCatalog(catalogFile.getPath());
}
} else if (catalogResourceName != null) {
LOGGER.trace("Using catalog from resource: {}", catalogResourceName);
Enumeration<URL> catalogs = Thread.currentThread().getContextClassLoader().getResources(catalogResourceName);
while (catalogs.hasMoreElements()) {
URL catalogResourceUrl = catalogs.nextElement();
LOGGER.trace("Parsing catalog from URL: {}", catalogResourceUrl);
catalog.parseCatalog(catalogResourceUrl);
}
} else {
throw new IllegalStateException("Catalog is not defined");
}
builtinSchemaResolver = catalogResolver;
}
示例4: resolveSchemaLocation
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
private String resolveSchemaLocation(String namespaceOrLocation, Path filePath, File workDir) throws MojoExecutionException, IOException {
for (ArtifactItem artifactItem: artifactItems) {
Catalog catalog = artifactItem.getResolveCatalog();
if (catalog == null) {
continue;
}
String publicId = namespaceOrLocation;
if (publicId.endsWith("#")) {
publicId = publicId.substring(0, publicId.length()-1);
}
String resolvedString = catalog.resolveEntity(filePath.toString(), publicId, publicId);
if (resolvedString != null) {
getLog().debug("-------------------");
getLog().debug("Resolved namespace/schemaLocation "+namespaceOrLocation+" to "+resolvedString+" using catalog "+catalog);
URL resolvedUrl = new URL(resolvedString);
String resolvedPathString = resolvedUrl.getPath();
Path resolvedPath = new File(resolvedPathString).toPath();
Path workDirPath = workDir.toPath();
Path resolvedRelativeToCatalogWorkdir = artifactItem.getWorkDir().toPath().relativize(resolvedPath);
Path fileRelativeToWorkdir = workDirPath.relativize(filePath);
getLog().debug("workDirPath: "+workDirPath);
getLog().debug("resolvedRelativeToCatalogWorkdir: "+resolvedRelativeToCatalogWorkdir+", fileRelativeToWorkdir: "+fileRelativeToWorkdir);
Path relativePath = fileRelativeToWorkdir.getParent().relativize(resolvedRelativeToCatalogWorkdir);
getLog().debug("Rel: "+relativePath);
String unixSeparators = FilenameUtils.separatorsToUnix(relativePath.toString());
getLog().debug("Normalized to use UNIX separators: " + unixSeparators);
return unixSeparators;
}
}
throw new MojoExecutionException("Cannot resolve namespace "+namespaceOrLocation+" in file "+filePath+" using any of the catalogs");
}
示例5: resolve
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
@Nullable
public String resolve(String uri) {
try {
Catalog catalog = myManager.getCatalog();
if (catalog == null) return null;
String resolved = catalog.resolveSystem(uri);
return resolved == null ? catalog.resolvePublic(uri, null) : resolved;
}
catch (IOException e) {
LOG.warn(e);
return null;
}
}
示例6: resolveSchemaLocation
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
private String resolveSchemaLocation(String namespaceOrLocation, Path filePath, File workDir) throws MojoExecutionException, IOException {
for (ArtifactItem artifactItem: artifactItems) {
Catalog catalog = artifactItem.getResolveCatalog();
if (catalog == null) {
continue;
}
String publicId = namespaceOrLocation;
if (publicId.endsWith("#")) {
publicId = publicId.substring(0, publicId.length()-1);
}
String resolvedString = catalog.resolveEntity(filePath.toString(), publicId, publicId);
if (resolvedString != null) {
getLog().debug("-------------------");
getLog().debug("Resolved namespace/schemaLocation "+namespaceOrLocation+" to "+resolvedString+" using catalog "+catalog);
URL resolvedUrl = new URL(resolvedString);
String resolvedPathString = resolvedUrl.getPath();
Path resolvedPath = new File(resolvedPathString).toPath();
Path workDirPath = workDir.toPath();
Path resolvedRelativeToCatalogWorkdir = artifactItem.getWorkDir().toPath().relativize(resolvedPath);
Path fileRelativeToWorkdir = workDirPath.relativize(filePath);
getLog().debug("workDirPath: "+workDirPath);
getLog().debug("resolvedRelativeToCatalogWorkdir: "+resolvedRelativeToCatalogWorkdir+", fileRelativeToWorkdir: "+fileRelativeToWorkdir);
Path relativePath = fileRelativeToWorkdir.getParent().relativize(resolvedRelativeToCatalogWorkdir);
getLog().debug("Rel: "+relativePath);
String unixSeparators = FilenameUtils.separatorsToUnix(relativePath.toString());
getLog().debug("Normalized to use UNIX separators: " + unixSeparators);
return unixSeparators;
}
}
throw new MojoExecutionException("Cannot resolve namespace "+namespaceOrLocation+" in file "+filePath+" using any of the catalogs");
}
示例7: getCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* Get a catalog instance.
*
* If this manager uses static catalogs, the same static catalog will
* always be returned. Otherwise a new catalog will be returned.
*/
public Catalog getCatalog() {
Catalog catalog = staticCatalog;
if (catalog == null || !super.getUseStaticCatalog()) {
catalog = getPrivateCatalog();
}
return catalog;
}
示例8: resolveWSDLLocationByCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
private String resolveWSDLLocationByCatalog(String wsdlLocation) {
if (catalogManager != null) {
Catalog catalog = catalogManager.getCatalog();
if (catalog != null) {
String resolvedLocation = null;
try {
resolvedLocation = catalog.resolveSystem(wsdlLocation);
if (resolvedLocation == null) {
resolvedLocation = catalog.resolveURI(wsdlLocation);
}
// normally, one might also do the following, but in this case we're looking at a top-level WSDL, so no parent
// resolvedLocation = catalog.resolvePublic(wsdlLocation, parent);
if (resolvedLocation != null) {
if (log.isDebugEnabled()) {
log.debug("XMLCatalog transformed original wsdl location \""
+ wsdlLocation
+ "\" to \""
+ resolvedLocation + "\"");
}
return resolvedLocation;
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Catalog resolution attempt caused exception: "
+ e);
}
}
}
}
return wsdlLocation;
}
示例9: attachReaderToCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* Attaches the reader to the catalog.
*/
private void attachReaderToCatalog (Catalog catalog) {
SAXParserFactory spf = new SAXParserFactoryImpl();
spf.setNamespaceAware(true);
spf.setValidating(false);
SAXCatalogReader saxReader = new SAXCatalogReader(spf);
saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog",
"org.apache.xml.resolver.readers.OASISXMLCatalogReader");
catalog.addReader("application/xml", saxReader);
}
示例10: getResolveCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
public Catalog getResolveCatalog() {
return resolveCatalog;
}
示例11: setResolveCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
public void setResolveCatalog(Catalog resolveCatalog) {
this.resolveCatalog = resolveCatalog;
}
示例12: CatalogResolver
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
public CatalogResolver(Catalog catalog) {
this.catalog = catalog;
}
示例13: newCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* <p>Create a new ApacheCatalog instance.</p>
*
* <p>This method overrides the superclass method of the same name
* in order to set the resolver object for callbacks. The reason
* we have to do this is that internally Catalog creates a new
* instance of itself for each external catalog file processed.
* That is, if two external catalog files are processed, there
* will be a total of two ApacheCatalog instances, and so on.</p>
* @return the catalog.
*/
@Override
protected Catalog newCatalog() {
final ApacheCatalog cat = (ApacheCatalog) super.newCatalog();
cat.setResolver(resolver);
return cat;
}
示例14: getPrivateCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* Get a new catalog instance.
*
* This method always returns a new instance of the underlying catalog class.
*/
abstract public Catalog getPrivateCatalog();
示例15: getCatalog
import org.apache.xml.resolver.Catalog; //导入依赖的package包/类
/**
* Get a catalog instance.
*
* If this manager uses static catalogs, the same static catalog will
* always be returned. Otherwise a new catalog will be returned.
*/
abstract public Catalog getCatalog();