当前位置: 首页>>代码示例>>Java>>正文


Java Catalog.resolveEntity方法代码示例

本文整理汇总了Java中org.apache.xml.resolver.Catalog.resolveEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Catalog.resolveEntity方法的具体用法?Java Catalog.resolveEntity怎么用?Java Catalog.resolveEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xml.resolver.Catalog的用法示例。


在下文中一共展示了Catalog.resolveEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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");
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:35,代码来源:SchemaDistMojo.java

示例2: 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");
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:35,代码来源:SchemaDistMojo.java


注:本文中的org.apache.xml.resolver.Catalog.resolveEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。